mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
64432bcb87
* Upgrade @astrojs/prism to a real package, fix component import not working * Remove `@astrojs/prism` as a dependency of `astro` * Update lock file * Refactor to multiple files * Oops, can't have astro imports run inside node * Follow Nate's suggestion on being minors instead of patchs * Update lockfile
18 lines
526 B
TypeScript
18 lines
526 B
TypeScript
import { runHighlighterWithAstro } from '@astrojs/prism/dist/highlighter';
|
|
import { visit } from 'unist-util-visit';
|
|
|
|
/** */
|
|
export default function remarkPrism() {
|
|
return (tree: any) =>
|
|
visit(tree, 'code', (node: any) => {
|
|
let { lang, value } = node;
|
|
node.type = 'html';
|
|
|
|
let { html, classLanguage } = runHighlighterWithAstro(lang, value);
|
|
let classes = [classLanguage];
|
|
node.value = `<pre class="${classes.join(
|
|
' '
|
|
)}"><code class="${classLanguage}">${html}</code></pre>`;
|
|
return node;
|
|
});
|
|
}
|