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

Function transform

packages/markmap-lib/src/plugins/hljs/index.ts:10–29  ·  view source on GitHub ↗
(transformHooks: ITransformHooks)

Source from the content-addressed store, hash-verified

8 name,
9 config,
10 transform(transformHooks: ITransformHooks) {
11 let enableFeature = noop;
12 transformHooks.parser.tap((md) => {
13 md.set({
14 highlight: (str: string, language?: string) => {
15 enableFeature();
16 return hljs.highlightAuto(str, language ? [language] : undefined)
17 .value;
18 },
19 });
20 });
21 transformHooks.beforeParse.tap((_, context) => {
22 enableFeature = () => {
23 context.features[name] = true;
24 };
25 });
26 return {
27 styles: plugin.config?.styles,
28 };
29 },
30});
31
32export default plugin;

Callers 1

constructorMethod · 0.50

Calls 1

tapMethod · 0.80

Tested by

no test coverage detected