MCPcopy
hub / github.com/markmap/markmap / transform

Function transform

packages/markmap-lib/src/plugins/prism/index.ts:11–37  ·  view source on GitHub ↗
(transformHooks: ITransformHooks)

Source from the content-addressed store, hash-verified

9 name,
10 config,
11 transform(transformHooks: ITransformHooks) {
12 let enableFeature = noop;
13 transformHooks.parser.tap((md) => {
14 md.set({
15 highlight: (str: string, lang: string) => {
16 enableFeature();
17 let grammar = Prism.languages[lang];
18 if (!grammar && lang) {
19 loadLanguages([lang]);
20 grammar = Prism.languages[lang];
21 }
22 if (grammar) {
23 return Prism.highlight(str, grammar, lang);
24 }
25 return '';
26 },
27 });
28 });
29 transformHooks.beforeParse.tap((_, context) => {
30 enableFeature = () => {
31 context.features[name] = true;
32 };
33 });
34 return {
35 styles: plugin.config?.styles,
36 };
37 },
38});
39
40export default plugin;

Callers

nothing calls this directly

Calls 1

tapMethod · 0.80

Tested by

no test coverage detected