markmap-lib 0.17.1 → 0.17.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 +6807 -3560
- package/dist/browser/index.mjs +16 -15
- package/dist/index.js +8 -12
- package/dist/index.mjs +8 -12
- package/dist/index.no-plugins.js +7 -11
- package/dist/index.no-plugins.mjs +7 -11
- package/dist/plugins.js +9 -4
- package/dist/plugins.mjs +9 -4
- package/dist/transform.d.ts +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +5 -5
package/dist/browser/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import md_ins from "markdown-it-ins";
|
|
|
5
5
|
import md_mark from "markdown-it-mark";
|
|
6
6
|
import md_sub from "markdown-it-sub";
|
|
7
7
|
import md_sup from "markdown-it-sup";
|
|
8
|
-
import
|
|
8
|
+
import { parse } from "yaml";
|
|
9
9
|
import katexPlugin from "@iktakahiro/markdown-it-katex";
|
|
10
10
|
function initializeMarkdownIt() {
|
|
11
11
|
const md = MarkdownIt({
|
|
@@ -63,17 +63,18 @@ const name$4 = "frontmatter";
|
|
|
63
63
|
const pluginFrontmatter = definePlugin({
|
|
64
64
|
name: name$4,
|
|
65
65
|
transform(transformHooks) {
|
|
66
|
-
transformHooks.beforeParse.tap((
|
|
66
|
+
transformHooks.beforeParse.tap((_md, context) => {
|
|
67
|
+
var _a;
|
|
67
68
|
const { content } = context;
|
|
68
69
|
if (!/^---\r?\n/.test(content))
|
|
69
70
|
return;
|
|
70
71
|
const match = /\n---\r?\n/.exec(content);
|
|
71
72
|
if (!match)
|
|
72
73
|
return;
|
|
73
|
-
const raw = content.slice(4, match.index);
|
|
74
|
+
const raw = content.slice(4, match.index).trimEnd();
|
|
74
75
|
let frontmatter;
|
|
75
76
|
try {
|
|
76
|
-
frontmatter =
|
|
77
|
+
frontmatter = parse(raw.replace(/\r?\n|\r/g, "\n"));
|
|
77
78
|
if (frontmatter == null ? void 0 : frontmatter.markmap) {
|
|
78
79
|
frontmatter.markmap = normalizeMarkmapJsonOptions(
|
|
79
80
|
frontmatter.markmap
|
|
@@ -83,6 +84,10 @@ const pluginFrontmatter = definePlugin({
|
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
86
|
context.frontmatter = frontmatter;
|
|
87
|
+
context.parserOptions = {
|
|
88
|
+
...context.parserOptions,
|
|
89
|
+
...(_a = frontmatter == null ? void 0 : frontmatter.markmap) == null ? void 0 : _a.htmlParser
|
|
90
|
+
};
|
|
86
91
|
context.content = content.slice(match.index + match[0].length);
|
|
87
92
|
context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
|
|
88
93
|
});
|
|
@@ -416,23 +421,19 @@ class Transformer {
|
|
|
416
421
|
this.md = md;
|
|
417
422
|
this.hooks.parser.call(md);
|
|
418
423
|
}
|
|
419
|
-
transform(content,
|
|
420
|
-
var _a
|
|
424
|
+
transform(content, fallbackParserOptions) {
|
|
425
|
+
var _a;
|
|
421
426
|
const context = {
|
|
422
427
|
content,
|
|
423
428
|
features: {},
|
|
424
|
-
contentLineOffset: 0
|
|
429
|
+
contentLineOffset: 0,
|
|
430
|
+
parserOptions: fallbackParserOptions
|
|
425
431
|
};
|
|
426
432
|
this.hooks.beforeParse.call(this.md, context);
|
|
427
433
|
const html = this.md.render(context.content, {});
|
|
428
434
|
this.hooks.afterParse.call(this.md, context);
|
|
429
|
-
const root = cleanNode(
|
|
430
|
-
|
|
431
|
-
...(_b = (_a = context.frontmatter) == null ? void 0 : _a.markmap) == null ? void 0 : _b.htmlParser,
|
|
432
|
-
...opts
|
|
433
|
-
})
|
|
434
|
-
);
|
|
435
|
-
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
435
|
+
const root = cleanNode(buildTree(html, context.parserOptions));
|
|
436
|
+
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
436
437
|
return { ...context, root };
|
|
437
438
|
}
|
|
438
439
|
/**
|
|
@@ -464,7 +465,7 @@ class Transformer {
|
|
|
464
465
|
}
|
|
465
466
|
}
|
|
466
467
|
const transformerVersions = {
|
|
467
|
-
"markmap-lib": "0.17.
|
|
468
|
+
"markmap-lib": "0.17.2"
|
|
468
469
|
};
|
|
469
470
|
export {
|
|
470
471
|
Transformer,
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const md_mark = require("markdown-it-mark");
|
|
|
8
8
|
const md_sub = require("markdown-it-sub");
|
|
9
9
|
const md_sup = require("markdown-it-sup");
|
|
10
10
|
const plugins = require("./plugins.js");
|
|
11
|
-
require("
|
|
11
|
+
require("yaml");
|
|
12
12
|
require("highlight.js");
|
|
13
13
|
require("@iktakahiro/markdown-it-katex");
|
|
14
14
|
function initializeMarkdownIt() {
|
|
@@ -76,23 +76,19 @@ class Transformer {
|
|
|
76
76
|
this.md = md;
|
|
77
77
|
this.hooks.parser.call(md);
|
|
78
78
|
}
|
|
79
|
-
transform(content,
|
|
80
|
-
var _a
|
|
79
|
+
transform(content, fallbackParserOptions) {
|
|
80
|
+
var _a;
|
|
81
81
|
const context = {
|
|
82
82
|
content,
|
|
83
83
|
features: {},
|
|
84
|
-
contentLineOffset: 0
|
|
84
|
+
contentLineOffset: 0,
|
|
85
|
+
parserOptions: fallbackParserOptions
|
|
85
86
|
};
|
|
86
87
|
this.hooks.beforeParse.call(this.md, context);
|
|
87
88
|
const html = this.md.render(context.content, {});
|
|
88
89
|
this.hooks.afterParse.call(this.md, context);
|
|
89
|
-
const root = cleanNode(
|
|
90
|
-
|
|
91
|
-
...(_b = (_a = context.frontmatter) == null ? void 0 : _a.markmap) == null ? void 0 : _b.htmlParser,
|
|
92
|
-
...opts
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
90
|
+
const root = cleanNode(markmapHtmlParser.buildTree(html, context.parserOptions));
|
|
91
|
+
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
96
92
|
return { ...context, root };
|
|
97
93
|
}
|
|
98
94
|
/**
|
|
@@ -124,7 +120,7 @@ class Transformer {
|
|
|
124
120
|
}
|
|
125
121
|
}
|
|
126
122
|
const transformerVersions = {
|
|
127
|
-
"markmap-lib": "0.17.
|
|
123
|
+
"markmap-lib": "0.17.2"
|
|
128
124
|
};
|
|
129
125
|
exports.Transformer = Transformer;
|
|
130
126
|
exports.builtInPlugins = builtInPlugins;
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import md_mark from "markdown-it-mark";
|
|
|
6
6
|
import md_sub from "markdown-it-sub";
|
|
7
7
|
import md_sup from "markdown-it-sup";
|
|
8
8
|
import { plugins, createTransformHooks } from "./plugins.mjs";
|
|
9
|
-
import "
|
|
9
|
+
import "yaml";
|
|
10
10
|
import "highlight.js";
|
|
11
11
|
import "@iktakahiro/markdown-it-katex";
|
|
12
12
|
function initializeMarkdownIt() {
|
|
@@ -74,23 +74,19 @@ class Transformer {
|
|
|
74
74
|
this.md = md;
|
|
75
75
|
this.hooks.parser.call(md);
|
|
76
76
|
}
|
|
77
|
-
transform(content,
|
|
78
|
-
var _a
|
|
77
|
+
transform(content, fallbackParserOptions) {
|
|
78
|
+
var _a;
|
|
79
79
|
const context = {
|
|
80
80
|
content,
|
|
81
81
|
features: {},
|
|
82
|
-
contentLineOffset: 0
|
|
82
|
+
contentLineOffset: 0,
|
|
83
|
+
parserOptions: fallbackParserOptions
|
|
83
84
|
};
|
|
84
85
|
this.hooks.beforeParse.call(this.md, context);
|
|
85
86
|
const html = this.md.render(context.content, {});
|
|
86
87
|
this.hooks.afterParse.call(this.md, context);
|
|
87
|
-
const root = cleanNode(
|
|
88
|
-
|
|
89
|
-
...(_b = (_a = context.frontmatter) == null ? void 0 : _a.markmap) == null ? void 0 : _b.htmlParser,
|
|
90
|
-
...opts
|
|
91
|
-
})
|
|
92
|
-
);
|
|
93
|
-
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
88
|
+
const root = cleanNode(buildTree(html, context.parserOptions));
|
|
89
|
+
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
94
90
|
return { ...context, root };
|
|
95
91
|
}
|
|
96
92
|
/**
|
|
@@ -122,7 +118,7 @@ class Transformer {
|
|
|
122
118
|
}
|
|
123
119
|
}
|
|
124
120
|
const transformerVersions = {
|
|
125
|
-
"markmap-lib": "0.17.
|
|
121
|
+
"markmap-lib": "0.17.2"
|
|
126
122
|
};
|
|
127
123
|
export {
|
|
128
124
|
Transformer,
|
package/dist/index.no-plugins.js
CHANGED
|
@@ -81,23 +81,19 @@ class Transformer {
|
|
|
81
81
|
this.md = md;
|
|
82
82
|
this.hooks.parser.call(md);
|
|
83
83
|
}
|
|
84
|
-
transform(content,
|
|
85
|
-
var _a
|
|
84
|
+
transform(content, fallbackParserOptions) {
|
|
85
|
+
var _a;
|
|
86
86
|
const context = {
|
|
87
87
|
content,
|
|
88
88
|
features: {},
|
|
89
|
-
contentLineOffset: 0
|
|
89
|
+
contentLineOffset: 0,
|
|
90
|
+
parserOptions: fallbackParserOptions
|
|
90
91
|
};
|
|
91
92
|
this.hooks.beforeParse.call(this.md, context);
|
|
92
93
|
const html = this.md.render(context.content, {});
|
|
93
94
|
this.hooks.afterParse.call(this.md, context);
|
|
94
|
-
const root = cleanNode(
|
|
95
|
-
|
|
96
|
-
...(_b = (_a = context.frontmatter) == null ? void 0 : _a.markmap) == null ? void 0 : _b.htmlParser,
|
|
97
|
-
...opts
|
|
98
|
-
})
|
|
99
|
-
);
|
|
100
|
-
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
95
|
+
const root = cleanNode(markmapHtmlParser.buildTree(html, context.parserOptions));
|
|
96
|
+
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
101
97
|
return { ...context, root };
|
|
102
98
|
}
|
|
103
99
|
/**
|
|
@@ -129,7 +125,7 @@ class Transformer {
|
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
127
|
const transformerVersions = {
|
|
132
|
-
"markmap-lib": "0.17.
|
|
128
|
+
"markmap-lib": "0.17.2"
|
|
133
129
|
};
|
|
134
130
|
exports.Transformer = Transformer;
|
|
135
131
|
exports.builtInPlugins = builtInPlugins;
|
|
@@ -79,23 +79,19 @@ class Transformer {
|
|
|
79
79
|
this.md = md;
|
|
80
80
|
this.hooks.parser.call(md);
|
|
81
81
|
}
|
|
82
|
-
transform(content,
|
|
83
|
-
var _a
|
|
82
|
+
transform(content, fallbackParserOptions) {
|
|
83
|
+
var _a;
|
|
84
84
|
const context = {
|
|
85
85
|
content,
|
|
86
86
|
features: {},
|
|
87
|
-
contentLineOffset: 0
|
|
87
|
+
contentLineOffset: 0,
|
|
88
|
+
parserOptions: fallbackParserOptions
|
|
88
89
|
};
|
|
89
90
|
this.hooks.beforeParse.call(this.md, context);
|
|
90
91
|
const html = this.md.render(context.content, {});
|
|
91
92
|
this.hooks.afterParse.call(this.md, context);
|
|
92
|
-
const root = cleanNode(
|
|
93
|
-
|
|
94
|
-
...(_b = (_a = context.frontmatter) == null ? void 0 : _a.markmap) == null ? void 0 : _b.htmlParser,
|
|
95
|
-
...opts
|
|
96
|
-
})
|
|
97
|
-
);
|
|
98
|
-
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
|
|
93
|
+
const root = cleanNode(buildTree(html, context.parserOptions));
|
|
94
|
+
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
99
95
|
return { ...context, root };
|
|
100
96
|
}
|
|
101
97
|
/**
|
|
@@ -127,7 +123,7 @@ class Transformer {
|
|
|
127
123
|
}
|
|
128
124
|
}
|
|
129
125
|
const transformerVersions = {
|
|
130
|
-
"markmap-lib": "0.17.
|
|
126
|
+
"markmap-lib": "0.17.2"
|
|
131
127
|
};
|
|
132
128
|
export {
|
|
133
129
|
Transformer,
|
package/dist/plugins.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const markmapCommon = require("markmap-common");
|
|
4
|
-
const yaml = require("
|
|
4
|
+
const yaml = require("yaml");
|
|
5
5
|
const hljs = require("highlight.js");
|
|
6
6
|
const katexPlugin = require("@iktakahiro/markdown-it-katex");
|
|
7
7
|
function createTransformHooks(transformer) {
|
|
@@ -52,17 +52,18 @@ const name$4 = "frontmatter";
|
|
|
52
52
|
const pluginFrontmatter = definePlugin({
|
|
53
53
|
name: name$4,
|
|
54
54
|
transform(transformHooks) {
|
|
55
|
-
transformHooks.beforeParse.tap((
|
|
55
|
+
transformHooks.beforeParse.tap((_md, context) => {
|
|
56
|
+
var _a;
|
|
56
57
|
const { content } = context;
|
|
57
58
|
if (!/^---\r?\n/.test(content))
|
|
58
59
|
return;
|
|
59
60
|
const match = /\n---\r?\n/.exec(content);
|
|
60
61
|
if (!match)
|
|
61
62
|
return;
|
|
62
|
-
const raw = content.slice(4, match.index);
|
|
63
|
+
const raw = content.slice(4, match.index).trimEnd();
|
|
63
64
|
let frontmatter;
|
|
64
65
|
try {
|
|
65
|
-
frontmatter = yaml.
|
|
66
|
+
frontmatter = yaml.parse(raw.replace(/\r?\n|\r/g, "\n"));
|
|
66
67
|
if (frontmatter == null ? void 0 : frontmatter.markmap) {
|
|
67
68
|
frontmatter.markmap = normalizeMarkmapJsonOptions(
|
|
68
69
|
frontmatter.markmap
|
|
@@ -72,6 +73,10 @@ const pluginFrontmatter = definePlugin({
|
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
context.frontmatter = frontmatter;
|
|
76
|
+
context.parserOptions = {
|
|
77
|
+
...context.parserOptions,
|
|
78
|
+
...(_a = frontmatter == null ? void 0 : frontmatter.markmap) == null ? void 0 : _a.htmlParser
|
|
79
|
+
};
|
|
75
80
|
context.content = content.slice(match.index + match[0].length);
|
|
76
81
|
context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
|
|
77
82
|
});
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hook, buildJSItem, buildCSSItem, noop, wrapFunction } from "markmap-common";
|
|
2
|
-
import
|
|
2
|
+
import { parse } from "yaml";
|
|
3
3
|
import hljs from "highlight.js";
|
|
4
4
|
import katexPlugin from "@iktakahiro/markdown-it-katex";
|
|
5
5
|
function createTransformHooks(transformer) {
|
|
@@ -50,17 +50,18 @@ const name$4 = "frontmatter";
|
|
|
50
50
|
const pluginFrontmatter = definePlugin({
|
|
51
51
|
name: name$4,
|
|
52
52
|
transform(transformHooks) {
|
|
53
|
-
transformHooks.beforeParse.tap((
|
|
53
|
+
transformHooks.beforeParse.tap((_md, context) => {
|
|
54
|
+
var _a;
|
|
54
55
|
const { content } = context;
|
|
55
56
|
if (!/^---\r?\n/.test(content))
|
|
56
57
|
return;
|
|
57
58
|
const match = /\n---\r?\n/.exec(content);
|
|
58
59
|
if (!match)
|
|
59
60
|
return;
|
|
60
|
-
const raw = content.slice(4, match.index);
|
|
61
|
+
const raw = content.slice(4, match.index).trimEnd();
|
|
61
62
|
let frontmatter;
|
|
62
63
|
try {
|
|
63
|
-
frontmatter =
|
|
64
|
+
frontmatter = parse(raw.replace(/\r?\n|\r/g, "\n"));
|
|
64
65
|
if (frontmatter == null ? void 0 : frontmatter.markmap) {
|
|
65
66
|
frontmatter.markmap = normalizeMarkmapJsonOptions(
|
|
66
67
|
frontmatter.markmap
|
|
@@ -70,6 +71,10 @@ const pluginFrontmatter = definePlugin({
|
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
context.frontmatter = frontmatter;
|
|
74
|
+
context.parserOptions = {
|
|
75
|
+
...context.parserOptions,
|
|
76
|
+
...(_a = frontmatter == null ? void 0 : frontmatter.markmap) == null ? void 0 : _a.htmlParser
|
|
77
|
+
};
|
|
73
78
|
context.content = content.slice(match.index + match[0].length);
|
|
74
79
|
context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
|
|
75
80
|
});
|
package/dist/transform.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class Transformer implements ITransformer {
|
|
|
10
10
|
urlBuilder: UrlBuilder;
|
|
11
11
|
plugins: ITransformPlugin[];
|
|
12
12
|
constructor(plugins?: Array<ITransformPlugin | (() => ITransformPlugin)>);
|
|
13
|
-
transform(content: string,
|
|
13
|
+
transform(content: string, fallbackParserOptions?: Partial<IHtmlParserOptions>): ITransformResult;
|
|
14
14
|
/**
|
|
15
15
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
16
16
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export interface ITransformContext {
|
|
|
54
54
|
};
|
|
55
55
|
/** The index of line where content without frontmatter starts */
|
|
56
56
|
contentLineOffset: number;
|
|
57
|
+
parserOptions?: Partial<IHtmlParserOptions>;
|
|
57
58
|
}
|
|
58
59
|
export interface ITransformResult extends ITransformContext {
|
|
59
60
|
root: IPureNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,7 +68,6 @@
|
|
|
68
68
|
"@babel/runtime": "^7.22.6",
|
|
69
69
|
"@iktakahiro/markdown-it-katex": "^4.0.1",
|
|
70
70
|
"highlight.js": "^11.8.0",
|
|
71
|
-
"js-yaml": "^4.1.0",
|
|
72
71
|
"katex": "^0.16.8",
|
|
73
72
|
"markdown-it": "^14.1.0",
|
|
74
73
|
"markdown-it-ins": "^4.0.0",
|
|
@@ -76,8 +75,9 @@
|
|
|
76
75
|
"markdown-it-sub": "^2.0.0",
|
|
77
76
|
"markdown-it-sup": "^2.0.0",
|
|
78
77
|
"markmap-html-parser": "0.17.1",
|
|
79
|
-
"markmap-view": "0.17.
|
|
80
|
-
"prismjs": "^1.29.0"
|
|
78
|
+
"markmap-view": "0.17.2",
|
|
79
|
+
"prismjs": "^1.29.0",
|
|
80
|
+
"yaml": "^2.5.1"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"markmap-common": "*"
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"^(.*\\.svg)\\?raw$": "$1"
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "bbeec32d0efeea4e36755b1909a5993187264487"
|
|
100
100
|
}
|