markmap-lib 0.15.9-alpha.11 → 0.15.9-alpha.14
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 +41 -148
- package/dist/browser/index.mjs +40 -78
- package/dist/index.js +3 -44
- package/dist/index.mjs +4 -45
- package/dist/index.no-plugins.js +3 -44
- package/dist/index.no-plugins.mjs +4 -45
- package/dist/plugins/index.d.ts +7 -0
- package/dist/plugins.js +38 -29
- package/dist/plugins.mjs +38 -29
- package/dist/transform.d.ts +2 -7
- package/package.json +10 -6
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
(function(exports, require$$0) {
|
|
2
2
|
"use strict";
|
|
3
|
-
const template =
|
|
3
|
+
const template = process.env.TEMPLATE || "";
|
|
4
4
|
const baseJsPaths = [
|
|
5
5
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
6
|
-
`markmap-view@${"0.15.
|
|
6
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
7
7
|
];
|
|
8
8
|
const testPath = "npm2url/dist/index.cjs";
|
|
9
9
|
const defaultProviders = {
|
|
@@ -96,75 +96,6 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
const escapeChars = {
|
|
100
|
-
"&": "&",
|
|
101
|
-
"<": "<",
|
|
102
|
-
'"': """
|
|
103
|
-
};
|
|
104
|
-
function escapeHtml$1(html2) {
|
|
105
|
-
return html2.replace(/[&<"]/g, (m) => escapeChars[m]);
|
|
106
|
-
}
|
|
107
|
-
function escapeScript(content) {
|
|
108
|
-
return content.replace(/<(\/script>)/g, "\\x3c$2");
|
|
109
|
-
}
|
|
110
|
-
function htmlOpen(tagName, attrs) {
|
|
111
|
-
const attrStr = attrs ? Object.entries(attrs).map(([key, value]) => {
|
|
112
|
-
if (value == null || value === false)
|
|
113
|
-
return;
|
|
114
|
-
key = ` ${escapeHtml$1(key)}`;
|
|
115
|
-
if (value === true)
|
|
116
|
-
return key;
|
|
117
|
-
return `${key}="${escapeHtml$1(value)}"`;
|
|
118
|
-
}).filter(Boolean).join("") : "";
|
|
119
|
-
return `<${tagName}${attrStr}>`;
|
|
120
|
-
}
|
|
121
|
-
function htmlClose(tagName) {
|
|
122
|
-
return `</${tagName}>`;
|
|
123
|
-
}
|
|
124
|
-
function wrapHtml(tagName, content, attrs) {
|
|
125
|
-
if (content == null)
|
|
126
|
-
return htmlOpen(tagName, attrs);
|
|
127
|
-
return htmlOpen(tagName, attrs) + (content || "") + htmlClose(tagName);
|
|
128
|
-
}
|
|
129
|
-
function buildCode(fn, args) {
|
|
130
|
-
const params = args.map((arg) => {
|
|
131
|
-
if (typeof arg === "function")
|
|
132
|
-
return arg.toString();
|
|
133
|
-
return JSON.stringify(arg ?? null);
|
|
134
|
-
}).join(",");
|
|
135
|
-
return `(${fn.toString()})(${params})`;
|
|
136
|
-
}
|
|
137
|
-
function persistJS(items, context) {
|
|
138
|
-
return items.map((item) => {
|
|
139
|
-
if (item.type === "script") {
|
|
140
|
-
const { textContent: textContent2, ...rest } = item.data;
|
|
141
|
-
return wrapHtml(
|
|
142
|
-
"script",
|
|
143
|
-
textContent2 || "",
|
|
144
|
-
rest
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
if (item.type === "iife") {
|
|
148
|
-
const { fn, getParams } = item.data;
|
|
149
|
-
return wrapHtml(
|
|
150
|
-
"script",
|
|
151
|
-
escapeScript(buildCode(fn, (getParams == null ? void 0 : getParams(context)) || []))
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
return "";
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
function persistCSS(items) {
|
|
158
|
-
return items.map((item) => {
|
|
159
|
-
if (item.type === "stylesheet") {
|
|
160
|
-
return wrapHtml("link", null, {
|
|
161
|
-
rel: "stylesheet",
|
|
162
|
-
...item.data
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
return wrapHtml("style", item.data);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
99
|
Math.random().toString(36).slice(2, 8);
|
|
169
100
|
function noop() {
|
|
170
101
|
}
|
|
@@ -18045,9 +17976,13 @@
|
|
|
18045
17976
|
function definePlugin(plugin2) {
|
|
18046
17977
|
return plugin2;
|
|
18047
17978
|
}
|
|
18048
|
-
const
|
|
18049
|
-
const
|
|
17979
|
+
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';
|
|
17980
|
+
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';
|
|
18050
17981
|
const name$5 = "checkbox";
|
|
17982
|
+
const images = {
|
|
17983
|
+
" ": svgUnmarked.trim(),
|
|
17984
|
+
x: svgMarked.trim()
|
|
17985
|
+
};
|
|
18051
17986
|
const plugin$3 = definePlugin({
|
|
18052
17987
|
name: name$5,
|
|
18053
17988
|
transform(transformHooks) {
|
|
@@ -18062,11 +17997,10 @@
|
|
|
18062
17997
|
const prevType = state.tokens[i2 - 1].type;
|
|
18063
17998
|
const prevPrevType = state.tokens[i2 - 2].type;
|
|
18064
17999
|
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
}
|
|
18000
|
+
token.content = token.content.replace(
|
|
18001
|
+
/^\[(.)\] /,
|
|
18002
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
18003
|
+
);
|
|
18070
18004
|
}
|
|
18071
18005
|
}
|
|
18072
18006
|
}
|
|
@@ -18078,7 +18012,7 @@
|
|
|
18078
18012
|
return {};
|
|
18079
18013
|
}
|
|
18080
18014
|
});
|
|
18081
|
-
const
|
|
18015
|
+
const pluginCheckbox = plugin$3;
|
|
18082
18016
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
|
18083
18017
|
function isNothing(subject) {
|
|
18084
18018
|
return typeof subject === "undefined" || subject === null;
|
|
@@ -20769,7 +20703,7 @@
|
|
|
20769
20703
|
};
|
|
20770
20704
|
const yaml = jsYaml;
|
|
20771
20705
|
const name$4 = "frontmatter";
|
|
20772
|
-
const
|
|
20706
|
+
const pluginFrontmatter = definePlugin({
|
|
20773
20707
|
name: name$4,
|
|
20774
20708
|
transform(transformHooks) {
|
|
20775
20709
|
transformHooks.beforeParse.tap((md, context) => {
|
|
@@ -20780,18 +20714,18 @@
|
|
|
20780
20714
|
if (!match)
|
|
20781
20715
|
return;
|
|
20782
20716
|
const raw = content.slice(4, match.index);
|
|
20783
|
-
let
|
|
20717
|
+
let frontmatter;
|
|
20784
20718
|
try {
|
|
20785
|
-
|
|
20786
|
-
if (
|
|
20787
|
-
|
|
20788
|
-
|
|
20719
|
+
frontmatter = yaml.load(raw);
|
|
20720
|
+
if (frontmatter == null ? void 0 : frontmatter.markmap) {
|
|
20721
|
+
frontmatter.markmap = normalizeMarkmapJsonOptions(
|
|
20722
|
+
frontmatter.markmap
|
|
20789
20723
|
);
|
|
20790
20724
|
}
|
|
20791
20725
|
} catch {
|
|
20792
20726
|
return;
|
|
20793
20727
|
}
|
|
20794
|
-
context.frontmatter =
|
|
20728
|
+
context.frontmatter = frontmatter;
|
|
20795
20729
|
context.content = content.slice(match.index + match[0].length);
|
|
20796
20730
|
context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
|
|
20797
20731
|
});
|
|
@@ -20881,9 +20815,9 @@
|
|
|
20881
20815
|
md.set({
|
|
20882
20816
|
highlight: (str2, language) => {
|
|
20883
20817
|
enableFeature();
|
|
20884
|
-
const { hljs
|
|
20885
|
-
if (
|
|
20886
|
-
return
|
|
20818
|
+
const { hljs } = window;
|
|
20819
|
+
if (hljs) {
|
|
20820
|
+
return hljs.highlightAuto(str2, language ? [language] : void 0).value;
|
|
20887
20821
|
}
|
|
20888
20822
|
autoload().then(() => {
|
|
20889
20823
|
transformHooks.retransform.call();
|
|
@@ -20902,7 +20836,7 @@
|
|
|
20902
20836
|
};
|
|
20903
20837
|
}
|
|
20904
20838
|
});
|
|
20905
|
-
const
|
|
20839
|
+
const pluginHljs = plugin$2;
|
|
20906
20840
|
const rkatex = (md, options) => {
|
|
20907
20841
|
const backslash = "\\";
|
|
20908
20842
|
const dollar = "$";
|
|
@@ -20911,8 +20845,8 @@
|
|
|
20911
20845
|
if (delimiter.length !== 1) {
|
|
20912
20846
|
throw new Error("invalid delimiter");
|
|
20913
20847
|
}
|
|
20914
|
-
const
|
|
20915
|
-
const renderKatex = (source, displayMode) =>
|
|
20848
|
+
const katex = require$$0;
|
|
20849
|
+
const renderKatex = (source, displayMode) => katex.renderToString(
|
|
20916
20850
|
source,
|
|
20917
20851
|
{
|
|
20918
20852
|
displayMode,
|
|
@@ -21116,9 +21050,9 @@
|
|
|
21116
21050
|
return loading;
|
|
21117
21051
|
};
|
|
21118
21052
|
const renderKatex = (source, displayMode) => {
|
|
21119
|
-
const { katex
|
|
21120
|
-
if (
|
|
21121
|
-
return
|
|
21053
|
+
const { katex } = window;
|
|
21054
|
+
if (katex) {
|
|
21055
|
+
return katex.renderToString(source, {
|
|
21122
21056
|
displayMode,
|
|
21123
21057
|
throwOnError: false
|
|
21124
21058
|
});
|
|
@@ -21165,14 +21099,14 @@
|
|
|
21165
21099
|
};
|
|
21166
21100
|
}
|
|
21167
21101
|
});
|
|
21168
|
-
const
|
|
21102
|
+
const pluginKatex = plugin$1;
|
|
21169
21103
|
const name$1 = "npmUrl";
|
|
21170
|
-
const
|
|
21104
|
+
const pluginNpmUrl = definePlugin({
|
|
21171
21105
|
name: name$1,
|
|
21172
21106
|
transform(transformHooks) {
|
|
21173
21107
|
transformHooks.afterParse.tap((_, context) => {
|
|
21174
|
-
const { frontmatter
|
|
21175
|
-
const markmap =
|
|
21108
|
+
const { frontmatter } = context;
|
|
21109
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
21176
21110
|
if (markmap) {
|
|
21177
21111
|
["extraJs", "extraCss"].forEach((key) => {
|
|
21178
21112
|
const value = markmap[key];
|
|
@@ -21223,14 +21157,14 @@
|
|
|
21223
21157
|
return html2;
|
|
21224
21158
|
});
|
|
21225
21159
|
}
|
|
21226
|
-
const
|
|
21160
|
+
const pluginSourceLines = plugin;
|
|
21227
21161
|
const plugins = [
|
|
21228
|
-
|
|
21229
|
-
|
|
21230
|
-
|
|
21231
|
-
|
|
21232
|
-
|
|
21233
|
-
|
|
21162
|
+
pluginFrontmatter,
|
|
21163
|
+
pluginKatex,
|
|
21164
|
+
pluginHljs,
|
|
21165
|
+
pluginNpmUrl,
|
|
21166
|
+
pluginCheckbox,
|
|
21167
|
+
pluginSourceLines
|
|
21234
21168
|
];
|
|
21235
21169
|
const builtInPlugins = plugins;
|
|
21236
21170
|
function cleanNode(node) {
|
|
@@ -21322,50 +21256,9 @@
|
|
|
21322
21256
|
const keys = this.plugins.map((plugin2) => plugin2.name).filter((name2) => features[name2]);
|
|
21323
21257
|
return this.getAssets(keys);
|
|
21324
21258
|
}
|
|
21325
|
-
fillTemplate(root2, assets, extra) {
|
|
21326
|
-
extra = {
|
|
21327
|
-
...extra
|
|
21328
|
-
};
|
|
21329
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
|
|
21330
|
-
const { scripts, styles: styles2 } = assets;
|
|
21331
|
-
const cssList = [...styles2 ? persistCSS(styles2) : []];
|
|
21332
|
-
const context = {
|
|
21333
|
-
getMarkmap: () => window.markmap,
|
|
21334
|
-
getOptions: extra.getOptions,
|
|
21335
|
-
jsonOptions: extra.jsonOptions,
|
|
21336
|
-
root: root2
|
|
21337
|
-
};
|
|
21338
|
-
const jsList = [
|
|
21339
|
-
...persistJS(
|
|
21340
|
-
[
|
|
21341
|
-
...extra.baseJs,
|
|
21342
|
-
...scripts || [],
|
|
21343
|
-
{
|
|
21344
|
-
type: "iife",
|
|
21345
|
-
data: {
|
|
21346
|
-
fn: (getMarkmap, getOptions, root22, jsonOptions) => {
|
|
21347
|
-
const markmap = getMarkmap();
|
|
21348
|
-
window.mm = markmap.Markmap.create(
|
|
21349
|
-
"svg#mindmap",
|
|
21350
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
21351
|
-
root22
|
|
21352
|
-
);
|
|
21353
|
-
},
|
|
21354
|
-
getParams: ({ getMarkmap, getOptions, root: root22, jsonOptions }) => {
|
|
21355
|
-
return [getMarkmap, getOptions, root22, jsonOptions];
|
|
21356
|
-
}
|
|
21357
|
-
}
|
|
21358
|
-
}
|
|
21359
|
-
],
|
|
21360
|
-
context
|
|
21361
|
-
)
|
|
21362
|
-
];
|
|
21363
|
-
const html2 = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
21364
|
-
return html2;
|
|
21365
|
-
}
|
|
21366
21259
|
}
|
|
21367
21260
|
const transformerVersions = {
|
|
21368
|
-
"markmap-lib": "process.env.
|
|
21261
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
21369
21262
|
d3: "7.8.5"
|
|
21370
21263
|
};
|
|
21371
21264
|
exports.Transformer = Transformer;
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Hook, buildJSItem, buildCSSItem, loadJS, noop, wrapFunction, UrlBuilder
|
|
1
|
+
import { Hook, buildJSItem, buildCSSItem, loadJS, noop, wrapFunction, UrlBuilder } from "markmap-common";
|
|
2
2
|
import { buildTree } from "markmap-html-parser";
|
|
3
3
|
import { Remarkable } from "remarkable";
|
|
4
4
|
import yaml from "js-yaml";
|
|
5
5
|
import remarkableKatex from "remarkable-katex";
|
|
6
|
-
const template =
|
|
6
|
+
const template = process.env.TEMPLATE || "";
|
|
7
7
|
const baseJsPaths = [
|
|
8
8
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
9
|
-
`markmap-view@${"0.15.
|
|
9
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
10
10
|
];
|
|
11
11
|
function createTransformHooks(transformer) {
|
|
12
12
|
return {
|
|
@@ -21,9 +21,13 @@ function createTransformHooks(transformer) {
|
|
|
21
21
|
function definePlugin(plugin2) {
|
|
22
22
|
return plugin2;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
const
|
|
24
|
+
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';
|
|
25
|
+
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';
|
|
26
26
|
const name$5 = "checkbox";
|
|
27
|
+
const images = {
|
|
28
|
+
" ": svgUnmarked.trim(),
|
|
29
|
+
x: svgMarked.trim()
|
|
30
|
+
};
|
|
27
31
|
const plugin$3 = definePlugin({
|
|
28
32
|
name: name$5,
|
|
29
33
|
transform(transformHooks) {
|
|
@@ -38,11 +42,10 @@ const plugin$3 = definePlugin({
|
|
|
38
42
|
const prevType = state.tokens[i - 1].type;
|
|
39
43
|
const prevPrevType = state.tokens[i - 2].type;
|
|
40
44
|
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
45
|
+
token.content = token.content.replace(
|
|
46
|
+
/^\[(.)\] /,
|
|
47
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
48
|
+
);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
}
|
|
@@ -54,9 +57,9 @@ const plugin$3 = definePlugin({
|
|
|
54
57
|
return {};
|
|
55
58
|
}
|
|
56
59
|
});
|
|
57
|
-
const
|
|
60
|
+
const pluginCheckbox = plugin$3;
|
|
58
61
|
const name$4 = "frontmatter";
|
|
59
|
-
const
|
|
62
|
+
const pluginFrontmatter = definePlugin({
|
|
60
63
|
name: name$4,
|
|
61
64
|
transform(transformHooks) {
|
|
62
65
|
transformHooks.beforeParse.tap((md, context) => {
|
|
@@ -67,18 +70,18 @@ const frontmatter = definePlugin({
|
|
|
67
70
|
if (!match)
|
|
68
71
|
return;
|
|
69
72
|
const raw = content.slice(4, match.index);
|
|
70
|
-
let
|
|
73
|
+
let frontmatter;
|
|
71
74
|
try {
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
frontmatter = yaml.load(raw);
|
|
76
|
+
if (frontmatter == null ? void 0 : frontmatter.markmap) {
|
|
77
|
+
frontmatter.markmap = normalizeMarkmapJsonOptions(
|
|
78
|
+
frontmatter.markmap
|
|
76
79
|
);
|
|
77
80
|
}
|
|
78
81
|
} catch {
|
|
79
82
|
return;
|
|
80
83
|
}
|
|
81
|
-
context.frontmatter =
|
|
84
|
+
context.frontmatter = frontmatter;
|
|
82
85
|
context.content = content.slice(match.index + match[0].length);
|
|
83
86
|
context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
|
|
84
87
|
});
|
|
@@ -168,9 +171,9 @@ const plugin$2 = definePlugin({
|
|
|
168
171
|
md.set({
|
|
169
172
|
highlight: (str, language) => {
|
|
170
173
|
enableFeature();
|
|
171
|
-
const { hljs
|
|
172
|
-
if (
|
|
173
|
-
return
|
|
174
|
+
const { hljs } = window;
|
|
175
|
+
if (hljs) {
|
|
176
|
+
return hljs.highlightAuto(str, language ? [language] : void 0).value;
|
|
174
177
|
}
|
|
175
178
|
autoload().then(() => {
|
|
176
179
|
transformHooks.retransform.call();
|
|
@@ -189,7 +192,7 @@ const plugin$2 = definePlugin({
|
|
|
189
192
|
};
|
|
190
193
|
}
|
|
191
194
|
});
|
|
192
|
-
const
|
|
195
|
+
const pluginHljs = plugin$2;
|
|
193
196
|
const name$2 = "katex";
|
|
194
197
|
const preloadScripts = [
|
|
195
198
|
`katex@${"0.16.8"}/dist/katex.min.js`
|
|
@@ -273,9 +276,9 @@ const plugin$1 = definePlugin({
|
|
|
273
276
|
return loading;
|
|
274
277
|
};
|
|
275
278
|
const renderKatex = (source, displayMode) => {
|
|
276
|
-
const { katex
|
|
277
|
-
if (
|
|
278
|
-
return
|
|
279
|
+
const { katex } = window;
|
|
280
|
+
if (katex) {
|
|
281
|
+
return katex.renderToString(source, {
|
|
279
282
|
displayMode,
|
|
280
283
|
throwOnError: false
|
|
281
284
|
});
|
|
@@ -322,14 +325,14 @@ const plugin$1 = definePlugin({
|
|
|
322
325
|
};
|
|
323
326
|
}
|
|
324
327
|
});
|
|
325
|
-
const
|
|
328
|
+
const pluginKatex = plugin$1;
|
|
326
329
|
const name$1 = "npmUrl";
|
|
327
|
-
const
|
|
330
|
+
const pluginNpmUrl = definePlugin({
|
|
328
331
|
name: name$1,
|
|
329
332
|
transform(transformHooks) {
|
|
330
333
|
transformHooks.afterParse.tap((_, context) => {
|
|
331
|
-
const { frontmatter
|
|
332
|
-
const markmap =
|
|
334
|
+
const { frontmatter } = context;
|
|
335
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
333
336
|
if (markmap) {
|
|
334
337
|
["extraJs", "extraCss"].forEach((key) => {
|
|
335
338
|
const value = markmap[key];
|
|
@@ -380,14 +383,14 @@ function patchRule(rule, _key) {
|
|
|
380
383
|
return html;
|
|
381
384
|
});
|
|
382
385
|
}
|
|
383
|
-
const
|
|
386
|
+
const pluginSourceLines = plugin;
|
|
384
387
|
const plugins = [
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
388
|
+
pluginFrontmatter,
|
|
389
|
+
pluginKatex,
|
|
390
|
+
pluginHljs,
|
|
391
|
+
pluginNpmUrl,
|
|
392
|
+
pluginCheckbox,
|
|
393
|
+
pluginSourceLines
|
|
391
394
|
];
|
|
392
395
|
const builtInPlugins = plugins;
|
|
393
396
|
function cleanNode(node) {
|
|
@@ -479,50 +482,9 @@ class Transformer {
|
|
|
479
482
|
const keys = this.plugins.map((plugin2) => plugin2.name).filter((name2) => features[name2]);
|
|
480
483
|
return this.getAssets(keys);
|
|
481
484
|
}
|
|
482
|
-
fillTemplate(root, assets, extra) {
|
|
483
|
-
extra = {
|
|
484
|
-
...extra
|
|
485
|
-
};
|
|
486
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
|
|
487
|
-
const { scripts, styles: styles2 } = assets;
|
|
488
|
-
const cssList = [...styles2 ? persistCSS(styles2) : []];
|
|
489
|
-
const context = {
|
|
490
|
-
getMarkmap: () => window.markmap,
|
|
491
|
-
getOptions: extra.getOptions,
|
|
492
|
-
jsonOptions: extra.jsonOptions,
|
|
493
|
-
root
|
|
494
|
-
};
|
|
495
|
-
const jsList = [
|
|
496
|
-
...persistJS(
|
|
497
|
-
[
|
|
498
|
-
...extra.baseJs,
|
|
499
|
-
...scripts || [],
|
|
500
|
-
{
|
|
501
|
-
type: "iife",
|
|
502
|
-
data: {
|
|
503
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
504
|
-
const markmap = getMarkmap();
|
|
505
|
-
window.mm = markmap.Markmap.create(
|
|
506
|
-
"svg#mindmap",
|
|
507
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
508
|
-
root2
|
|
509
|
-
);
|
|
510
|
-
},
|
|
511
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
512
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
],
|
|
517
|
-
context
|
|
518
|
-
)
|
|
519
|
-
];
|
|
520
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
521
|
-
return html;
|
|
522
|
-
}
|
|
523
485
|
}
|
|
524
486
|
const transformerVersions = {
|
|
525
|
-
"markmap-lib": "process.env.
|
|
487
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
526
488
|
d3: "7.8.5"
|
|
527
489
|
};
|
|
528
490
|
export {
|
package/dist/index.js
CHANGED
|
@@ -7,10 +7,10 @@ const plugins = require("./plugins.js");
|
|
|
7
7
|
require("js-yaml");
|
|
8
8
|
require("highlight.js");
|
|
9
9
|
require("remarkable-katex");
|
|
10
|
-
const template =
|
|
10
|
+
const template = process.env.TEMPLATE || "";
|
|
11
11
|
const baseJsPaths = [
|
|
12
12
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
13
|
-
`markmap-view@${"0.15.
|
|
13
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
14
14
|
];
|
|
15
15
|
function patchJSItem(urlBuilder, item) {
|
|
16
16
|
if (item.type === "script" && item.data.src) {
|
|
@@ -126,50 +126,9 @@ class Transformer {
|
|
|
126
126
|
const keys = this.plugins.map((plugin) => plugin.name).filter((name) => features[name]);
|
|
127
127
|
return this.getAssets(keys);
|
|
128
128
|
}
|
|
129
|
-
fillTemplate(root, assets, extra) {
|
|
130
|
-
extra = {
|
|
131
|
-
...extra
|
|
132
|
-
};
|
|
133
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => markmapCommon.buildJSItem(path)));
|
|
134
|
-
const { scripts, styles } = assets;
|
|
135
|
-
const cssList = [...styles ? markmapCommon.persistCSS(styles) : []];
|
|
136
|
-
const context = {
|
|
137
|
-
getMarkmap: () => window.markmap,
|
|
138
|
-
getOptions: extra.getOptions,
|
|
139
|
-
jsonOptions: extra.jsonOptions,
|
|
140
|
-
root
|
|
141
|
-
};
|
|
142
|
-
const jsList = [
|
|
143
|
-
...markmapCommon.persistJS(
|
|
144
|
-
[
|
|
145
|
-
...extra.baseJs,
|
|
146
|
-
...scripts || [],
|
|
147
|
-
{
|
|
148
|
-
type: "iife",
|
|
149
|
-
data: {
|
|
150
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
151
|
-
const markmap = getMarkmap();
|
|
152
|
-
window.mm = markmap.Markmap.create(
|
|
153
|
-
"svg#mindmap",
|
|
154
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
155
|
-
root2
|
|
156
|
-
);
|
|
157
|
-
},
|
|
158
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
159
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
context
|
|
165
|
-
)
|
|
166
|
-
];
|
|
167
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
168
|
-
return html;
|
|
169
|
-
}
|
|
170
129
|
}
|
|
171
130
|
const transformerVersions = {
|
|
172
|
-
"markmap-lib": "process.env.
|
|
131
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
173
132
|
d3: "7.8.5"
|
|
174
133
|
};
|
|
175
134
|
exports.Transformer = Transformer;
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { UrlBuilder, wrapFunction
|
|
1
|
+
import { UrlBuilder, wrapFunction } from "markmap-common";
|
|
2
2
|
import { buildTree } from "markmap-html-parser";
|
|
3
3
|
import { Remarkable } from "remarkable";
|
|
4
4
|
import { plugins, createTransformHooks } from "./plugins.mjs";
|
|
5
5
|
import "js-yaml";
|
|
6
6
|
import "highlight.js";
|
|
7
7
|
import "remarkable-katex";
|
|
8
|
-
const template =
|
|
8
|
+
const template = process.env.TEMPLATE || "";
|
|
9
9
|
const baseJsPaths = [
|
|
10
10
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
11
|
-
`markmap-view@${"0.15.
|
|
11
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
12
12
|
];
|
|
13
13
|
function patchJSItem(urlBuilder, item) {
|
|
14
14
|
if (item.type === "script" && item.data.src) {
|
|
@@ -124,50 +124,9 @@ class Transformer {
|
|
|
124
124
|
const keys = this.plugins.map((plugin) => plugin.name).filter((name) => features[name]);
|
|
125
125
|
return this.getAssets(keys);
|
|
126
126
|
}
|
|
127
|
-
fillTemplate(root, assets, extra) {
|
|
128
|
-
extra = {
|
|
129
|
-
...extra
|
|
130
|
-
};
|
|
131
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
|
|
132
|
-
const { scripts, styles } = assets;
|
|
133
|
-
const cssList = [...styles ? persistCSS(styles) : []];
|
|
134
|
-
const context = {
|
|
135
|
-
getMarkmap: () => window.markmap,
|
|
136
|
-
getOptions: extra.getOptions,
|
|
137
|
-
jsonOptions: extra.jsonOptions,
|
|
138
|
-
root
|
|
139
|
-
};
|
|
140
|
-
const jsList = [
|
|
141
|
-
...persistJS(
|
|
142
|
-
[
|
|
143
|
-
...extra.baseJs,
|
|
144
|
-
...scripts || [],
|
|
145
|
-
{
|
|
146
|
-
type: "iife",
|
|
147
|
-
data: {
|
|
148
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
149
|
-
const markmap = getMarkmap();
|
|
150
|
-
window.mm = markmap.Markmap.create(
|
|
151
|
-
"svg#mindmap",
|
|
152
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
153
|
-
root2
|
|
154
|
-
);
|
|
155
|
-
},
|
|
156
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
157
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
],
|
|
162
|
-
context
|
|
163
|
-
)
|
|
164
|
-
];
|
|
165
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
166
|
-
return html;
|
|
167
|
-
}
|
|
168
127
|
}
|
|
169
128
|
const transformerVersions = {
|
|
170
|
-
"markmap-lib": "process.env.
|
|
129
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
171
130
|
d3: "7.8.5"
|
|
172
131
|
};
|
|
173
132
|
export {
|
package/dist/index.no-plugins.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const markmapCommon = require("markmap-common");
|
|
4
4
|
const markmapHtmlParser = require("markmap-html-parser");
|
|
5
5
|
const remarkable = require("remarkable");
|
|
6
|
-
const template =
|
|
6
|
+
const template = process.env.TEMPLATE || "";
|
|
7
7
|
const baseJsPaths = [
|
|
8
8
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
9
|
-
`markmap-view@${"0.15.
|
|
9
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
10
10
|
];
|
|
11
11
|
function createTransformHooks(transformer) {
|
|
12
12
|
return {
|
|
@@ -132,50 +132,9 @@ class Transformer {
|
|
|
132
132
|
const keys = this.plugins.map((plugin) => plugin.name).filter((name) => features[name]);
|
|
133
133
|
return this.getAssets(keys);
|
|
134
134
|
}
|
|
135
|
-
fillTemplate(root, assets, extra) {
|
|
136
|
-
extra = {
|
|
137
|
-
...extra
|
|
138
|
-
};
|
|
139
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => markmapCommon.buildJSItem(path)));
|
|
140
|
-
const { scripts, styles } = assets;
|
|
141
|
-
const cssList = [...styles ? markmapCommon.persistCSS(styles) : []];
|
|
142
|
-
const context = {
|
|
143
|
-
getMarkmap: () => window.markmap,
|
|
144
|
-
getOptions: extra.getOptions,
|
|
145
|
-
jsonOptions: extra.jsonOptions,
|
|
146
|
-
root
|
|
147
|
-
};
|
|
148
|
-
const jsList = [
|
|
149
|
-
...markmapCommon.persistJS(
|
|
150
|
-
[
|
|
151
|
-
...extra.baseJs,
|
|
152
|
-
...scripts || [],
|
|
153
|
-
{
|
|
154
|
-
type: "iife",
|
|
155
|
-
data: {
|
|
156
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
157
|
-
const markmap = getMarkmap();
|
|
158
|
-
window.mm = markmap.Markmap.create(
|
|
159
|
-
"svg#mindmap",
|
|
160
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
161
|
-
root2
|
|
162
|
-
);
|
|
163
|
-
},
|
|
164
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
165
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
],
|
|
170
|
-
context
|
|
171
|
-
)
|
|
172
|
-
];
|
|
173
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
174
|
-
return html;
|
|
175
|
-
}
|
|
176
135
|
}
|
|
177
136
|
const transformerVersions = {
|
|
178
|
-
"markmap-lib": "process.env.
|
|
137
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
179
138
|
d3: "7.8.5"
|
|
180
139
|
};
|
|
181
140
|
exports.Transformer = Transformer;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Hook, UrlBuilder, wrapFunction
|
|
1
|
+
import { Hook, UrlBuilder, wrapFunction } from "markmap-common";
|
|
2
2
|
import { buildTree } from "markmap-html-parser";
|
|
3
3
|
import { Remarkable } from "remarkable";
|
|
4
|
-
const template =
|
|
4
|
+
const template = process.env.TEMPLATE || "";
|
|
5
5
|
const baseJsPaths = [
|
|
6
6
|
`d3@${"7.8.5"}/dist/d3.min.js`,
|
|
7
|
-
`markmap-view@${"0.15.
|
|
7
|
+
`markmap-view@${"0.15.9-alpha.14"}/dist/browser/index.js`
|
|
8
8
|
];
|
|
9
9
|
function createTransformHooks(transformer) {
|
|
10
10
|
return {
|
|
@@ -130,50 +130,9 @@ class Transformer {
|
|
|
130
130
|
const keys = this.plugins.map((plugin) => plugin.name).filter((name) => features[name]);
|
|
131
131
|
return this.getAssets(keys);
|
|
132
132
|
}
|
|
133
|
-
fillTemplate(root, assets, extra) {
|
|
134
|
-
extra = {
|
|
135
|
-
...extra
|
|
136
|
-
};
|
|
137
|
-
extra.baseJs ?? (extra.baseJs = baseJsPaths.map((path) => this.urlBuilder.getFullUrl(path)).map((path) => buildJSItem(path)));
|
|
138
|
-
const { scripts, styles } = assets;
|
|
139
|
-
const cssList = [...styles ? persistCSS(styles) : []];
|
|
140
|
-
const context = {
|
|
141
|
-
getMarkmap: () => window.markmap,
|
|
142
|
-
getOptions: extra.getOptions,
|
|
143
|
-
jsonOptions: extra.jsonOptions,
|
|
144
|
-
root
|
|
145
|
-
};
|
|
146
|
-
const jsList = [
|
|
147
|
-
...persistJS(
|
|
148
|
-
[
|
|
149
|
-
...extra.baseJs,
|
|
150
|
-
...scripts || [],
|
|
151
|
-
{
|
|
152
|
-
type: "iife",
|
|
153
|
-
data: {
|
|
154
|
-
fn: (getMarkmap, getOptions, root2, jsonOptions) => {
|
|
155
|
-
const markmap = getMarkmap();
|
|
156
|
-
window.mm = markmap.Markmap.create(
|
|
157
|
-
"svg#mindmap",
|
|
158
|
-
(getOptions || markmap.deriveOptions)(jsonOptions),
|
|
159
|
-
root2
|
|
160
|
-
);
|
|
161
|
-
},
|
|
162
|
-
getParams: ({ getMarkmap, getOptions, root: root2, jsonOptions }) => {
|
|
163
|
-
return [getMarkmap, getOptions, root2, jsonOptions];
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
],
|
|
168
|
-
context
|
|
169
|
-
)
|
|
170
|
-
];
|
|
171
|
-
const html = template.replace("<!--CSS-->", () => cssList.join("")).replace("<!--JS-->", () => jsList.join(""));
|
|
172
|
-
return html;
|
|
173
|
-
}
|
|
174
133
|
}
|
|
175
134
|
const transformerVersions = {
|
|
176
|
-
"markmap-lib": "process.env.
|
|
135
|
+
"markmap-lib": "process.env.LIB_VERSION",
|
|
177
136
|
d3: "7.8.5"
|
|
178
137
|
};
|
|
179
138
|
export {
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -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[];
|
package/dist/plugins.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const markmapCommon = require("markmap-common");
|
|
4
4
|
const yaml = require("js-yaml");
|
|
5
|
-
const hljs
|
|
5
|
+
const hljs = require("highlight.js");
|
|
6
6
|
const remarkableKatex = require("remarkable-katex");
|
|
7
7
|
function createTransformHooks(transformer) {
|
|
8
8
|
return {
|
|
@@ -17,9 +17,13 @@ function createTransformHooks(transformer) {
|
|
|
17
17
|
function definePlugin(plugin2) {
|
|
18
18
|
return plugin2;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
const
|
|
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
22
|
const name$5 = "checkbox";
|
|
23
|
+
const images = {
|
|
24
|
+
" ": svgUnmarked.trim(),
|
|
25
|
+
x: svgMarked.trim()
|
|
26
|
+
};
|
|
23
27
|
const plugin$3 = definePlugin({
|
|
24
28
|
name: name$5,
|
|
25
29
|
transform(transformHooks) {
|
|
@@ -34,11 +38,10 @@ const plugin$3 = definePlugin({
|
|
|
34
38
|
const prevType = state.tokens[i - 1].type;
|
|
35
39
|
const prevPrevType = state.tokens[i - 2].type;
|
|
36
40
|
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
41
|
+
token.content = token.content.replace(
|
|
42
|
+
/^\[(.)\] /,
|
|
43
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
44
|
+
);
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
}
|
|
@@ -50,9 +53,9 @@ const plugin$3 = definePlugin({
|
|
|
50
53
|
return {};
|
|
51
54
|
}
|
|
52
55
|
});
|
|
53
|
-
const
|
|
56
|
+
const pluginCheckbox = plugin$3;
|
|
54
57
|
const name$4 = "frontmatter";
|
|
55
|
-
const
|
|
58
|
+
const pluginFrontmatter = definePlugin({
|
|
56
59
|
name: name$4,
|
|
57
60
|
transform(transformHooks) {
|
|
58
61
|
transformHooks.beforeParse.tap((md, context) => {
|
|
@@ -63,18 +66,18 @@ const frontmatter = definePlugin({
|
|
|
63
66
|
if (!match)
|
|
64
67
|
return;
|
|
65
68
|
const raw = content.slice(4, match.index);
|
|
66
|
-
let
|
|
69
|
+
let frontmatter;
|
|
67
70
|
try {
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
frontmatter = yaml.load(raw);
|
|
72
|
+
if (frontmatter == null ? void 0 : frontmatter.markmap) {
|
|
73
|
+
frontmatter.markmap = normalizeMarkmapJsonOptions(
|
|
74
|
+
frontmatter.markmap
|
|
72
75
|
);
|
|
73
76
|
}
|
|
74
77
|
} catch {
|
|
75
78
|
return;
|
|
76
79
|
}
|
|
77
|
-
context.frontmatter =
|
|
80
|
+
context.frontmatter = frontmatter;
|
|
78
81
|
context.content = content.slice(match.index + match[0].length);
|
|
79
82
|
context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
|
|
80
83
|
});
|
|
@@ -132,7 +135,7 @@ const plugin$2 = definePlugin({
|
|
|
132
135
|
md.set({
|
|
133
136
|
highlight: (str, language) => {
|
|
134
137
|
enableFeature();
|
|
135
|
-
return hljs
|
|
138
|
+
return hljs.highlightAuto(str, language ? [language] : void 0).value;
|
|
136
139
|
}
|
|
137
140
|
});
|
|
138
141
|
});
|
|
@@ -146,7 +149,7 @@ const plugin$2 = definePlugin({
|
|
|
146
149
|
};
|
|
147
150
|
}
|
|
148
151
|
});
|
|
149
|
-
const
|
|
152
|
+
const pluginHljs = plugin$2;
|
|
150
153
|
const name$2 = "katex";
|
|
151
154
|
const preloadScripts = [
|
|
152
155
|
`katex@${"0.16.8"}/dist/katex.min.js`
|
|
@@ -227,14 +230,14 @@ const plugin$1 = definePlugin({
|
|
|
227
230
|
};
|
|
228
231
|
}
|
|
229
232
|
});
|
|
230
|
-
const
|
|
233
|
+
const pluginKatex = plugin$1;
|
|
231
234
|
const name$1 = "npmUrl";
|
|
232
|
-
const
|
|
235
|
+
const pluginNpmUrl = definePlugin({
|
|
233
236
|
name: name$1,
|
|
234
237
|
transform(transformHooks) {
|
|
235
238
|
transformHooks.afterParse.tap((_, context) => {
|
|
236
|
-
const { frontmatter
|
|
237
|
-
const markmap =
|
|
239
|
+
const { frontmatter } = context;
|
|
240
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
238
241
|
if (markmap) {
|
|
239
242
|
["extraJs", "extraCss"].forEach((key) => {
|
|
240
243
|
const value = markmap[key];
|
|
@@ -285,15 +288,21 @@ function patchRule(rule, _key) {
|
|
|
285
288
|
return html;
|
|
286
289
|
});
|
|
287
290
|
}
|
|
288
|
-
const
|
|
291
|
+
const pluginSourceLines = plugin;
|
|
289
292
|
const plugins = [
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
293
|
+
pluginFrontmatter,
|
|
294
|
+
pluginKatex,
|
|
295
|
+
pluginHljs,
|
|
296
|
+
pluginNpmUrl,
|
|
297
|
+
pluginCheckbox,
|
|
298
|
+
pluginSourceLines
|
|
296
299
|
];
|
|
297
300
|
exports.createTransformHooks = createTransformHooks;
|
|
298
301
|
exports.definePlugin = definePlugin;
|
|
302
|
+
exports.pluginCheckbox = pluginCheckbox;
|
|
303
|
+
exports.pluginFrontmatter = pluginFrontmatter;
|
|
304
|
+
exports.pluginHljs = pluginHljs;
|
|
305
|
+
exports.pluginKatex = pluginKatex;
|
|
306
|
+
exports.pluginNpmUrl = pluginNpmUrl;
|
|
307
|
+
exports.pluginSourceLines = pluginSourceLines;
|
|
299
308
|
exports.plugins = plugins;
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Hook, buildJSItem, buildCSSItem, noop, wrapFunction } from "markmap-common";
|
|
2
2
|
import yaml from "js-yaml";
|
|
3
|
-
import hljs
|
|
3
|
+
import hljs from "highlight.js";
|
|
4
4
|
import remarkableKatex from "remarkable-katex";
|
|
5
5
|
function createTransformHooks(transformer) {
|
|
6
6
|
return {
|
|
@@ -15,9 +15,13 @@ function createTransformHooks(transformer) {
|
|
|
15
15
|
function definePlugin(plugin2) {
|
|
16
16
|
return plugin2;
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
const
|
|
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
20
|
const name$5 = "checkbox";
|
|
21
|
+
const images = {
|
|
22
|
+
" ": svgUnmarked.trim(),
|
|
23
|
+
x: svgMarked.trim()
|
|
24
|
+
};
|
|
21
25
|
const plugin$3 = definePlugin({
|
|
22
26
|
name: name$5,
|
|
23
27
|
transform(transformHooks) {
|
|
@@ -32,11 +36,10 @@ const plugin$3 = definePlugin({
|
|
|
32
36
|
const prevType = state.tokens[i - 1].type;
|
|
33
37
|
const prevPrevType = state.tokens[i - 2].type;
|
|
34
38
|
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
39
|
+
token.content = token.content.replace(
|
|
40
|
+
/^\[(.)\] /,
|
|
41
|
+
(m, g) => images[g] ? `${images[g]} ` : m
|
|
42
|
+
);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
}
|
|
@@ -48,9 +51,9 @@ const plugin$3 = definePlugin({
|
|
|
48
51
|
return {};
|
|
49
52
|
}
|
|
50
53
|
});
|
|
51
|
-
const
|
|
54
|
+
const pluginCheckbox = plugin$3;
|
|
52
55
|
const name$4 = "frontmatter";
|
|
53
|
-
const
|
|
56
|
+
const pluginFrontmatter = definePlugin({
|
|
54
57
|
name: name$4,
|
|
55
58
|
transform(transformHooks) {
|
|
56
59
|
transformHooks.beforeParse.tap((md, context) => {
|
|
@@ -61,18 +64,18 @@ const frontmatter = definePlugin({
|
|
|
61
64
|
if (!match)
|
|
62
65
|
return;
|
|
63
66
|
const raw = content.slice(4, match.index);
|
|
64
|
-
let
|
|
67
|
+
let frontmatter;
|
|
65
68
|
try {
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
frontmatter = yaml.load(raw);
|
|
70
|
+
if (frontmatter == null ? void 0 : frontmatter.markmap) {
|
|
71
|
+
frontmatter.markmap = normalizeMarkmapJsonOptions(
|
|
72
|
+
frontmatter.markmap
|
|
70
73
|
);
|
|
71
74
|
}
|
|
72
75
|
} catch {
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
75
|
-
context.frontmatter =
|
|
78
|
+
context.frontmatter = frontmatter;
|
|
76
79
|
context.content = content.slice(match.index + match[0].length);
|
|
77
80
|
context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
|
|
78
81
|
});
|
|
@@ -130,7 +133,7 @@ const plugin$2 = definePlugin({
|
|
|
130
133
|
md.set({
|
|
131
134
|
highlight: (str, language) => {
|
|
132
135
|
enableFeature();
|
|
133
|
-
return hljs
|
|
136
|
+
return hljs.highlightAuto(str, language ? [language] : void 0).value;
|
|
134
137
|
}
|
|
135
138
|
});
|
|
136
139
|
});
|
|
@@ -144,7 +147,7 @@ const plugin$2 = definePlugin({
|
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
});
|
|
147
|
-
const
|
|
150
|
+
const pluginHljs = plugin$2;
|
|
148
151
|
const name$2 = "katex";
|
|
149
152
|
const preloadScripts = [
|
|
150
153
|
`katex@${"0.16.8"}/dist/katex.min.js`
|
|
@@ -225,14 +228,14 @@ const plugin$1 = definePlugin({
|
|
|
225
228
|
};
|
|
226
229
|
}
|
|
227
230
|
});
|
|
228
|
-
const
|
|
231
|
+
const pluginKatex = plugin$1;
|
|
229
232
|
const name$1 = "npmUrl";
|
|
230
|
-
const
|
|
233
|
+
const pluginNpmUrl = definePlugin({
|
|
231
234
|
name: name$1,
|
|
232
235
|
transform(transformHooks) {
|
|
233
236
|
transformHooks.afterParse.tap((_, context) => {
|
|
234
|
-
const { frontmatter
|
|
235
|
-
const markmap =
|
|
237
|
+
const { frontmatter } = context;
|
|
238
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
236
239
|
if (markmap) {
|
|
237
240
|
["extraJs", "extraCss"].forEach((key) => {
|
|
238
241
|
const value = markmap[key];
|
|
@@ -283,17 +286,23 @@ function patchRule(rule, _key) {
|
|
|
283
286
|
return html;
|
|
284
287
|
});
|
|
285
288
|
}
|
|
286
|
-
const
|
|
289
|
+
const pluginSourceLines = plugin;
|
|
287
290
|
const plugins = [
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
pluginFrontmatter,
|
|
292
|
+
pluginKatex,
|
|
293
|
+
pluginHljs,
|
|
294
|
+
pluginNpmUrl,
|
|
295
|
+
pluginCheckbox,
|
|
296
|
+
pluginSourceLines
|
|
294
297
|
];
|
|
295
298
|
export {
|
|
296
299
|
createTransformHooks,
|
|
297
300
|
definePlugin,
|
|
301
|
+
pluginCheckbox,
|
|
302
|
+
pluginFrontmatter,
|
|
303
|
+
pluginHljs,
|
|
304
|
+
pluginKatex,
|
|
305
|
+
pluginNpmUrl,
|
|
306
|
+
pluginSourceLines,
|
|
298
307
|
plugins
|
|
299
308
|
};
|
package/dist/transform.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UrlBuilder } from 'markmap-common';
|
|
2
2
|
import { IHtmlParserOptions } from 'markmap-html-parser';
|
|
3
3
|
import { Remarkable } from 'remarkable';
|
|
4
|
-
import { IAssets, IFeatures, ITransformHooks, ITransformPlugin, ITransformResult, ITransformer
|
|
4
|
+
import { IAssets, IFeatures, ITransformHooks, ITransformPlugin, ITransformResult, ITransformer } from './types';
|
|
5
5
|
export declare const builtInPlugins: ITransformPlugin[];
|
|
6
6
|
export declare class Transformer implements ITransformer {
|
|
7
7
|
hooks: ITransformHooks;
|
|
@@ -19,9 +19,4 @@ export declare class Transformer implements ITransformer {
|
|
|
19
19
|
* Get used assets by features object returned by `transform`.
|
|
20
20
|
*/
|
|
21
21
|
getUsedAssets(features: IFeatures): IAssets;
|
|
22
|
-
fillTemplate(root: IPureNode | null, assets: IAssets, extra?: {
|
|
23
|
-
baseJs?: JSItem[];
|
|
24
|
-
jsonOptions?: IMarkmapJSONOptions;
|
|
25
|
-
getOptions?: (jsonOptions: IMarkmapJSONOptions) => Partial<IMarkmapOptions>;
|
|
26
|
-
}): string;
|
|
27
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.15.9-alpha.
|
|
3
|
+
"version": "0.15.9-alpha.14+fa8173f",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@highlightjs/cdn-assets": "^11.8.0",
|
|
61
61
|
"@types/remarkable": "^2.0.3",
|
|
62
|
-
"markmap-common": "0.15.9-alpha.
|
|
63
|
-
"markmap-view": "0.15.9-alpha.
|
|
62
|
+
"markmap-common": "0.15.9-alpha.14+fa8173f",
|
|
63
|
+
"markmap-view": "0.15.9-alpha.14+fa8173f",
|
|
64
64
|
"webfontloader": "^1.6.28"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"highlight.js": "^11.8.0",
|
|
69
69
|
"js-yaml": "^4.1.0",
|
|
70
70
|
"katex": "^0.16.8",
|
|
71
|
-
"markmap-html-parser": "0.15.9-alpha.
|
|
71
|
+
"markmap-html-parser": "0.15.9-alpha.14+fa8173f",
|
|
72
72
|
"prismjs": "^1.29.0",
|
|
73
73
|
"remarkable": "^2.0.1",
|
|
74
74
|
"remarkable-katex": "^1.2.1"
|
|
@@ -83,8 +83,12 @@
|
|
|
83
83
|
{
|
|
84
84
|
"rootMode": "upward"
|
|
85
85
|
}
|
|
86
|
-
]
|
|
86
|
+
],
|
|
87
|
+
"\\.svg$": "<rootDir>/scripts/file-transform.js"
|
|
88
|
+
},
|
|
89
|
+
"moduleNameMapper": {
|
|
90
|
+
"^(.*\\.svg)\\?raw$": "$1"
|
|
87
91
|
}
|
|
88
92
|
},
|
|
89
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "fa8173fbb9d5b30e669da11497f24123e5ead511"
|
|
90
94
|
}
|