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

Function transform

packages/markmap-lib/src/plugins/katex/index.ts:10–33  ·  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.use(katexPlugin);
14 ['math_block', 'math_inline'].forEach((key) => {
15 const fn = md.renderer.rules[key];
16 if (fn) {
17 md.renderer.rules[key] = wrapFunction(fn, (render, ...args) => {
18 enableFeature();
19 return render(...args);
20 });
21 }
22 });
23 });
24 transformHooks.beforeParse.tap((_, context) => {
25 enableFeature = () => {
26 context.features[name] = true;
27 };
28 });
29 return {
30 styles: plugin.config?.styles,
31 scripts: plugin.config?.scripts,
32 };
33 },
34});
35
36export default plugin;

Callers

nothing calls this directly

Calls 3

wrapFunctionFunction · 0.90
renderFunction · 0.85
tapMethod · 0.80

Tested by

no test coverage detected