forked from docsifyjs/docsify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
17 lines (15 loc) 路 706 Bytes
/
Copy pathcode.js
File metadata and controls
17 lines (15 loc) 路 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import Prism from 'prismjs';
// See https://github.com/PrismJS/prism/pull/1367
import 'prismjs/components/prism-markup-templating.js';
import checkLangDependenciesAllLoaded from '../../util/prism.js';
export const highlightCodeCompiler = ({ renderer }) =>
(renderer.code = function ({ text, lang = 'markup' }) {
checkLangDependenciesAllLoaded(lang);
const langOrMarkup = Prism.languages[lang] || Prism.languages.markup;
const code = Prism.highlight(
text.replace(/@DOCSIFY_QM@/g, '`'),
langOrMarkup,
lang,
);
return /* html */ `<pre data-lang="${lang}" class="language-${lang}"><code class="lang-${lang} language-${lang}" tabindex="0">${code}</code></pre>`;
});