markmap-lib 0.16.1 → 0.16.3-web.2
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.
- package/dist/browser/index.iife.js +4332 -3049
- package/dist/browser/index.mjs +66 -80
- package/dist/index.js +18 -17
- package/dist/index.mjs +19 -18
- package/dist/index.no-plugins.js +17 -17
- package/dist/index.no-plugins.mjs +18 -18
- package/dist/markdown-it.d.ts +2 -0
- package/dist/plugins.js +33 -49
- package/dist/plugins.mjs +33 -49
- package/dist/transform.d.ts +2 -2
- package/dist/types.d.ts +6 -11
- package/package.json +14 -9
package/dist/browser/index.mjs
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { Hook, buildJSItem, buildCSSItem, loadJS, noop, wrapFunction, UrlBuilder } from "markmap-common";
|
|
2
2
|
import { buildTree } from "markmap-html-parser";
|
|
3
|
-
import
|
|
3
|
+
import MarkdownIt from "markdown-it";
|
|
4
|
+
import md_ins from "markdown-it-ins";
|
|
5
|
+
import md_mark from "markdown-it-mark";
|
|
6
|
+
import md_sub from "markdown-it-sub";
|
|
7
|
+
import md_sup from "markdown-it-sup";
|
|
4
8
|
import yaml from "js-yaml";
|
|
5
|
-
import
|
|
9
|
+
import katexPlugin from "@iktakahiro/markdown-it-katex";
|
|
10
|
+
function initializeMarkdownIt() {
|
|
11
|
+
const md = MarkdownIt({
|
|
12
|
+
html: true,
|
|
13
|
+
breaks: true
|
|
14
|
+
});
|
|
15
|
+
md.use(md_ins).use(md_mark).use(md_sub).use(md_sup);
|
|
16
|
+
return md;
|
|
17
|
+
}
|
|
6
18
|
function createTransformHooks(transformer) {
|
|
7
19
|
return {
|
|
8
20
|
transformer,
|
|
9
21
|
parser: new Hook(),
|
|
10
22
|
beforeParse: new Hook(),
|
|
11
23
|
afterParse: new Hook(),
|
|
12
|
-
htmltag: new Hook(),
|
|
13
24
|
retransform: new Hook()
|
|
14
25
|
};
|
|
15
26
|
}
|
|
@@ -27,27 +38,22 @@ const plugin$3 = definePlugin({
|
|
|
27
38
|
name: name$5,
|
|
28
39
|
transform(transformHooks) {
|
|
29
40
|
transformHooks.parser.tap((md) => {
|
|
30
|
-
md.core.ruler.before(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/^\[(.)\] /,
|
|
42
|
-
(m, g) => images[g] ? `${images[g]} ` : m
|
|
43
|
-
);
|
|
44
|
-
}
|
|
41
|
+
md.core.ruler.before("inline", "checkbox", (state) => {
|
|
42
|
+
for (let i = 2; i < state.tokens.length; i += 1) {
|
|
43
|
+
const token = state.tokens[i];
|
|
44
|
+
if (token.type === "inline" && token.content) {
|
|
45
|
+
const prevType = state.tokens[i - 1].type;
|
|
46
|
+
const prevPrevType = state.tokens[i - 2].type;
|
|
47
|
+
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
48
|
+
token.content = token.content.replace(
|
|
49
|
+
/^\[(.)\] /,
|
|
50
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
51
|
+
);
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
});
|
|
51
57
|
});
|
|
52
58
|
return {};
|
|
53
59
|
}
|
|
@@ -187,6 +193,22 @@ const plugin$2 = definePlugin({
|
|
|
187
193
|
}
|
|
188
194
|
});
|
|
189
195
|
const pluginHljs = plugin$2;
|
|
196
|
+
function addDefaultVersions(paths, name2, version) {
|
|
197
|
+
return paths.map((path) => {
|
|
198
|
+
if (typeof path === "string" && !path.includes("://")) {
|
|
199
|
+
if (!path.startsWith("npm:")) {
|
|
200
|
+
path = `npm:${path}`;
|
|
201
|
+
}
|
|
202
|
+
const prefixLength = 4 + name2.length;
|
|
203
|
+
if (path.startsWith(`npm:${name2}/`)) {
|
|
204
|
+
path = `${path.slice(0, prefixLength)}@${version}${path.slice(
|
|
205
|
+
prefixLength
|
|
206
|
+
)}`;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return path;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
190
212
|
const name$2 = "katex";
|
|
191
213
|
const preloadScripts = [
|
|
192
214
|
`katex@${"0.16.8"}/dist/katex.min.js`
|
|
@@ -240,22 +262,6 @@ const config = {
|
|
|
240
262
|
],
|
|
241
263
|
styles
|
|
242
264
|
};
|
|
243
|
-
function addDefaultVersions(paths, name2, version) {
|
|
244
|
-
return paths.map((path) => {
|
|
245
|
-
if (typeof path === "string" && !path.includes("://")) {
|
|
246
|
-
if (!path.startsWith("npm:")) {
|
|
247
|
-
path = `npm:${path}`;
|
|
248
|
-
}
|
|
249
|
-
const prefixLength = 4 + name2.length;
|
|
250
|
-
if (path.startsWith(`npm:${name2}/`)) {
|
|
251
|
-
path = `${path.slice(0, prefixLength)}@${version}${path.slice(
|
|
252
|
-
prefixLength
|
|
253
|
-
)}`;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return path;
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
265
|
const plugin$1 = definePlugin({
|
|
260
266
|
name: name$2,
|
|
261
267
|
config,
|
|
@@ -284,12 +290,15 @@ const plugin$1 = definePlugin({
|
|
|
284
290
|
};
|
|
285
291
|
let enableFeature = noop;
|
|
286
292
|
transformHooks.parser.tap((md) => {
|
|
287
|
-
md.use(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
+
md.use(katexPlugin);
|
|
294
|
+
["math_block", "math_inline"].forEach((key) => {
|
|
295
|
+
const fn = (tokens, idx) => {
|
|
296
|
+
enableFeature();
|
|
297
|
+
const result = renderKatex(tokens[idx].content, !!tokens[idx].block);
|
|
298
|
+
return result;
|
|
299
|
+
};
|
|
300
|
+
md.renderer.rules[key] = fn;
|
|
301
|
+
});
|
|
293
302
|
});
|
|
294
303
|
transformHooks.beforeParse.tap((_, context) => {
|
|
295
304
|
enableFeature = () => {
|
|
@@ -351,32 +360,20 @@ const plugin = definePlugin({
|
|
|
351
360
|
name,
|
|
352
361
|
transform(transformHooks) {
|
|
353
362
|
transformHooks.parser.tap((md) => {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
363
|
+
md.renderer.renderAttrs = wrapFunction(
|
|
364
|
+
md.renderer.renderAttrs,
|
|
365
|
+
(renderAttrs, token) => {
|
|
366
|
+
let attrs = renderAttrs(token);
|
|
367
|
+
if (token.block && token.map) {
|
|
368
|
+
attrs += ` data-lines=${token.map.join(",")}`;
|
|
369
|
+
}
|
|
370
|
+
return attrs;
|
|
361
371
|
}
|
|
362
|
-
|
|
372
|
+
);
|
|
363
373
|
});
|
|
364
374
|
return {};
|
|
365
375
|
}
|
|
366
376
|
});
|
|
367
|
-
function patchRule(rule, _key) {
|
|
368
|
-
return wrapFunction(rule, (render, tokens, idx, ...rest) => {
|
|
369
|
-
let html = render(tokens, idx, ...rest);
|
|
370
|
-
const { lines } = tokens[idx];
|
|
371
|
-
if (lines) {
|
|
372
|
-
html = html.replace(
|
|
373
|
-
/^<[\w-]+/,
|
|
374
|
-
(m) => `${m} data-lines="${lines.join(",")}"`
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
return html;
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
377
|
const pluginSourceLines = plugin;
|
|
381
378
|
const plugins = [
|
|
382
379
|
pluginFrontmatter,
|
|
@@ -415,24 +412,12 @@ class Transformer {
|
|
|
415
412
|
assetsMap[name2] = transform(this.hooks);
|
|
416
413
|
}
|
|
417
414
|
this.assetsMap = assetsMap;
|
|
418
|
-
const md =
|
|
419
|
-
html: true,
|
|
420
|
-
breaks: true,
|
|
421
|
-
maxNesting: Infinity
|
|
422
|
-
});
|
|
423
|
-
md.renderer.rules.htmltag = wrapFunction(
|
|
424
|
-
md.renderer.rules.htmltag,
|
|
425
|
-
(render, ...args) => {
|
|
426
|
-
const result = render(...args);
|
|
427
|
-
this.hooks.htmltag.call({ args, result });
|
|
428
|
-
return result;
|
|
429
|
-
}
|
|
430
|
-
);
|
|
415
|
+
const md = initializeMarkdownIt();
|
|
431
416
|
this.md = md;
|
|
432
417
|
this.hooks.parser.call(md);
|
|
433
418
|
}
|
|
434
419
|
transform(content, opts) {
|
|
435
|
-
var _a, _b;
|
|
420
|
+
var _a, _b, _c;
|
|
436
421
|
const context = {
|
|
437
422
|
content,
|
|
438
423
|
features: {},
|
|
@@ -447,6 +432,7 @@ class Transformer {
|
|
|
447
432
|
...opts
|
|
448
433
|
})
|
|
449
434
|
);
|
|
435
|
+
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
450
436
|
return { ...context, root };
|
|
451
437
|
}
|
|
452
438
|
/**
|
|
@@ -478,7 +464,7 @@ class Transformer {
|
|
|
478
464
|
}
|
|
479
465
|
}
|
|
480
466
|
const transformerVersions = {
|
|
481
|
-
"markmap-lib": "0.16.
|
|
467
|
+
"markmap-lib": "0.16.3-web.2+0f4c3f8"
|
|
482
468
|
};
|
|
483
469
|
export {
|
|
484
470
|
Transformer,
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const markmapCommon = require("markmap-common");
|
|
4
4
|
const markmapHtmlParser = require("markmap-html-parser");
|
|
5
|
-
const
|
|
5
|
+
const MarkdownIt = require("markdown-it");
|
|
6
|
+
const md_ins = require("markdown-it-ins");
|
|
7
|
+
const md_mark = require("markdown-it-mark");
|
|
8
|
+
const md_sub = require("markdown-it-sub");
|
|
9
|
+
const md_sup = require("markdown-it-sup");
|
|
6
10
|
const plugins = require("./plugins.js");
|
|
7
11
|
require("js-yaml");
|
|
8
12
|
require("highlight.js");
|
|
9
|
-
require("
|
|
13
|
+
require("@iktakahiro/markdown-it-katex");
|
|
14
|
+
function initializeMarkdownIt() {
|
|
15
|
+
const md = MarkdownIt({
|
|
16
|
+
html: true,
|
|
17
|
+
breaks: true
|
|
18
|
+
});
|
|
19
|
+
md.use(md_ins).use(md_mark).use(md_sub).use(md_sup);
|
|
20
|
+
return md;
|
|
21
|
+
}
|
|
10
22
|
function patchJSItem(urlBuilder, item) {
|
|
11
23
|
if (item.type === "script" && item.data.src) {
|
|
12
24
|
return {
|
|
@@ -60,24 +72,12 @@ class Transformer {
|
|
|
60
72
|
assetsMap[name] = transform(this.hooks);
|
|
61
73
|
}
|
|
62
74
|
this.assetsMap = assetsMap;
|
|
63
|
-
const md =
|
|
64
|
-
html: true,
|
|
65
|
-
breaks: true,
|
|
66
|
-
maxNesting: Infinity
|
|
67
|
-
});
|
|
68
|
-
md.renderer.rules.htmltag = markmapCommon.wrapFunction(
|
|
69
|
-
md.renderer.rules.htmltag,
|
|
70
|
-
(render, ...args) => {
|
|
71
|
-
const result = render(...args);
|
|
72
|
-
this.hooks.htmltag.call({ args, result });
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
);
|
|
75
|
+
const md = initializeMarkdownIt();
|
|
76
76
|
this.md = md;
|
|
77
77
|
this.hooks.parser.call(md);
|
|
78
78
|
}
|
|
79
79
|
transform(content, opts) {
|
|
80
|
-
var _a, _b;
|
|
80
|
+
var _a, _b, _c;
|
|
81
81
|
const context = {
|
|
82
82
|
content,
|
|
83
83
|
features: {},
|
|
@@ -92,6 +92,7 @@ class Transformer {
|
|
|
92
92
|
...opts
|
|
93
93
|
})
|
|
94
94
|
);
|
|
95
|
+
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
95
96
|
return { ...context, root };
|
|
96
97
|
}
|
|
97
98
|
/**
|
|
@@ -123,7 +124,7 @@ class Transformer {
|
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
const transformerVersions = {
|
|
126
|
-
"markmap-lib": "0.16.
|
|
127
|
+
"markmap-lib": "0.16.3-web.2+0f4c3f8"
|
|
127
128
|
};
|
|
128
129
|
exports.Transformer = Transformer;
|
|
129
130
|
exports.builtInPlugins = builtInPlugins;
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import { UrlBuilder
|
|
1
|
+
import { UrlBuilder } from "markmap-common";
|
|
2
2
|
import { buildTree } from "markmap-html-parser";
|
|
3
|
-
import
|
|
3
|
+
import MarkdownIt from "markdown-it";
|
|
4
|
+
import md_ins from "markdown-it-ins";
|
|
5
|
+
import md_mark from "markdown-it-mark";
|
|
6
|
+
import md_sub from "markdown-it-sub";
|
|
7
|
+
import md_sup from "markdown-it-sup";
|
|
4
8
|
import { plugins, createTransformHooks } from "./plugins.mjs";
|
|
5
9
|
import "js-yaml";
|
|
6
10
|
import "highlight.js";
|
|
7
|
-
import "
|
|
11
|
+
import "@iktakahiro/markdown-it-katex";
|
|
12
|
+
function initializeMarkdownIt() {
|
|
13
|
+
const md = MarkdownIt({
|
|
14
|
+
html: true,
|
|
15
|
+
breaks: true
|
|
16
|
+
});
|
|
17
|
+
md.use(md_ins).use(md_mark).use(md_sub).use(md_sup);
|
|
18
|
+
return md;
|
|
19
|
+
}
|
|
8
20
|
function patchJSItem(urlBuilder, item) {
|
|
9
21
|
if (item.type === "script" && item.data.src) {
|
|
10
22
|
return {
|
|
@@ -58,24 +70,12 @@ class Transformer {
|
|
|
58
70
|
assetsMap[name] = transform(this.hooks);
|
|
59
71
|
}
|
|
60
72
|
this.assetsMap = assetsMap;
|
|
61
|
-
const md =
|
|
62
|
-
html: true,
|
|
63
|
-
breaks: true,
|
|
64
|
-
maxNesting: Infinity
|
|
65
|
-
});
|
|
66
|
-
md.renderer.rules.htmltag = wrapFunction(
|
|
67
|
-
md.renderer.rules.htmltag,
|
|
68
|
-
(render, ...args) => {
|
|
69
|
-
const result = render(...args);
|
|
70
|
-
this.hooks.htmltag.call({ args, result });
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
);
|
|
73
|
+
const md = initializeMarkdownIt();
|
|
74
74
|
this.md = md;
|
|
75
75
|
this.hooks.parser.call(md);
|
|
76
76
|
}
|
|
77
77
|
transform(content, opts) {
|
|
78
|
-
var _a, _b;
|
|
78
|
+
var _a, _b, _c;
|
|
79
79
|
const context = {
|
|
80
80
|
content,
|
|
81
81
|
features: {},
|
|
@@ -90,6 +90,7 @@ class Transformer {
|
|
|
90
90
|
...opts
|
|
91
91
|
})
|
|
92
92
|
);
|
|
93
|
+
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
93
94
|
return { ...context, root };
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
@@ -121,7 +122,7 @@ class Transformer {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
const transformerVersions = {
|
|
124
|
-
"markmap-lib": "0.16.
|
|
125
|
+
"markmap-lib": "0.16.3-web.2+0f4c3f8"
|
|
125
126
|
};
|
|
126
127
|
export {
|
|
127
128
|
Transformer,
|
package/dist/index.no-plugins.js
CHANGED
|
@@ -2,14 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const markmapCommon = require("markmap-common");
|
|
4
4
|
const markmapHtmlParser = require("markmap-html-parser");
|
|
5
|
-
const
|
|
5
|
+
const MarkdownIt = require("markdown-it");
|
|
6
|
+
const md_ins = require("markdown-it-ins");
|
|
7
|
+
const md_mark = require("markdown-it-mark");
|
|
8
|
+
const md_sub = require("markdown-it-sub");
|
|
9
|
+
const md_sup = require("markdown-it-sup");
|
|
10
|
+
function initializeMarkdownIt() {
|
|
11
|
+
const md = MarkdownIt({
|
|
12
|
+
html: true,
|
|
13
|
+
breaks: true
|
|
14
|
+
});
|
|
15
|
+
md.use(md_ins).use(md_mark).use(md_sub).use(md_sup);
|
|
16
|
+
return md;
|
|
17
|
+
}
|
|
6
18
|
function createTransformHooks(transformer) {
|
|
7
19
|
return {
|
|
8
20
|
transformer,
|
|
9
21
|
parser: new markmapCommon.Hook(),
|
|
10
22
|
beforeParse: new markmapCommon.Hook(),
|
|
11
23
|
afterParse: new markmapCommon.Hook(),
|
|
12
|
-
htmltag: new markmapCommon.Hook(),
|
|
13
24
|
retransform: new markmapCommon.Hook()
|
|
14
25
|
};
|
|
15
26
|
}
|
|
@@ -66,24 +77,12 @@ class Transformer {
|
|
|
66
77
|
assetsMap[name] = transform(this.hooks);
|
|
67
78
|
}
|
|
68
79
|
this.assetsMap = assetsMap;
|
|
69
|
-
const md =
|
|
70
|
-
html: true,
|
|
71
|
-
breaks: true,
|
|
72
|
-
maxNesting: Infinity
|
|
73
|
-
});
|
|
74
|
-
md.renderer.rules.htmltag = markmapCommon.wrapFunction(
|
|
75
|
-
md.renderer.rules.htmltag,
|
|
76
|
-
(render, ...args) => {
|
|
77
|
-
const result = render(...args);
|
|
78
|
-
this.hooks.htmltag.call({ args, result });
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
);
|
|
80
|
+
const md = initializeMarkdownIt();
|
|
82
81
|
this.md = md;
|
|
83
82
|
this.hooks.parser.call(md);
|
|
84
83
|
}
|
|
85
84
|
transform(content, opts) {
|
|
86
|
-
var _a, _b;
|
|
85
|
+
var _a, _b, _c;
|
|
87
86
|
const context = {
|
|
88
87
|
content,
|
|
89
88
|
features: {},
|
|
@@ -98,6 +97,7 @@ class Transformer {
|
|
|
98
97
|
...opts
|
|
99
98
|
})
|
|
100
99
|
);
|
|
100
|
+
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
101
101
|
return { ...context, root };
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
@@ -129,7 +129,7 @@ class Transformer {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
const transformerVersions = {
|
|
132
|
-
"markmap-lib": "0.16.
|
|
132
|
+
"markmap-lib": "0.16.3-web.2+0f4c3f8"
|
|
133
133
|
};
|
|
134
134
|
exports.Transformer = Transformer;
|
|
135
135
|
exports.builtInPlugins = builtInPlugins;
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import { Hook, UrlBuilder
|
|
1
|
+
import { Hook, UrlBuilder } from "markmap-common";
|
|
2
2
|
import { buildTree } from "markmap-html-parser";
|
|
3
|
-
import
|
|
3
|
+
import MarkdownIt from "markdown-it";
|
|
4
|
+
import md_ins from "markdown-it-ins";
|
|
5
|
+
import md_mark from "markdown-it-mark";
|
|
6
|
+
import md_sub from "markdown-it-sub";
|
|
7
|
+
import md_sup from "markdown-it-sup";
|
|
8
|
+
function initializeMarkdownIt() {
|
|
9
|
+
const md = MarkdownIt({
|
|
10
|
+
html: true,
|
|
11
|
+
breaks: true
|
|
12
|
+
});
|
|
13
|
+
md.use(md_ins).use(md_mark).use(md_sub).use(md_sup);
|
|
14
|
+
return md;
|
|
15
|
+
}
|
|
4
16
|
function createTransformHooks(transformer) {
|
|
5
17
|
return {
|
|
6
18
|
transformer,
|
|
7
19
|
parser: new Hook(),
|
|
8
20
|
beforeParse: new Hook(),
|
|
9
21
|
afterParse: new Hook(),
|
|
10
|
-
htmltag: new Hook(),
|
|
11
22
|
retransform: new Hook()
|
|
12
23
|
};
|
|
13
24
|
}
|
|
@@ -64,24 +75,12 @@ class Transformer {
|
|
|
64
75
|
assetsMap[name] = transform(this.hooks);
|
|
65
76
|
}
|
|
66
77
|
this.assetsMap = assetsMap;
|
|
67
|
-
const md =
|
|
68
|
-
html: true,
|
|
69
|
-
breaks: true,
|
|
70
|
-
maxNesting: Infinity
|
|
71
|
-
});
|
|
72
|
-
md.renderer.rules.htmltag = wrapFunction(
|
|
73
|
-
md.renderer.rules.htmltag,
|
|
74
|
-
(render, ...args) => {
|
|
75
|
-
const result = render(...args);
|
|
76
|
-
this.hooks.htmltag.call({ args, result });
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
);
|
|
78
|
+
const md = initializeMarkdownIt();
|
|
80
79
|
this.md = md;
|
|
81
80
|
this.hooks.parser.call(md);
|
|
82
81
|
}
|
|
83
82
|
transform(content, opts) {
|
|
84
|
-
var _a, _b;
|
|
83
|
+
var _a, _b, _c;
|
|
85
84
|
const context = {
|
|
86
85
|
content,
|
|
87
86
|
features: {},
|
|
@@ -96,6 +95,7 @@ class Transformer {
|
|
|
96
95
|
...opts
|
|
97
96
|
})
|
|
98
97
|
);
|
|
98
|
+
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
99
99
|
return { ...context, root };
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
@@ -127,7 +127,7 @@ class Transformer {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
const transformerVersions = {
|
|
130
|
-
"markmap-lib": "0.16.
|
|
130
|
+
"markmap-lib": "0.16.3-web.2+0f4c3f8"
|
|
131
131
|
};
|
|
132
132
|
export {
|
|
133
133
|
Transformer,
|
package/dist/plugins.js
CHANGED
|
@@ -3,14 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const markmapCommon = require("markmap-common");
|
|
4
4
|
const yaml = require("js-yaml");
|
|
5
5
|
const hljs = require("highlight.js");
|
|
6
|
-
const
|
|
6
|
+
const katexPlugin = require("@iktakahiro/markdown-it-katex");
|
|
7
7
|
function createTransformHooks(transformer) {
|
|
8
8
|
return {
|
|
9
9
|
transformer,
|
|
10
10
|
parser: new markmapCommon.Hook(),
|
|
11
11
|
beforeParse: new markmapCommon.Hook(),
|
|
12
12
|
afterParse: new markmapCommon.Hook(),
|
|
13
|
-
htmltag: new markmapCommon.Hook(),
|
|
14
13
|
retransform: new markmapCommon.Hook()
|
|
15
14
|
};
|
|
16
15
|
}
|
|
@@ -28,27 +27,22 @@ const plugin$3 = definePlugin({
|
|
|
28
27
|
name: name$5,
|
|
29
28
|
transform(transformHooks) {
|
|
30
29
|
transformHooks.parser.tap((md) => {
|
|
31
|
-
md.core.ruler.before(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/^\[(.)\] /,
|
|
43
|
-
(m, g) => images[g] ? `${images[g]} ` : m
|
|
44
|
-
);
|
|
45
|
-
}
|
|
30
|
+
md.core.ruler.before("inline", "checkbox", (state) => {
|
|
31
|
+
for (let i = 2; i < state.tokens.length; i += 1) {
|
|
32
|
+
const token = state.tokens[i];
|
|
33
|
+
if (token.type === "inline" && token.content) {
|
|
34
|
+
const prevType = state.tokens[i - 1].type;
|
|
35
|
+
const prevPrevType = state.tokens[i - 2].type;
|
|
36
|
+
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
37
|
+
token.content = token.content.replace(
|
|
38
|
+
/^\[(.)\] /,
|
|
39
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
40
|
+
);
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
});
|
|
52
46
|
});
|
|
53
47
|
return {};
|
|
54
48
|
}
|
|
@@ -209,14 +203,16 @@ const plugin$1 = definePlugin({
|
|
|
209
203
|
var _a, _b;
|
|
210
204
|
let enableFeature = markmapCommon.noop;
|
|
211
205
|
transformHooks.parser.tap((md) => {
|
|
212
|
-
md.use(
|
|
213
|
-
|
|
214
|
-
md.renderer.rules
|
|
215
|
-
(
|
|
216
|
-
|
|
217
|
-
|
|
206
|
+
md.use(katexPlugin);
|
|
207
|
+
["math_block", "math_inline"].forEach((key) => {
|
|
208
|
+
const fn = md.renderer.rules[key];
|
|
209
|
+
if (fn) {
|
|
210
|
+
md.renderer.rules[key] = markmapCommon.wrapFunction(fn, (render, ...args) => {
|
|
211
|
+
enableFeature();
|
|
212
|
+
return render(...args);
|
|
213
|
+
});
|
|
218
214
|
}
|
|
219
|
-
);
|
|
215
|
+
});
|
|
220
216
|
});
|
|
221
217
|
transformHooks.beforeParse.tap((_, context) => {
|
|
222
218
|
enableFeature = () => {
|
|
@@ -261,32 +257,20 @@ const plugin = definePlugin({
|
|
|
261
257
|
name,
|
|
262
258
|
transform(transformHooks) {
|
|
263
259
|
transformHooks.parser.tap((md) => {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
260
|
+
md.renderer.renderAttrs = markmapCommon.wrapFunction(
|
|
261
|
+
md.renderer.renderAttrs,
|
|
262
|
+
(renderAttrs, token) => {
|
|
263
|
+
let attrs = renderAttrs(token);
|
|
264
|
+
if (token.block && token.map) {
|
|
265
|
+
attrs += ` data-lines=${token.map.join(",")}`;
|
|
266
|
+
}
|
|
267
|
+
return attrs;
|
|
271
268
|
}
|
|
272
|
-
|
|
269
|
+
);
|
|
273
270
|
});
|
|
274
271
|
return {};
|
|
275
272
|
}
|
|
276
273
|
});
|
|
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
274
|
const pluginSourceLines = plugin;
|
|
291
275
|
const plugins = [
|
|
292
276
|
pluginFrontmatter,
|