markmap-lib 0.15.9-alpha.6 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/browser/index.iife.js +38 -150
  2. package/dist/browser/index.mjs +37 -81
  3. package/dist/index.d.ts +1 -3
  4. package/dist/index.js +17 -352
  5. package/dist/index.mjs +18 -353
  6. package/dist/index.no-plugins.js +136 -0
  7. package/dist/index.no-plugins.mjs +136 -0
  8. package/dist/plugins/checkbox/index.d.ts +2 -0
  9. package/dist/plugins/frontmatter/index.d.ts +2 -0
  10. package/dist/plugins/hljs/index.browser.d.ts +2 -0
  11. package/dist/plugins/hljs/index.d.ts +2 -0
  12. package/dist/plugins/index.d.ts +7 -0
  13. package/dist/plugins/katex/index.browser.d.ts +2 -0
  14. package/dist/plugins/katex/index.d.ts +2 -0
  15. package/dist/plugins/npm-url/index.d.ts +2 -0
  16. package/dist/plugins/prism/index.browser.d.ts +2 -0
  17. package/dist/plugins/prism/index.d.ts +2 -0
  18. package/dist/plugins/source-lines/index.d.ts +2 -0
  19. package/dist/plugins.js +307 -0
  20. package/dist/plugins.mjs +307 -0
  21. package/dist/transform.d.ts +3 -9
  22. package/package.json +23 -7
  23. package/dist/constants.d.ts +0 -4
  24. package/dist/plugins/checkbox.d.ts +0 -2
  25. package/dist/plugins/frontmatter.d.ts +0 -2
  26. package/dist/plugins/hljs.browser.d.ts +0 -2
  27. package/dist/plugins/hljs.d.ts +0 -2
  28. package/dist/plugins/katex.browser.d.ts +0 -2
  29. package/dist/plugins/katex.d.ts +0 -2
  30. package/dist/plugins/npm-url.d.ts +0 -2
  31. package/dist/plugins/prism.browser.d.ts +0 -2
  32. package/dist/plugins/prism.d.ts +0 -2
  33. package/dist/plugins/source-lines.d.ts +0 -2
  34. /package/dist/plugins/{hljs.config.d.ts → hljs/config.d.ts} +0 -0
  35. /package/dist/plugins/{katex.config.d.ts → katex/config.d.ts} +0 -0
  36. /package/dist/plugins/{prism.config.d.ts → prism/config.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ declare const plugin: import("../../types").ITransformPlugin;
2
+ export default plugin;
@@ -1,2 +1,9 @@
1
+ import pluginCheckbox from './checkbox';
2
+ import pluginFrontmatter from './frontmatter';
3
+ import pluginHljs from './hljs';
4
+ import pluginKatex from './katex';
5
+ import pluginNpmUrl from './npm-url';
6
+ import pluginSourceLines from './source-lines';
1
7
  export * from './base';
8
+ export { pluginCheckbox, pluginFrontmatter, pluginHljs, pluginKatex, pluginNpmUrl, pluginSourceLines, };
2
9
  export declare const plugins: import("..").ITransformPlugin[];
@@ -0,0 +1,2 @@
1
+ declare const plugin: import("../../types").ITransformPlugin;
2
+ export default plugin;
@@ -0,0 +1,2 @@
1
+ declare const plugin: import("../../types").ITransformPlugin;
2
+ export default plugin;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../../types").ITransformPlugin;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const plugin: import("../../types").ITransformPlugin;
2
+ export default plugin;
@@ -0,0 +1,2 @@
1
+ declare const plugin: import("../../types").ITransformPlugin;
2
+ export default plugin;
@@ -0,0 +1,2 @@
1
+ declare const plugin: import("../../types").ITransformPlugin;
2
+ export default plugin;
@@ -0,0 +1,307 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const markmapCommon = require("markmap-common");
4
+ const yaml = require("js-yaml");
5
+ const hljs = require("highlight.js");
6
+ const remarkableKatex = require("remarkable-katex");
7
+ function createTransformHooks(transformer) {
8
+ return {
9
+ transformer,
10
+ parser: new markmapCommon.Hook(),
11
+ beforeParse: new markmapCommon.Hook(),
12
+ afterParse: new markmapCommon.Hook(),
13
+ htmltag: new markmapCommon.Hook(),
14
+ retransform: new markmapCommon.Hook()
15
+ };
16
+ }
17
+ function definePlugin(plugin2) {
18
+ return plugin2;
19
+ }
20
+ const svgMarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>\n';
21
+ const svgUnmarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>\n';
22
+ const name$5 = "checkbox";
23
+ const images = {
24
+ " ": svgUnmarked.trim(),
25
+ x: svgMarked.trim()
26
+ };
27
+ const plugin$3 = definePlugin({
28
+ name: name$5,
29
+ transform(transformHooks) {
30
+ transformHooks.parser.tap((md) => {
31
+ md.core.ruler.before(
32
+ "inline",
33
+ "checkbox",
34
+ (state) => {
35
+ for (let i = 2; i < state.tokens.length; i += 1) {
36
+ const token = state.tokens[i];
37
+ if (token.type === "inline" && token.content) {
38
+ const prevType = state.tokens[i - 1].type;
39
+ const prevPrevType = state.tokens[i - 2].type;
40
+ if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
41
+ token.content = token.content.replace(
42
+ /^\[(.)\] /,
43
+ (m, g) => images[g] ? `${images[g]} ` : m
44
+ );
45
+ }
46
+ }
47
+ }
48
+ return false;
49
+ },
50
+ {}
51
+ );
52
+ });
53
+ return {};
54
+ }
55
+ });
56
+ const pluginCheckbox = plugin$3;
57
+ const name$4 = "frontmatter";
58
+ const pluginFrontmatter = definePlugin({
59
+ name: name$4,
60
+ transform(transformHooks) {
61
+ transformHooks.beforeParse.tap((md, context) => {
62
+ const { content } = context;
63
+ if (!/^---\r?\n/.test(content))
64
+ return;
65
+ const match = /\n---\r?\n/.exec(content);
66
+ if (!match)
67
+ return;
68
+ const raw = content.slice(4, match.index);
69
+ let frontmatter;
70
+ try {
71
+ frontmatter = yaml.load(raw);
72
+ if (frontmatter == null ? void 0 : frontmatter.markmap) {
73
+ frontmatter.markmap = normalizeMarkmapJsonOptions(
74
+ frontmatter.markmap
75
+ );
76
+ }
77
+ } catch {
78
+ return;
79
+ }
80
+ context.frontmatter = frontmatter;
81
+ context.content = content.slice(match.index + match[0].length);
82
+ context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
83
+ });
84
+ return {};
85
+ }
86
+ });
87
+ function normalizeMarkmapJsonOptions(options) {
88
+ if (!options)
89
+ return;
90
+ ["color", "extraJs", "extraCss"].forEach((key) => {
91
+ if (options[key] != null)
92
+ options[key] = normalizeStringArray(options[key]);
93
+ });
94
+ ["duration", "maxWidth", "initialExpandLevel"].forEach((key) => {
95
+ if (options[key] != null)
96
+ options[key] = normalizeNumber(options[key]);
97
+ });
98
+ return options;
99
+ }
100
+ function normalizeStringArray(value) {
101
+ let result;
102
+ if (typeof value === "string")
103
+ result = [value];
104
+ else if (Array.isArray(value))
105
+ result = value.filter((item) => item && typeof item === "string");
106
+ return (result == null ? void 0 : result.length) ? result : void 0;
107
+ }
108
+ function normalizeNumber(value) {
109
+ if (isNaN(+value))
110
+ return;
111
+ return +value;
112
+ }
113
+ const name$3 = "hljs";
114
+ const preloadScripts$1 = [
115
+ `@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`
116
+ ].map((path) => markmapCommon.buildJSItem(path));
117
+ const styles$1 = [
118
+ `@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
119
+ ].map((path) => markmapCommon.buildCSSItem(path));
120
+ const config$1 = {
121
+ versions: {
122
+ hljs: "11.8.0"
123
+ },
124
+ preloadScripts: preloadScripts$1,
125
+ styles: styles$1
126
+ };
127
+ const plugin$2 = definePlugin({
128
+ name: name$3,
129
+ config: config$1,
130
+ transform(transformHooks) {
131
+ var _a;
132
+ let enableFeature = markmapCommon.noop;
133
+ transformHooks.parser.tap((md) => {
134
+ md.set({
135
+ highlight: (str, language) => {
136
+ enableFeature();
137
+ return hljs.highlightAuto(str, language ? [language] : void 0).value;
138
+ }
139
+ });
140
+ });
141
+ transformHooks.beforeParse.tap((_, context) => {
142
+ enableFeature = () => {
143
+ context.features[name$3] = true;
144
+ };
145
+ });
146
+ return {
147
+ styles: (_a = plugin$2.config) == null ? void 0 : _a.styles
148
+ };
149
+ }
150
+ });
151
+ const pluginHljs = plugin$2;
152
+ const name$2 = "katex";
153
+ const preloadScripts = [
154
+ `katex@${"0.16.8"}/dist/katex.min.js`
155
+ ].map((path) => markmapCommon.buildJSItem(path));
156
+ const webfontloader = markmapCommon.buildJSItem(
157
+ `webfontloader@${"1.6.28"}/webfontloader.js`
158
+ );
159
+ webfontloader.data.defer = true;
160
+ const styles = [`katex@${"0.16.8"}/dist/katex.min.css`].map(
161
+ (path) => markmapCommon.buildCSSItem(path)
162
+ );
163
+ const config = {
164
+ versions: {
165
+ katex: "0.16.8",
166
+ webfontloader: "1.6.28"
167
+ },
168
+ preloadScripts,
169
+ scripts: [
170
+ {
171
+ type: "iife",
172
+ data: {
173
+ fn: (getMarkmap) => {
174
+ window.WebFontConfig = {
175
+ custom: {
176
+ families: [
177
+ "KaTeX_AMS",
178
+ "KaTeX_Caligraphic:n4,n7",
179
+ "KaTeX_Fraktur:n4,n7",
180
+ "KaTeX_Main:n4,n7,i4,i7",
181
+ "KaTeX_Math:i4,i7",
182
+ "KaTeX_Script",
183
+ "KaTeX_SansSerif:n4,n7,i4",
184
+ "KaTeX_Size1",
185
+ "KaTeX_Size2",
186
+ "KaTeX_Size3",
187
+ "KaTeX_Size4",
188
+ "KaTeX_Typewriter"
189
+ ]
190
+ },
191
+ active: () => {
192
+ getMarkmap().refreshHook.call();
193
+ }
194
+ };
195
+ },
196
+ getParams({ getMarkmap }) {
197
+ return [getMarkmap];
198
+ }
199
+ }
200
+ },
201
+ webfontloader
202
+ ],
203
+ styles
204
+ };
205
+ const plugin$1 = definePlugin({
206
+ name: name$2,
207
+ config,
208
+ transform(transformHooks) {
209
+ var _a, _b;
210
+ let enableFeature = markmapCommon.noop;
211
+ transformHooks.parser.tap((md) => {
212
+ md.use(remarkableKatex);
213
+ md.renderer.rules.katex = markmapCommon.wrapFunction(
214
+ md.renderer.rules.katex,
215
+ (render, ...args) => {
216
+ enableFeature();
217
+ return render(...args);
218
+ }
219
+ );
220
+ });
221
+ transformHooks.beforeParse.tap((_, context) => {
222
+ enableFeature = () => {
223
+ context.features[name$2] = true;
224
+ };
225
+ });
226
+ return {
227
+ styles: (_a = plugin$1.config) == null ? void 0 : _a.styles,
228
+ scripts: (_b = plugin$1.config) == null ? void 0 : _b.scripts
229
+ };
230
+ }
231
+ });
232
+ const pluginKatex = plugin$1;
233
+ const name$1 = "npmUrl";
234
+ const pluginNpmUrl = definePlugin({
235
+ name: name$1,
236
+ transform(transformHooks) {
237
+ transformHooks.afterParse.tap((_, context) => {
238
+ const { frontmatter } = context;
239
+ const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
240
+ if (markmap) {
241
+ ["extraJs", "extraCss"].forEach((key) => {
242
+ const value = markmap[key];
243
+ if (value) {
244
+ markmap[key] = value.map((path) => {
245
+ if (path.startsWith("npm:")) {
246
+ return transformHooks.transformer.urlBuilder.getFullUrl(
247
+ path.slice(4)
248
+ );
249
+ }
250
+ return path;
251
+ });
252
+ }
253
+ });
254
+ }
255
+ });
256
+ return {};
257
+ }
258
+ });
259
+ const name = "sourceLines";
260
+ const plugin = definePlugin({
261
+ name,
262
+ transform(transformHooks) {
263
+ transformHooks.parser.tap((md) => {
264
+ Object.entries(md.renderer.rules).forEach(([key, value]) => {
265
+ if (typeof value === "function") {
266
+ md.renderer.rules[key] = patchRule(value);
267
+ } else {
268
+ Object.entries(value).forEach(([k, v]) => {
269
+ value[k] = patchRule(v);
270
+ });
271
+ }
272
+ });
273
+ });
274
+ return {};
275
+ }
276
+ });
277
+ function patchRule(rule, _key) {
278
+ return markmapCommon.wrapFunction(rule, (render, tokens, idx, ...rest) => {
279
+ let html = render(tokens, idx, ...rest);
280
+ const { lines } = tokens[idx];
281
+ if (lines) {
282
+ html = html.replace(
283
+ /^<[\w-]+/,
284
+ (m) => `${m} data-lines="${lines.join(",")}"`
285
+ );
286
+ }
287
+ return html;
288
+ });
289
+ }
290
+ const pluginSourceLines = plugin;
291
+ const plugins = [
292
+ pluginFrontmatter,
293
+ pluginKatex,
294
+ pluginHljs,
295
+ pluginNpmUrl,
296
+ pluginCheckbox,
297
+ pluginSourceLines
298
+ ];
299
+ exports.createTransformHooks = createTransformHooks;
300
+ exports.definePlugin = definePlugin;
301
+ exports.pluginCheckbox = pluginCheckbox;
302
+ exports.pluginFrontmatter = pluginFrontmatter;
303
+ exports.pluginHljs = pluginHljs;
304
+ exports.pluginKatex = pluginKatex;
305
+ exports.pluginNpmUrl = pluginNpmUrl;
306
+ exports.pluginSourceLines = pluginSourceLines;
307
+ exports.plugins = plugins;
@@ -0,0 +1,307 @@
1
+ import { Hook, buildJSItem, buildCSSItem, noop, wrapFunction } from "markmap-common";
2
+ import yaml from "js-yaml";
3
+ import hljs from "highlight.js";
4
+ import remarkableKatex from "remarkable-katex";
5
+ function createTransformHooks(transformer) {
6
+ return {
7
+ transformer,
8
+ parser: new Hook(),
9
+ beforeParse: new Hook(),
10
+ afterParse: new Hook(),
11
+ htmltag: new Hook(),
12
+ retransform: new Hook()
13
+ };
14
+ }
15
+ function definePlugin(plugin2) {
16
+ return plugin2;
17
+ }
18
+ const svgMarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>\n';
19
+ const svgUnmarked = '<svg width="16" height="16" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>\n';
20
+ const name$5 = "checkbox";
21
+ const images = {
22
+ " ": svgUnmarked.trim(),
23
+ x: svgMarked.trim()
24
+ };
25
+ const plugin$3 = definePlugin({
26
+ name: name$5,
27
+ transform(transformHooks) {
28
+ transformHooks.parser.tap((md) => {
29
+ md.core.ruler.before(
30
+ "inline",
31
+ "checkbox",
32
+ (state) => {
33
+ for (let i = 2; i < state.tokens.length; i += 1) {
34
+ const token = state.tokens[i];
35
+ if (token.type === "inline" && token.content) {
36
+ const prevType = state.tokens[i - 1].type;
37
+ const prevPrevType = state.tokens[i - 2].type;
38
+ if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
39
+ token.content = token.content.replace(
40
+ /^\[(.)\] /,
41
+ (m, g) => images[g] ? `${images[g]} ` : m
42
+ );
43
+ }
44
+ }
45
+ }
46
+ return false;
47
+ },
48
+ {}
49
+ );
50
+ });
51
+ return {};
52
+ }
53
+ });
54
+ const pluginCheckbox = plugin$3;
55
+ const name$4 = "frontmatter";
56
+ const pluginFrontmatter = definePlugin({
57
+ name: name$4,
58
+ transform(transformHooks) {
59
+ transformHooks.beforeParse.tap((md, context) => {
60
+ const { content } = context;
61
+ if (!/^---\r?\n/.test(content))
62
+ return;
63
+ const match = /\n---\r?\n/.exec(content);
64
+ if (!match)
65
+ return;
66
+ const raw = content.slice(4, match.index);
67
+ let frontmatter;
68
+ try {
69
+ frontmatter = yaml.load(raw);
70
+ if (frontmatter == null ? void 0 : frontmatter.markmap) {
71
+ frontmatter.markmap = normalizeMarkmapJsonOptions(
72
+ frontmatter.markmap
73
+ );
74
+ }
75
+ } catch {
76
+ return;
77
+ }
78
+ context.frontmatter = frontmatter;
79
+ context.content = content.slice(match.index + match[0].length);
80
+ context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
81
+ });
82
+ return {};
83
+ }
84
+ });
85
+ function normalizeMarkmapJsonOptions(options) {
86
+ if (!options)
87
+ return;
88
+ ["color", "extraJs", "extraCss"].forEach((key) => {
89
+ if (options[key] != null)
90
+ options[key] = normalizeStringArray(options[key]);
91
+ });
92
+ ["duration", "maxWidth", "initialExpandLevel"].forEach((key) => {
93
+ if (options[key] != null)
94
+ options[key] = normalizeNumber(options[key]);
95
+ });
96
+ return options;
97
+ }
98
+ function normalizeStringArray(value) {
99
+ let result;
100
+ if (typeof value === "string")
101
+ result = [value];
102
+ else if (Array.isArray(value))
103
+ result = value.filter((item) => item && typeof item === "string");
104
+ return (result == null ? void 0 : result.length) ? result : void 0;
105
+ }
106
+ function normalizeNumber(value) {
107
+ if (isNaN(+value))
108
+ return;
109
+ return +value;
110
+ }
111
+ const name$3 = "hljs";
112
+ const preloadScripts$1 = [
113
+ `@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`
114
+ ].map((path) => buildJSItem(path));
115
+ const styles$1 = [
116
+ `@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
117
+ ].map((path) => buildCSSItem(path));
118
+ const config$1 = {
119
+ versions: {
120
+ hljs: "11.8.0"
121
+ },
122
+ preloadScripts: preloadScripts$1,
123
+ styles: styles$1
124
+ };
125
+ const plugin$2 = definePlugin({
126
+ name: name$3,
127
+ config: config$1,
128
+ transform(transformHooks) {
129
+ var _a;
130
+ let enableFeature = noop;
131
+ transformHooks.parser.tap((md) => {
132
+ md.set({
133
+ highlight: (str, language) => {
134
+ enableFeature();
135
+ return hljs.highlightAuto(str, language ? [language] : void 0).value;
136
+ }
137
+ });
138
+ });
139
+ transformHooks.beforeParse.tap((_, context) => {
140
+ enableFeature = () => {
141
+ context.features[name$3] = true;
142
+ };
143
+ });
144
+ return {
145
+ styles: (_a = plugin$2.config) == null ? void 0 : _a.styles
146
+ };
147
+ }
148
+ });
149
+ const pluginHljs = plugin$2;
150
+ const name$2 = "katex";
151
+ const preloadScripts = [
152
+ `katex@${"0.16.8"}/dist/katex.min.js`
153
+ ].map((path) => buildJSItem(path));
154
+ const webfontloader = buildJSItem(
155
+ `webfontloader@${"1.6.28"}/webfontloader.js`
156
+ );
157
+ webfontloader.data.defer = true;
158
+ const styles = [`katex@${"0.16.8"}/dist/katex.min.css`].map(
159
+ (path) => buildCSSItem(path)
160
+ );
161
+ const config = {
162
+ versions: {
163
+ katex: "0.16.8",
164
+ webfontloader: "1.6.28"
165
+ },
166
+ preloadScripts,
167
+ scripts: [
168
+ {
169
+ type: "iife",
170
+ data: {
171
+ fn: (getMarkmap) => {
172
+ window.WebFontConfig = {
173
+ custom: {
174
+ families: [
175
+ "KaTeX_AMS",
176
+ "KaTeX_Caligraphic:n4,n7",
177
+ "KaTeX_Fraktur:n4,n7",
178
+ "KaTeX_Main:n4,n7,i4,i7",
179
+ "KaTeX_Math:i4,i7",
180
+ "KaTeX_Script",
181
+ "KaTeX_SansSerif:n4,n7,i4",
182
+ "KaTeX_Size1",
183
+ "KaTeX_Size2",
184
+ "KaTeX_Size3",
185
+ "KaTeX_Size4",
186
+ "KaTeX_Typewriter"
187
+ ]
188
+ },
189
+ active: () => {
190
+ getMarkmap().refreshHook.call();
191
+ }
192
+ };
193
+ },
194
+ getParams({ getMarkmap }) {
195
+ return [getMarkmap];
196
+ }
197
+ }
198
+ },
199
+ webfontloader
200
+ ],
201
+ styles
202
+ };
203
+ const plugin$1 = definePlugin({
204
+ name: name$2,
205
+ config,
206
+ transform(transformHooks) {
207
+ var _a, _b;
208
+ let enableFeature = noop;
209
+ transformHooks.parser.tap((md) => {
210
+ md.use(remarkableKatex);
211
+ md.renderer.rules.katex = wrapFunction(
212
+ md.renderer.rules.katex,
213
+ (render, ...args) => {
214
+ enableFeature();
215
+ return render(...args);
216
+ }
217
+ );
218
+ });
219
+ transformHooks.beforeParse.tap((_, context) => {
220
+ enableFeature = () => {
221
+ context.features[name$2] = true;
222
+ };
223
+ });
224
+ return {
225
+ styles: (_a = plugin$1.config) == null ? void 0 : _a.styles,
226
+ scripts: (_b = plugin$1.config) == null ? void 0 : _b.scripts
227
+ };
228
+ }
229
+ });
230
+ const pluginKatex = plugin$1;
231
+ const name$1 = "npmUrl";
232
+ const pluginNpmUrl = definePlugin({
233
+ name: name$1,
234
+ transform(transformHooks) {
235
+ transformHooks.afterParse.tap((_, context) => {
236
+ const { frontmatter } = context;
237
+ const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
238
+ if (markmap) {
239
+ ["extraJs", "extraCss"].forEach((key) => {
240
+ const value = markmap[key];
241
+ if (value) {
242
+ markmap[key] = value.map((path) => {
243
+ if (path.startsWith("npm:")) {
244
+ return transformHooks.transformer.urlBuilder.getFullUrl(
245
+ path.slice(4)
246
+ );
247
+ }
248
+ return path;
249
+ });
250
+ }
251
+ });
252
+ }
253
+ });
254
+ return {};
255
+ }
256
+ });
257
+ const name = "sourceLines";
258
+ const plugin = definePlugin({
259
+ name,
260
+ transform(transformHooks) {
261
+ transformHooks.parser.tap((md) => {
262
+ Object.entries(md.renderer.rules).forEach(([key, value]) => {
263
+ if (typeof value === "function") {
264
+ md.renderer.rules[key] = patchRule(value);
265
+ } else {
266
+ Object.entries(value).forEach(([k, v]) => {
267
+ value[k] = patchRule(v);
268
+ });
269
+ }
270
+ });
271
+ });
272
+ return {};
273
+ }
274
+ });
275
+ function patchRule(rule, _key) {
276
+ return wrapFunction(rule, (render, tokens, idx, ...rest) => {
277
+ let html = render(tokens, idx, ...rest);
278
+ const { lines } = tokens[idx];
279
+ if (lines) {
280
+ html = html.replace(
281
+ /^<[\w-]+/,
282
+ (m) => `${m} data-lines="${lines.join(",")}"`
283
+ );
284
+ }
285
+ return html;
286
+ });
287
+ }
288
+ const pluginSourceLines = plugin;
289
+ const plugins = [
290
+ pluginFrontmatter,
291
+ pluginKatex,
292
+ pluginHljs,
293
+ pluginNpmUrl,
294
+ pluginCheckbox,
295
+ pluginSourceLines
296
+ ];
297
+ export {
298
+ createTransformHooks,
299
+ definePlugin,
300
+ pluginCheckbox,
301
+ pluginFrontmatter,
302
+ pluginHljs,
303
+ pluginKatex,
304
+ pluginNpmUrl,
305
+ pluginSourceLines,
306
+ plugins
307
+ };
@@ -1,9 +1,8 @@
1
- import { IMarkmapOptions, IPureNode, JSItem, UrlBuilder } from 'markmap-common';
1
+ import { UrlBuilder } from 'markmap-common';
2
2
  import { IHtmlParserOptions } from 'markmap-html-parser';
3
3
  import { Remarkable } from 'remarkable';
4
- import { plugins as builtInPlugins } from './plugins';
5
- import { IAssets, IFeatures, ITransformHooks, ITransformPlugin, ITransformResult, ITransformer, IMarkmapJSONOptions } from './types';
6
- export { builtInPlugins };
4
+ import { IAssets, IFeatures, ITransformHooks, ITransformPlugin, ITransformResult, ITransformer } from './types';
5
+ export declare const builtInPlugins: ITransformPlugin[];
7
6
  export declare class Transformer implements ITransformer {
8
7
  hooks: ITransformHooks;
9
8
  md: Remarkable;
@@ -20,9 +19,4 @@ export declare class Transformer implements ITransformer {
20
19
  * Get used assets by features object returned by `transform`.
21
20
  */
22
21
  getUsedAssets(features: IFeatures): IAssets;
23
- fillTemplate(root: IPureNode | null, assets: IAssets, extra?: {
24
- baseJs?: JSItem[];
25
- jsonOptions?: IMarkmapJSONOptions;
26
- getOptions?: (jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
27
- }): string;
28
22
  }