2 ms·
This is not new, but it's nice to spread awareness since it seems everyone loads it in the front-end nowadays and I've noticed that it also avoids the page movi
by franciscop 6y ago
This is not new, but it's nice to spread awareness since it seems everyone loads it in the front-end nowadays and I've noticed that it also avoids the page moving around too much.
In https://documentation.page/ https://documentation.page/ I'm using `markdown-it` with `prismjs` to generate the code snippets (see example on e.g. https://react-test.dev/ https://react-test.dev/). It's in fact a default helper, so you don't even need hacks:
import MarkdownIt from "markdown-it";
import Prism from "prismjs";
function highlight(str, lang) {
if (!lang || !Prism.languages[lang]) return;
return Prism.highlight(str, Prism.languages[lang], lang);
}
const md = new MarkdownIt({ highlight }).use(...