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

Function transform

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

Source from the content-addressed store, hash-verified

6export default definePlugin({
7 name,
8 transform(transformHooks: ITransformHooks) {
9 transformHooks.afterParse.tap((_, context) => {
10 const { frontmatter } = context;
11 const markmap = frontmatter?.markmap;
12 if (markmap) {
13 (['extraJs', 'extraCss'] as const).forEach((key) => {
14 const value = markmap[key];
15 if (value) {
16 markmap[key] = value.map((path) => {
17 if (path.startsWith('npm:')) {
18 return transformHooks.transformer.urlBuilder.getFullUrl(
19 path.slice(4),
20 );
21 }
22 return path;
23 });
24 }
25 });
26 }
27 });
28 return {};
29 },
30});

Callers

nothing calls this directly

Calls 1

tapMethod · 0.80

Tested by

no test coverage detected