cfae9760b2
* feat: use internal MDX tooling for markdown + components * fix: improve MD + component tests * chore: add changeset * fix: make tsc happy * fix(#3319): add regression test for component children * fix(markdown): support HTML comments in markdown * fix(#2474): ensure namespaced components are properly handled in markdown pages * fix(#3220): ensure html in markdown pages does not have extra surrounding space * fix(#3264): ensure that remark files pass in file information * fix(#3254): enable experimentalStaticExtraction for `.md` pages * fix: revert parsing change * fix: remove `markdown.mode` option
18 lines
490 B
TypeScript
18 lines
490 B
TypeScript
import { map } from 'unist-util-map';
|
|
|
|
export default function rehypeExpressions(): any {
|
|
return function (node: any): any {
|
|
return map(node, (child) => {
|
|
if (child.type === 'text') {
|
|
return { ...child, type: 'raw' };
|
|
}
|
|
if (child.type === 'mdxTextExpression') {
|
|
return { type: 'raw', value: `{${(child as any).value}}` };
|
|
}
|
|
if (child.type === 'mdxFlowExpression') {
|
|
return { type: 'raw', value: `{${(child as any).value}}` };
|
|
}
|
|
return child;
|
|
});
|
|
};
|
|
}
|