* refactor: vite-plugin-md -> vite-plugin-md-legacy * wip: add vite-plugin-md * feat: always apply jsx renderer * fix: markHTMLString on VNode result * feat: apply new vite-plugin-markdown! * fix: add meta export to md * fix: remove needless $$metadata export * fix: toggle to legacy plugin on flag * fix: pass fileId to renderMarkdown * test: raw and compiled content on plain md * fix: escape vite env refs * refactor: astro-md -> legacy-astro-flavored-md, astro-md-mode -> astro-markdown * fix: import.meta.env refs with tests * fix: add pkg.json to clientAddress * fix: prefer JSX integration over Astro runtime * Revert "fix: prefer JSX integration over Astro runtime" This reverts commit 3e5fa49344be9c857393da9af095faab152e92e1. * fix: remove .mdx check on importSource * chore: changeset * chore: remove TODO * fix: add back getHeadings * fix: add pkg.json to astro-head fixture * fix: default to Astro renderer for MDX and MD * feat: add "headings" and "frontmatter" to md layouts * refactor: remove legacy flag conditionals from legacy plugin * fix: add back MDX warning when legacy is off * test: getHeadings() glob * fix: add error on "astro.headings" access * feat: update docs example astro.headings => headings * refactor: readFile as string w/ utf-8 * chore: remove astro metadata TODO * refactor: stringify HTML once * fix: add pkg.json to glob-pages-css
15 lines
509 B
TypeScript
15 lines
509 B
TypeScript
import type { Literal } from 'unist';
|
|
import { visit } from 'unist-util-visit';
|
|
|
|
// In code blocks, this removes the JS comment wrapper added to
|
|
// HTML comments by vite-plugin-markdown-legacy.
|
|
export default function remarkEscape() {
|
|
return (tree: any) => {
|
|
visit(tree, 'code', removeCommentWrapper);
|
|
visit(tree, 'inlineCode', removeCommentWrapper);
|
|
};
|
|
|
|
function removeCommentWrapper(node: Literal<string>) {
|
|
node.value = node.value.replace(/{\/\*<!--/gs, '<!--').replace(/-->\*\/}/gs, '-->');
|
|
}
|
|
}
|