markmap-lib 0.15.0-alpha.0 → 0.15.1
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.js +678 -510
- package/dist/browser/index.mjs +244 -10860
- package/dist/index.js +179 -176
- package/dist/index.mjs +179 -176
- package/package.json +20 -8
- package/types/constants.d.ts +2 -0
- package/types/index.d.ts +2 -2
- package/types/plugins/base.d.ts +3 -3
- package/types/plugins/frontmatter.d.ts +1 -1
- package/types/plugins/hljs.d.ts +2 -0
- package/types/plugins/index.d.ts +1 -1
- package/types/plugins/katex.browser.d.ts +2 -2
- package/types/plugins/katex.config.d.ts +2 -1
- package/types/plugins/katex.d.ts +2 -2
- package/types/plugins/npm-url.d.ts +1 -1
- package/types/plugins/prism.browser.d.ts +2 -2
- package/types/plugins/prism.config.d.ts +2 -1
- package/types/plugins/prism.d.ts +2 -2
- package/types/plugins/util.d.ts +4 -0
- package/types/transform.d.ts +10 -4
- package/types/types.d.ts +6 -2
- package/types/template.d.ts +0 -8
package/dist/browser/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
/*! markmap-lib v0.15.
|
|
1
|
+
/*! markmap-lib v0.15.1 | MIT License */
|
|
2
2
|
(function (global, factory) {
|
|
3
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('katex')) :
|
|
4
|
-
typeof define === 'function' && define.amd ? define(['exports', 'katex'], factory) :
|
|
5
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markmap = global.markmap || {}, global.window.katex));
|
|
6
|
-
})(this, (function (exports, require$$0) { 'use strict';
|
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('katex'), require('highlight.js')) :
|
|
4
|
+
typeof define === 'function' && define.amd ? define(['exports', 'katex', 'highlight.js'], factory) :
|
|
5
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markmap = global.markmap || {}, global.window.katex, global.window.hljs));
|
|
6
|
+
})(this, (function (exports, require$$0, hljs) { 'use strict';
|
|
7
|
+
|
|
8
|
+
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n" ;
|
|
9
|
+
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.15.0"}/dist/browser/index.js`];
|
|
7
10
|
|
|
8
11
|
function _extends$1() {
|
|
9
12
|
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -20,271 +23,6 @@ function _extends$1() {
|
|
|
20
23
|
return _extends$1.apply(this, arguments);
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
/*! markmap-common v0.15.0-alpha.0 | MIT License */
|
|
24
|
-
class Hook {
|
|
25
|
-
constructor() {
|
|
26
|
-
this.listeners = [];
|
|
27
|
-
}
|
|
28
|
-
tap(fn) {
|
|
29
|
-
this.listeners.push(fn);
|
|
30
|
-
return () => this.revoke(fn);
|
|
31
|
-
}
|
|
32
|
-
revoke(fn) {
|
|
33
|
-
const i = this.listeners.indexOf(fn);
|
|
34
|
-
if (i >= 0) this.listeners.splice(i, 1);
|
|
35
|
-
}
|
|
36
|
-
revokeAll() {
|
|
37
|
-
this.listeners.splice(0);
|
|
38
|
-
}
|
|
39
|
-
call(...args) {
|
|
40
|
-
for (const fn of this.listeners) {
|
|
41
|
-
fn(...args);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function _extends() {
|
|
46
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
47
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
48
|
-
var source = arguments[i];
|
|
49
|
-
for (var key in source) {
|
|
50
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
51
|
-
target[key] = source[key];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return target;
|
|
56
|
-
};
|
|
57
|
-
return _extends.apply(this, arguments);
|
|
58
|
-
}
|
|
59
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
60
|
-
if (source == null) return {};
|
|
61
|
-
var target = {};
|
|
62
|
-
var sourceKeys = Object.keys(source);
|
|
63
|
-
var key, i;
|
|
64
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
65
|
-
key = sourceKeys[i];
|
|
66
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
67
|
-
target[key] = source[key];
|
|
68
|
-
}
|
|
69
|
-
return target;
|
|
70
|
-
}
|
|
71
|
-
const _excluded = ["textContent"];
|
|
72
|
-
function escapeHtml$1(html) {
|
|
73
|
-
return html.replace(/[&<"]/g, m => ({
|
|
74
|
-
'&': '&',
|
|
75
|
-
'<': '<',
|
|
76
|
-
'"': '"'
|
|
77
|
-
})[m]);
|
|
78
|
-
}
|
|
79
|
-
function escapeScript(content) {
|
|
80
|
-
return content.replace(/<(\/script>)/g, '\\x3c$2');
|
|
81
|
-
}
|
|
82
|
-
function htmlOpen(tagName, attrs) {
|
|
83
|
-
const attrStr = attrs ? Object.entries(attrs).map(([key, value]) => {
|
|
84
|
-
if (value == null || value === false) return;
|
|
85
|
-
key = ` ${escapeHtml$1(key)}`;
|
|
86
|
-
if (value === true) return key;
|
|
87
|
-
return `${key}="${escapeHtml$1(value)}"`;
|
|
88
|
-
}).filter(Boolean).join('') : '';
|
|
89
|
-
return `<${tagName}${attrStr}>`;
|
|
90
|
-
}
|
|
91
|
-
function htmlClose(tagName) {
|
|
92
|
-
return `</${tagName}>`;
|
|
93
|
-
}
|
|
94
|
-
function wrapHtml(tagName, content, attrs) {
|
|
95
|
-
if (content == null) return htmlOpen(tagName, attrs);
|
|
96
|
-
return htmlOpen(tagName, attrs) + (content || '') + htmlClose(tagName);
|
|
97
|
-
}
|
|
98
|
-
function buildCode(fn, args) {
|
|
99
|
-
const params = args.map(arg => {
|
|
100
|
-
if (typeof arg === 'function') return arg.toString();
|
|
101
|
-
return JSON.stringify(arg != null ? arg : null);
|
|
102
|
-
}).join(',');
|
|
103
|
-
return `(${fn.toString()})(${params})`;
|
|
104
|
-
}
|
|
105
|
-
function persistJS(items, context) {
|
|
106
|
-
return items.map(item => {
|
|
107
|
-
if (item.type === 'script') {
|
|
108
|
-
const _item$data = item.data,
|
|
109
|
-
{
|
|
110
|
-
textContent
|
|
111
|
-
} = _item$data,
|
|
112
|
-
rest = _objectWithoutPropertiesLoose(_item$data, _excluded);
|
|
113
|
-
return wrapHtml('script', textContent || '', rest);
|
|
114
|
-
}
|
|
115
|
-
if (item.type === 'iife') {
|
|
116
|
-
const {
|
|
117
|
-
fn,
|
|
118
|
-
getParams
|
|
119
|
-
} = item.data;
|
|
120
|
-
return wrapHtml('script', escapeScript(buildCode(fn, (getParams == null ? void 0 : getParams(context)) || [])));
|
|
121
|
-
}
|
|
122
|
-
return '';
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function persistCSS(items) {
|
|
126
|
-
return items.map(item => {
|
|
127
|
-
if (item.type === 'stylesheet') {
|
|
128
|
-
return wrapHtml('link', null, _extends({
|
|
129
|
-
rel: 'stylesheet'
|
|
130
|
-
}, item.data));
|
|
131
|
-
}
|
|
132
|
-
/* else if (item.type === 'style') */
|
|
133
|
-
return wrapHtml('style', item.data);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
Math.random().toString(36).slice(2, 8);
|
|
137
|
-
function noop() {
|
|
138
|
-
// noop
|
|
139
|
-
}
|
|
140
|
-
function wrapFunction(fn, wrapper) {
|
|
141
|
-
return (...args) => wrapper(fn, ...args);
|
|
142
|
-
}
|
|
143
|
-
function memoize(fn) {
|
|
144
|
-
const cache = {};
|
|
145
|
-
return function memoized(...args) {
|
|
146
|
-
const key = `${args[0]}`;
|
|
147
|
-
let data = cache[key];
|
|
148
|
-
if (!data) {
|
|
149
|
-
data = {
|
|
150
|
-
value: fn(...args)
|
|
151
|
-
};
|
|
152
|
-
cache[key] = data;
|
|
153
|
-
}
|
|
154
|
-
return data.value;
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
const providers = {
|
|
158
|
-
jsdelivr: path => `https://cdn.jsdelivr.net/npm/${path}`,
|
|
159
|
-
unpkg: path => `https://unpkg.com/${path}`
|
|
160
|
-
};
|
|
161
|
-
function cdnUrl(provider, path) {
|
|
162
|
-
const factory = providers[provider];
|
|
163
|
-
if (!factory) {
|
|
164
|
-
throw new Error(`Provider ${provider} not found`);
|
|
165
|
-
}
|
|
166
|
-
return factory(path);
|
|
167
|
-
}
|
|
168
|
-
function createElement(tagName, props, attrs) {
|
|
169
|
-
const el = document.createElement(tagName);
|
|
170
|
-
if (props) {
|
|
171
|
-
Object.entries(props).forEach(([key, value]) => {
|
|
172
|
-
el[key] = value;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
if (attrs) {
|
|
176
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
177
|
-
el.setAttribute(key, value);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
return el;
|
|
181
|
-
}
|
|
182
|
-
const memoizedPreloadJS = memoize(url => {
|
|
183
|
-
document.head.append(createElement('link', {
|
|
184
|
-
rel: 'preload',
|
|
185
|
-
as: 'script',
|
|
186
|
-
href: url
|
|
187
|
-
}));
|
|
188
|
-
});
|
|
189
|
-
async function loadJSItem(item, context) {
|
|
190
|
-
if (!item.loaded) {
|
|
191
|
-
if (item.type === 'script') {
|
|
192
|
-
item.loaded = new Promise((resolve, reject) => {
|
|
193
|
-
var _item$data;
|
|
194
|
-
document.head.append(createElement('script', _extends({}, item.data, {
|
|
195
|
-
onload: resolve,
|
|
196
|
-
onerror: reject
|
|
197
|
-
})));
|
|
198
|
-
// Run inline script synchronously
|
|
199
|
-
if (!((_item$data = item.data) != null && _item$data.src)) resolve(undefined);
|
|
200
|
-
}).then(() => {
|
|
201
|
-
item.loaded = true;
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
if (item.type === 'iife') {
|
|
205
|
-
const {
|
|
206
|
-
fn,
|
|
207
|
-
getParams
|
|
208
|
-
} = item.data;
|
|
209
|
-
fn(...((getParams == null ? void 0 : getParams(context)) || []));
|
|
210
|
-
item.loaded = true;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
await item.loaded;
|
|
214
|
-
}
|
|
215
|
-
async function loadJS(items, context) {
|
|
216
|
-
const needPreload = items.filter(item => {
|
|
217
|
-
var _item$data2;
|
|
218
|
-
return item.type === 'script' && ((_item$data2 = item.data) == null ? void 0 : _item$data2.src);
|
|
219
|
-
});
|
|
220
|
-
if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src));
|
|
221
|
-
context = _extends({
|
|
222
|
-
getMarkmap: () => window.markmap
|
|
223
|
-
}, context);
|
|
224
|
-
for (const item of items) {
|
|
225
|
-
await loadJSItem(item, context);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
let provider = 'jsdelivr';
|
|
229
|
-
function getFullUrl(path) {
|
|
230
|
-
if (path.includes('://')) return path;
|
|
231
|
-
return cdnUrl(provider, path);
|
|
232
|
-
}
|
|
233
|
-
function buildJSItem(path) {
|
|
234
|
-
return {
|
|
235
|
-
type: 'script',
|
|
236
|
-
data: {
|
|
237
|
-
src: getFullUrl(path)
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
function buildCSSItem(path) {
|
|
242
|
-
return {
|
|
243
|
-
type: 'stylesheet',
|
|
244
|
-
data: {
|
|
245
|
-
href: getFullUrl(path)
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n";
|
|
251
|
-
const baseJsPaths = [`d3@${"6.2.0"}`, `markmap-view@${"0.15.0-alpha.0"}`];
|
|
252
|
-
function fillTemplate(root, assets, extra) {
|
|
253
|
-
var _extra, _extra$baseJs;
|
|
254
|
-
extra = _extends$1({}, extra);
|
|
255
|
-
(_extra$baseJs = (_extra = extra).baseJs) != null ? _extra$baseJs : _extra.baseJs = baseJsPaths.map(buildJSItem);
|
|
256
|
-
const {
|
|
257
|
-
scripts,
|
|
258
|
-
styles
|
|
259
|
-
} = assets;
|
|
260
|
-
const cssList = [...(styles ? persistCSS(styles) : [])];
|
|
261
|
-
const context = {
|
|
262
|
-
getMarkmap: () => window.markmap,
|
|
263
|
-
getOptions: extra.getOptions,
|
|
264
|
-
jsonOptions: extra.jsonOptions,
|
|
265
|
-
root
|
|
266
|
-
};
|
|
267
|
-
const jsList = [...persistJS([...extra.baseJs, ...(scripts || []), {
|
|
268
|
-
type: 'iife',
|
|
269
|
-
data: {
|
|
270
|
-
fn: (getMarkmap, getOptions, root, jsonOptions) => {
|
|
271
|
-
const markmap = getMarkmap();
|
|
272
|
-
window.mm = markmap.Markmap.create('svg#mindmap', (getOptions || markmap.deriveOptions)(jsonOptions), root);
|
|
273
|
-
},
|
|
274
|
-
getParams: ({
|
|
275
|
-
getMarkmap,
|
|
276
|
-
getOptions,
|
|
277
|
-
root,
|
|
278
|
-
jsonOptions
|
|
279
|
-
}) => {
|
|
280
|
-
return [getMarkmap, getOptions, root, jsonOptions];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}], context)];
|
|
284
|
-
const html = template.replace('<!--CSS-->', () => cssList.join('')).replace('<!--JS-->', () => jsList.join(''));
|
|
285
|
-
return html;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
26
|
// List of valid entities
|
|
289
27
|
//
|
|
290
28
|
// Generate with ./support/entities.js script
|
|
@@ -2541,7 +2279,7 @@ var HTML_REPLACEMENTS = {
|
|
|
2541
2279
|
function replaceUnsafeChar(ch) {
|
|
2542
2280
|
return HTML_REPLACEMENTS[ch];
|
|
2543
2281
|
}
|
|
2544
|
-
function escapeHtml(str) {
|
|
2282
|
+
function escapeHtml$1(str) {
|
|
2545
2283
|
if (HTML_ESCAPE_TEST_RE.test(str)) {
|
|
2546
2284
|
return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
|
|
2547
2285
|
}
|
|
@@ -2572,9 +2310,9 @@ rules.blockquote_close = function (tokens, idx /*, options, env */) {
|
|
|
2572
2310
|
|
|
2573
2311
|
rules.code = function (tokens, idx /*, options, env */) {
|
|
2574
2312
|
if (tokens[idx].block) {
|
|
2575
|
-
return '<pre><code>' + escapeHtml(tokens[idx].content) + '</code></pre>' + getBreak(tokens, idx);
|
|
2313
|
+
return '<pre><code>' + escapeHtml$1(tokens[idx].content) + '</code></pre>' + getBreak(tokens, idx);
|
|
2576
2314
|
}
|
|
2577
|
-
return '<code>' + escapeHtml(tokens[idx].content) + '</code>';
|
|
2315
|
+
return '<code>' + escapeHtml$1(tokens[idx].content) + '</code>';
|
|
2578
2316
|
};
|
|
2579
2317
|
|
|
2580
2318
|
/**
|
|
@@ -2602,13 +2340,13 @@ rules.fence = function (tokens, idx, options, env, instance) {
|
|
|
2602
2340
|
if (has$1(instance.rules.fence_custom, fences[0])) {
|
|
2603
2341
|
return instance.rules.fence_custom[fences[0]](tokens, idx, options, env, instance);
|
|
2604
2342
|
}
|
|
2605
|
-
langName = escapeHtml(replaceEntities(unescapeMd(fenceName)));
|
|
2343
|
+
langName = escapeHtml$1(replaceEntities(unescapeMd(fenceName)));
|
|
2606
2344
|
langClass = ' class="' + langPrefix + langName + '"';
|
|
2607
2345
|
}
|
|
2608
2346
|
if (options.highlight) {
|
|
2609
|
-
highlighted = options.highlight.apply(options.highlight, [token.content].concat(fences)) || escapeHtml(token.content);
|
|
2347
|
+
highlighted = options.highlight.apply(options.highlight, [token.content].concat(fences)) || escapeHtml$1(token.content);
|
|
2610
2348
|
} else {
|
|
2611
|
-
highlighted = escapeHtml(token.content);
|
|
2349
|
+
highlighted = escapeHtml$1(token.content);
|
|
2612
2350
|
}
|
|
2613
2351
|
return '<pre><code' + langClass + '>' + highlighted + '</code></pre>' + getBreak(tokens, idx);
|
|
2614
2352
|
};
|
|
@@ -2688,9 +2426,9 @@ rules.paragraph_close = function (tokens, idx /*, options, env */) {
|
|
|
2688
2426
|
*/
|
|
2689
2427
|
|
|
2690
2428
|
rules.link_open = function (tokens, idx, options /* env */) {
|
|
2691
|
-
var title = tokens[idx].title ? ' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"' : '';
|
|
2429
|
+
var title = tokens[idx].title ? ' title="' + escapeHtml$1(replaceEntities(tokens[idx].title)) + '"' : '';
|
|
2692
2430
|
var target = options.linkTarget ? ' target="' + options.linkTarget + '"' : '';
|
|
2693
|
-
return '<a href="' + escapeHtml(tokens[idx].href) + '"' + title + target + '>';
|
|
2431
|
+
return '<a href="' + escapeHtml$1(tokens[idx].href) + '"' + title + target + '>';
|
|
2694
2432
|
};
|
|
2695
2433
|
rules.link_close = function /* tokens, idx, options, env */
|
|
2696
2434
|
() {
|
|
@@ -2702,9 +2440,9 @@ rules.link_close = function /* tokens, idx, options, env */
|
|
|
2702
2440
|
*/
|
|
2703
2441
|
|
|
2704
2442
|
rules.image = function (tokens, idx, options /*, env */) {
|
|
2705
|
-
var src = ' src="' + escapeHtml(tokens[idx].src) + '"';
|
|
2706
|
-
var title = tokens[idx].title ? ' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"' : '';
|
|
2707
|
-
var alt = ' alt="' + (tokens[idx].alt ? escapeHtml(replaceEntities(unescapeMd(tokens[idx].alt))) : '') + '"';
|
|
2443
|
+
var src = ' src="' + escapeHtml$1(tokens[idx].src) + '"';
|
|
2444
|
+
var title = tokens[idx].title ? ' title="' + escapeHtml$1(replaceEntities(tokens[idx].title)) + '"' : '';
|
|
2445
|
+
var alt = ' alt="' + (tokens[idx].alt ? escapeHtml$1(replaceEntities(unescapeMd(tokens[idx].alt))) : '') + '"';
|
|
2708
2446
|
var suffix = options.xhtmlOut ? ' /' : '';
|
|
2709
2447
|
return '<img' + src + alt + title + suffix + '>';
|
|
2710
2448
|
};
|
|
@@ -2832,10 +2570,10 @@ rules.mark_close = function /* tokens, idx, options, env */
|
|
|
2832
2570
|
*/
|
|
2833
2571
|
|
|
2834
2572
|
rules.sub = function (tokens, idx /*, options, env */) {
|
|
2835
|
-
return '<sub>' + escapeHtml(tokens[idx].content) + '</sub>';
|
|
2573
|
+
return '<sub>' + escapeHtml$1(tokens[idx].content) + '</sub>';
|
|
2836
2574
|
};
|
|
2837
2575
|
rules.sup = function (tokens, idx /*, options, env */) {
|
|
2838
|
-
return '<sup>' + escapeHtml(tokens[idx].content) + '</sup>';
|
|
2576
|
+
return '<sup>' + escapeHtml$1(tokens[idx].content) + '</sup>';
|
|
2839
2577
|
};
|
|
2840
2578
|
|
|
2841
2579
|
/**
|
|
@@ -2854,7 +2592,7 @@ rules.softbreak = function (tokens, idx, options /*, env */) {
|
|
|
2854
2592
|
*/
|
|
2855
2593
|
|
|
2856
2594
|
rules.text = function (tokens, idx /*, options, env */) {
|
|
2857
|
-
return escapeHtml(tokens[idx].content);
|
|
2595
|
+
return escapeHtml$1(tokens[idx].content);
|
|
2858
2596
|
};
|
|
2859
2597
|
|
|
2860
2598
|
/**
|
|
@@ -2873,7 +2611,7 @@ rules.htmltag = function (tokens, idx /*, options, env */) {
|
|
|
2873
2611
|
*/
|
|
2874
2612
|
|
|
2875
2613
|
rules.abbr_open = function (tokens, idx /*, options, env */) {
|
|
2876
|
-
return '<abbr title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '">';
|
|
2614
|
+
return '<abbr title="' + escapeHtml$1(replaceEntities(tokens[idx].title)) + '">';
|
|
2877
2615
|
};
|
|
2878
2616
|
rules.abbr_close = function /* tokens, idx, options, env */
|
|
2879
2617
|
() {
|
|
@@ -7213,7 +6951,7 @@ var commonmarkConfig = {
|
|
|
7213
6951
|
* Preset configs
|
|
7214
6952
|
*/
|
|
7215
6953
|
|
|
7216
|
-
var config = {
|
|
6954
|
+
var config$2 = {
|
|
7217
6955
|
'default': defaultConfig,
|
|
7218
6956
|
'full': fullConfig,
|
|
7219
6957
|
'commonmark': commonmarkConfig
|
|
@@ -7261,7 +6999,7 @@ function Remarkable(preset, options) {
|
|
|
7261
6999
|
this.renderer = new Renderer();
|
|
7262
7000
|
this.ruler = new Ruler();
|
|
7263
7001
|
this.options = {};
|
|
7264
|
-
this.configure(config[preset]);
|
|
7002
|
+
this.configure(config$2[preset]);
|
|
7265
7003
|
this.set(options || {});
|
|
7266
7004
|
}
|
|
7267
7005
|
|
|
@@ -7381,53 +7119,456 @@ Remarkable.prototype.renderInline = function (str, env) {
|
|
|
7381
7119
|
return this.renderer.render(this.parseInline(str, env), this.options, env);
|
|
7382
7120
|
};
|
|
7383
7121
|
|
|
7384
|
-
|
|
7385
|
-
|
|
7122
|
+
/*! markmap-common v0.15.0 | MIT License */
|
|
7123
|
+
function _extends() {
|
|
7124
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
7125
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
7126
|
+
var source = arguments[i];
|
|
7127
|
+
for (var key in source) {
|
|
7128
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7129
|
+
target[key] = source[key];
|
|
7130
|
+
}
|
|
7131
|
+
}
|
|
7132
|
+
}
|
|
7133
|
+
return target;
|
|
7134
|
+
};
|
|
7135
|
+
return _extends.apply(this, arguments);
|
|
7386
7136
|
}
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7137
|
+
const testPath = "npm2url/dist/index.cjs";
|
|
7138
|
+
const defaultProviders = {
|
|
7139
|
+
jsdelivr: path => `https://cdn.jsdelivr.net/npm/${path}`,
|
|
7140
|
+
unpkg: path => `https://unpkg.com/${path}`
|
|
7141
|
+
};
|
|
7142
|
+
class UrlBuilder {
|
|
7143
|
+
constructor() {
|
|
7144
|
+
this.providers = _extends({}, defaultProviders);
|
|
7145
|
+
this.provider = "jsdelivr";
|
|
7146
|
+
}
|
|
7147
|
+
getFastestProvider(path = testPath) {
|
|
7148
|
+
return Promise.any(Object.entries(this.providers).map(async ([name, factory]) => {
|
|
7149
|
+
const res = await fetch(factory(path));
|
|
7150
|
+
if (!res.ok) {
|
|
7151
|
+
throw res;
|
|
7152
|
+
}
|
|
7153
|
+
await res.text();
|
|
7154
|
+
return name;
|
|
7155
|
+
}));
|
|
7156
|
+
}
|
|
7157
|
+
async findFastestProvider() {
|
|
7158
|
+
this.provider = await this.getFastestProvider();
|
|
7159
|
+
return this.provider;
|
|
7160
|
+
}
|
|
7161
|
+
setProvider(name, factory) {
|
|
7162
|
+
if (factory) {
|
|
7163
|
+
this.providers[name] = factory;
|
|
7164
|
+
} else {
|
|
7165
|
+
delete this.providers[name];
|
|
7166
|
+
}
|
|
7399
7167
|
}
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
* Render the contents as KaTeX
|
|
7404
|
-
*/
|
|
7405
|
-
const renderKatex = (source, displayMode) => katex.renderToString(source, {
|
|
7406
|
-
displayMode: displayMode,
|
|
7407
|
-
throwOnError: false
|
|
7408
|
-
});
|
|
7409
|
-
|
|
7410
|
-
/**
|
|
7411
|
-
* Parse '$$' as a block. Based off of similar method in remarkable.
|
|
7412
|
-
*/
|
|
7413
|
-
const parseBlockKatex = (state, startLine, endLine) => {
|
|
7414
|
-
let haveEndMarker = false;
|
|
7415
|
-
let pos = state.bMarks[startLine] + state.tShift[startLine];
|
|
7416
|
-
let max = state.eMarks[startLine];
|
|
7417
|
-
if (pos + 1 > max) {
|
|
7418
|
-
return false;
|
|
7168
|
+
getFullUrl(path, provider = this.provider) {
|
|
7169
|
+
if (path.includes("://")) {
|
|
7170
|
+
return path;
|
|
7419
7171
|
}
|
|
7420
|
-
const
|
|
7421
|
-
if (
|
|
7422
|
-
|
|
7172
|
+
const factory = this.providers[provider];
|
|
7173
|
+
if (!factory) {
|
|
7174
|
+
throw new Error(`Provider ${provider} not found`);
|
|
7423
7175
|
}
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7176
|
+
return factory(path);
|
|
7177
|
+
}
|
|
7178
|
+
}
|
|
7179
|
+
new UrlBuilder();
|
|
7180
|
+
class Hook {
|
|
7181
|
+
constructor() {
|
|
7182
|
+
this.listeners = [];
|
|
7183
|
+
}
|
|
7184
|
+
tap(fn) {
|
|
7185
|
+
this.listeners.push(fn);
|
|
7186
|
+
return () => this.revoke(fn);
|
|
7187
|
+
}
|
|
7188
|
+
revoke(fn) {
|
|
7189
|
+
const i = this.listeners.indexOf(fn);
|
|
7190
|
+
if (i >= 0) this.listeners.splice(i, 1);
|
|
7191
|
+
}
|
|
7192
|
+
revokeAll() {
|
|
7193
|
+
this.listeners.splice(0);
|
|
7194
|
+
}
|
|
7195
|
+
call(...args) {
|
|
7196
|
+
for (const fn of this.listeners) {
|
|
7197
|
+
fn(...args);
|
|
7198
|
+
}
|
|
7199
|
+
}
|
|
7200
|
+
}
|
|
7201
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
7202
|
+
if (source == null) return {};
|
|
7203
|
+
var target = {};
|
|
7204
|
+
var sourceKeys = Object.keys(source);
|
|
7205
|
+
var key, i;
|
|
7206
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
7207
|
+
key = sourceKeys[i];
|
|
7208
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
7209
|
+
target[key] = source[key];
|
|
7210
|
+
}
|
|
7211
|
+
return target;
|
|
7212
|
+
}
|
|
7213
|
+
const _excluded = ["textContent"];
|
|
7214
|
+
const escapeChars = {
|
|
7215
|
+
'&': '&',
|
|
7216
|
+
'<': '<',
|
|
7217
|
+
'"': '"'
|
|
7218
|
+
};
|
|
7219
|
+
function escapeHtml(html) {
|
|
7220
|
+
return html.replace(/[&<"]/g, m => escapeChars[m]);
|
|
7221
|
+
}
|
|
7222
|
+
function escapeScript(content) {
|
|
7223
|
+
return content.replace(/<(\/script>)/g, '\\x3c$2');
|
|
7224
|
+
}
|
|
7225
|
+
function htmlOpen(tagName, attrs) {
|
|
7226
|
+
const attrStr = attrs ? Object.entries(attrs).map(([key, value]) => {
|
|
7227
|
+
if (value == null || value === false) return;
|
|
7228
|
+
key = ` ${escapeHtml(key)}`;
|
|
7229
|
+
if (value === true) return key;
|
|
7230
|
+
return `${key}="${escapeHtml(value)}"`;
|
|
7231
|
+
}).filter(Boolean).join('') : '';
|
|
7232
|
+
return `<${tagName}${attrStr}>`;
|
|
7233
|
+
}
|
|
7234
|
+
function htmlClose(tagName) {
|
|
7235
|
+
return `</${tagName}>`;
|
|
7236
|
+
}
|
|
7237
|
+
function wrapHtml(tagName, content, attrs) {
|
|
7238
|
+
if (content == null) return htmlOpen(tagName, attrs);
|
|
7239
|
+
return htmlOpen(tagName, attrs) + (content || '') + htmlClose(tagName);
|
|
7240
|
+
}
|
|
7241
|
+
function buildCode(fn, args) {
|
|
7242
|
+
const params = args.map(arg => {
|
|
7243
|
+
if (typeof arg === 'function') return arg.toString();
|
|
7244
|
+
return JSON.stringify(arg != null ? arg : null);
|
|
7245
|
+
}).join(',');
|
|
7246
|
+
return `(${fn.toString()})(${params})`;
|
|
7247
|
+
}
|
|
7248
|
+
function persistJS(items, context) {
|
|
7249
|
+
return items.map(item => {
|
|
7250
|
+
if (item.type === 'script') {
|
|
7251
|
+
const _item$data = item.data,
|
|
7252
|
+
{
|
|
7253
|
+
textContent
|
|
7254
|
+
} = _item$data,
|
|
7255
|
+
rest = _objectWithoutPropertiesLoose(_item$data, _excluded);
|
|
7256
|
+
return wrapHtml('script', textContent || '', rest);
|
|
7257
|
+
}
|
|
7258
|
+
if (item.type === 'iife') {
|
|
7259
|
+
const {
|
|
7260
|
+
fn,
|
|
7261
|
+
getParams
|
|
7262
|
+
} = item.data;
|
|
7263
|
+
return wrapHtml('script', escapeScript(buildCode(fn, (getParams == null ? void 0 : getParams(context)) || [])));
|
|
7264
|
+
}
|
|
7265
|
+
return '';
|
|
7266
|
+
});
|
|
7267
|
+
}
|
|
7268
|
+
function persistCSS(items) {
|
|
7269
|
+
return items.map(item => {
|
|
7270
|
+
if (item.type === 'stylesheet') {
|
|
7271
|
+
return wrapHtml('link', null, _extends({
|
|
7272
|
+
rel: 'stylesheet'
|
|
7273
|
+
}, item.data));
|
|
7274
|
+
}
|
|
7275
|
+
/* else if (item.type === 'style') */
|
|
7276
|
+
return wrapHtml('style', item.data);
|
|
7277
|
+
});
|
|
7278
|
+
}
|
|
7279
|
+
Math.random().toString(36).slice(2, 8);
|
|
7280
|
+
function noop() {
|
|
7281
|
+
// noop
|
|
7282
|
+
}
|
|
7283
|
+
function wrapFunction(fn, wrapper) {
|
|
7284
|
+
return (...args) => wrapper(fn, ...args);
|
|
7285
|
+
}
|
|
7286
|
+
function memoize(fn) {
|
|
7287
|
+
const cache = {};
|
|
7288
|
+
return function memoized(...args) {
|
|
7289
|
+
const key = `${args[0]}`;
|
|
7290
|
+
let data = cache[key];
|
|
7291
|
+
if (!data) {
|
|
7292
|
+
data = {
|
|
7293
|
+
value: fn(...args)
|
|
7294
|
+
};
|
|
7295
|
+
cache[key] = data;
|
|
7296
|
+
}
|
|
7297
|
+
return data.value;
|
|
7298
|
+
};
|
|
7299
|
+
}
|
|
7300
|
+
|
|
7301
|
+
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
7302
|
+
const VTYPE_ELEMENT = 1;
|
|
7303
|
+
const VTYPE_FUNCTION = 2;
|
|
7304
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
7305
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
7306
|
+
const NS_ATTRS = {
|
|
7307
|
+
show: XLINK_NS,
|
|
7308
|
+
actuate: XLINK_NS,
|
|
7309
|
+
href: XLINK_NS
|
|
7310
|
+
};
|
|
7311
|
+
const isLeaf = c => typeof c === 'string' || typeof c === 'number';
|
|
7312
|
+
const isElement = c => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
|
|
7313
|
+
const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
7314
|
+
function h(type, props, ...children) {
|
|
7315
|
+
props = Object.assign({}, props, {
|
|
7316
|
+
children: children.length === 1 ? children[0] : children
|
|
7317
|
+
});
|
|
7318
|
+
return jsx(type, props);
|
|
7319
|
+
}
|
|
7320
|
+
function jsx(type, props) {
|
|
7321
|
+
let vtype;
|
|
7322
|
+
if (typeof type === 'string') vtype = VTYPE_ELEMENT;else if (typeof type === 'function') vtype = VTYPE_FUNCTION;else throw new Error('Invalid VNode type');
|
|
7323
|
+
return {
|
|
7324
|
+
vtype,
|
|
7325
|
+
type,
|
|
7326
|
+
props
|
|
7327
|
+
};
|
|
7328
|
+
}
|
|
7329
|
+
function Fragment(props) {
|
|
7330
|
+
return props.children;
|
|
7331
|
+
}
|
|
7332
|
+
const DEFAULT_ENV = {
|
|
7333
|
+
isSvg: false
|
|
7334
|
+
};
|
|
7335
|
+
function insertDom(parent, nodes) {
|
|
7336
|
+
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
7337
|
+
nodes = nodes.filter(Boolean);
|
|
7338
|
+
if (nodes.length) parent.append(...nodes);
|
|
7339
|
+
}
|
|
7340
|
+
function mountAttributes(domElement, props, env) {
|
|
7341
|
+
for (const key in props) {
|
|
7342
|
+
if (key === 'key' || key === 'children' || key === 'ref') continue;
|
|
7343
|
+
if (key === 'dangerouslySetInnerHTML') {
|
|
7344
|
+
domElement.innerHTML = props[key].__html;
|
|
7345
|
+
} else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
|
|
7346
|
+
const value = props[key];
|
|
7347
|
+
if (value != null) domElement[key] = value;
|
|
7348
|
+
} else if (key.startsWith('on')) {
|
|
7349
|
+
domElement[key.toLowerCase()] = props[key];
|
|
7350
|
+
} else {
|
|
7351
|
+
setDOMAttribute(domElement, key, props[key], env.isSvg);
|
|
7352
|
+
}
|
|
7353
|
+
}
|
|
7354
|
+
}
|
|
7355
|
+
const attrMap = {
|
|
7356
|
+
className: 'class',
|
|
7357
|
+
labelFor: 'for'
|
|
7358
|
+
};
|
|
7359
|
+
function setDOMAttribute(el, attr, value, isSVG) {
|
|
7360
|
+
attr = attrMap[attr] || attr;
|
|
7361
|
+
if (value === true) {
|
|
7362
|
+
el.setAttribute(attr, '');
|
|
7363
|
+
} else if (value === false) {
|
|
7364
|
+
el.removeAttribute(attr);
|
|
7365
|
+
} else {
|
|
7366
|
+
const namespace = isSVG ? NS_ATTRS[attr] : undefined;
|
|
7367
|
+
if (namespace !== undefined) {
|
|
7368
|
+
el.setAttributeNS(namespace, attr, value);
|
|
7369
|
+
} else {
|
|
7370
|
+
el.setAttribute(attr, value);
|
|
7371
|
+
}
|
|
7372
|
+
}
|
|
7373
|
+
}
|
|
7374
|
+
function flatten(arr) {
|
|
7375
|
+
return arr.reduce((prev, item) => prev.concat(item), []);
|
|
7376
|
+
}
|
|
7377
|
+
function mountChildren(children, env) {
|
|
7378
|
+
return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
|
|
7379
|
+
}
|
|
7380
|
+
function mount(vnode, env = DEFAULT_ENV) {
|
|
7381
|
+
if (vnode == null || typeof vnode === 'boolean') {
|
|
7382
|
+
return null;
|
|
7383
|
+
}
|
|
7384
|
+
if (vnode instanceof Node) {
|
|
7385
|
+
return vnode;
|
|
7386
|
+
}
|
|
7387
|
+
if (isRenderFunction(vnode)) {
|
|
7388
|
+
const {
|
|
7389
|
+
type,
|
|
7390
|
+
props
|
|
7391
|
+
} = vnode;
|
|
7392
|
+
if (type === Fragment) {
|
|
7393
|
+
const node = document.createDocumentFragment();
|
|
7394
|
+
if (props.children) {
|
|
7395
|
+
const children = mountChildren(props.children, env);
|
|
7396
|
+
insertDom(node, children);
|
|
7397
|
+
}
|
|
7398
|
+
return node;
|
|
7399
|
+
}
|
|
7400
|
+
const childVNode = type(props);
|
|
7401
|
+
return mount(childVNode, env);
|
|
7402
|
+
}
|
|
7403
|
+
if (isLeaf(vnode)) {
|
|
7404
|
+
return document.createTextNode(`${vnode}`);
|
|
7405
|
+
}
|
|
7406
|
+
if (isElement(vnode)) {
|
|
7407
|
+
let node;
|
|
7408
|
+
const {
|
|
7409
|
+
type,
|
|
7410
|
+
props
|
|
7411
|
+
} = vnode;
|
|
7412
|
+
if (!env.isSvg && type === 'svg') {
|
|
7413
|
+
env = Object.assign({}, env, {
|
|
7414
|
+
isSvg: true
|
|
7415
|
+
});
|
|
7416
|
+
}
|
|
7417
|
+
if (!env.isSvg) {
|
|
7418
|
+
node = document.createElement(type);
|
|
7419
|
+
} else {
|
|
7420
|
+
node = document.createElementNS(SVG_NS, type);
|
|
7421
|
+
}
|
|
7422
|
+
mountAttributes(node, props, env);
|
|
7423
|
+
if (props.children) {
|
|
7424
|
+
let childEnv = env;
|
|
7425
|
+
if (env.isSvg && type === 'foreignObject') {
|
|
7426
|
+
childEnv = Object.assign({}, childEnv, {
|
|
7427
|
+
isSvg: false
|
|
7428
|
+
});
|
|
7429
|
+
}
|
|
7430
|
+
const children = mountChildren(props.children, childEnv);
|
|
7431
|
+
if (children != null) insertDom(node, children);
|
|
7432
|
+
}
|
|
7433
|
+
const {
|
|
7434
|
+
ref
|
|
7435
|
+
} = props;
|
|
7436
|
+
if (typeof ref === 'function') ref(node);
|
|
7437
|
+
return node;
|
|
7438
|
+
}
|
|
7439
|
+
throw new Error('mount: Invalid Vnode!');
|
|
7440
|
+
}
|
|
7441
|
+
|
|
7442
|
+
/**
|
|
7443
|
+
* Mount vdom as real DOM nodes.
|
|
7444
|
+
*/
|
|
7445
|
+
function mountDom(vnode) {
|
|
7446
|
+
return mount(vnode);
|
|
7447
|
+
}
|
|
7448
|
+
|
|
7449
|
+
/**
|
|
7450
|
+
* Render and mount without returning VirtualDOM, useful when you don't need SVG support.
|
|
7451
|
+
*/
|
|
7452
|
+
function hm(...args) {
|
|
7453
|
+
return mountDom(h(...args));
|
|
7454
|
+
}
|
|
7455
|
+
const memoizedPreloadJS = memoize(url => {
|
|
7456
|
+
document.head.append(hm('link', {
|
|
7457
|
+
rel: 'preload',
|
|
7458
|
+
as: 'script',
|
|
7459
|
+
href: url
|
|
7460
|
+
}));
|
|
7461
|
+
});
|
|
7462
|
+
const jsCache = {};
|
|
7463
|
+
async function loadJSItem(item, context) {
|
|
7464
|
+
var _item$data;
|
|
7465
|
+
const src = item.type === 'script' && ((_item$data = item.data) == null ? void 0 : _item$data.src) || '';
|
|
7466
|
+
item.loaded || (item.loaded = jsCache[src]);
|
|
7467
|
+
if (!item.loaded) {
|
|
7468
|
+
if (item.type === 'script') {
|
|
7469
|
+
item.loaded = new Promise((resolve, reject) => {
|
|
7470
|
+
document.head.append(hm('script', _extends({}, item.data, {
|
|
7471
|
+
onLoad: resolve,
|
|
7472
|
+
onError: reject
|
|
7473
|
+
})));
|
|
7474
|
+
if (!src) {
|
|
7475
|
+
// Run inline script synchronously
|
|
7476
|
+
resolve(undefined);
|
|
7477
|
+
}
|
|
7478
|
+
}).then(() => {
|
|
7479
|
+
item.loaded = true;
|
|
7480
|
+
});
|
|
7481
|
+
if (src) jsCache[src] = item.loaded;
|
|
7482
|
+
}
|
|
7483
|
+
if (item.type === 'iife') {
|
|
7484
|
+
const {
|
|
7485
|
+
fn,
|
|
7486
|
+
getParams
|
|
7487
|
+
} = item.data;
|
|
7488
|
+
fn(...((getParams == null ? void 0 : getParams(context)) || []));
|
|
7489
|
+
item.loaded = true;
|
|
7490
|
+
}
|
|
7491
|
+
}
|
|
7492
|
+
await item.loaded;
|
|
7493
|
+
}
|
|
7494
|
+
async function loadJS(items, context) {
|
|
7495
|
+
items.forEach(item => {
|
|
7496
|
+
var _item$data2;
|
|
7497
|
+
if (item.type === 'script' && (_item$data2 = item.data) != null && _item$data2.src) {
|
|
7498
|
+
memoizedPreloadJS(item.data.src);
|
|
7499
|
+
}
|
|
7500
|
+
});
|
|
7501
|
+
context = _extends({
|
|
7502
|
+
getMarkmap: () => window.markmap
|
|
7503
|
+
}, context);
|
|
7504
|
+
for (const item of items) {
|
|
7505
|
+
await loadJSItem(item, context);
|
|
7506
|
+
}
|
|
7507
|
+
}
|
|
7508
|
+
function buildJSItem(path) {
|
|
7509
|
+
return {
|
|
7510
|
+
type: 'script',
|
|
7511
|
+
data: {
|
|
7512
|
+
src: path
|
|
7513
|
+
}
|
|
7514
|
+
};
|
|
7515
|
+
}
|
|
7516
|
+
function buildCSSItem(path) {
|
|
7517
|
+
return {
|
|
7518
|
+
type: 'stylesheet',
|
|
7519
|
+
data: {
|
|
7520
|
+
href: path
|
|
7521
|
+
}
|
|
7522
|
+
};
|
|
7523
|
+
}
|
|
7524
|
+
|
|
7525
|
+
function getDefaultExportFromCjs (x) {
|
|
7526
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
7527
|
+
}
|
|
7528
|
+
|
|
7529
|
+
/**
|
|
7530
|
+
* Plugin for Remarkable Markdown processor which transforms $..$ and $$..$$ sequences into math HTML using the
|
|
7531
|
+
* Katex package.
|
|
7532
|
+
*/
|
|
7533
|
+
const rkatex = (md, options) => {
|
|
7534
|
+
const backslash = '\\';
|
|
7535
|
+
const dollar = '$';
|
|
7536
|
+
const opts = options || {};
|
|
7537
|
+
const delimiter = opts.delimiter || dollar;
|
|
7538
|
+
if (delimiter.length !== 1) {
|
|
7539
|
+
throw new Error('invalid delimiter');
|
|
7540
|
+
}
|
|
7541
|
+
const katex = require$$0;
|
|
7542
|
+
|
|
7543
|
+
/**
|
|
7544
|
+
* Render the contents as KaTeX
|
|
7545
|
+
*/
|
|
7546
|
+
const renderKatex = (source, displayMode) => katex.renderToString(source, {
|
|
7547
|
+
displayMode: displayMode,
|
|
7548
|
+
throwOnError: false
|
|
7549
|
+
});
|
|
7550
|
+
|
|
7551
|
+
/**
|
|
7552
|
+
* Parse '$$' as a block. Based off of similar method in remarkable.
|
|
7553
|
+
*/
|
|
7554
|
+
const parseBlockKatex = (state, startLine, endLine) => {
|
|
7555
|
+
let haveEndMarker = false;
|
|
7556
|
+
let pos = state.bMarks[startLine] + state.tShift[startLine];
|
|
7557
|
+
let max = state.eMarks[startLine];
|
|
7558
|
+
if (pos + 1 > max) {
|
|
7559
|
+
return false;
|
|
7560
|
+
}
|
|
7561
|
+
const marker = state.src.charAt(pos);
|
|
7562
|
+
if (marker !== delimiter) {
|
|
7563
|
+
return false;
|
|
7564
|
+
}
|
|
7565
|
+
|
|
7566
|
+
// scan marker length
|
|
7567
|
+
let mem = pos;
|
|
7568
|
+
pos = state.skipChars(pos, marker);
|
|
7569
|
+
let len = pos - mem;
|
|
7570
|
+
if (len !== 2) {
|
|
7571
|
+
return false;
|
|
7431
7572
|
}
|
|
7432
7573
|
|
|
7433
7574
|
// search end of block
|
|
@@ -7545,40 +7686,39 @@ var remarkableKatex = rkatex;
|
|
|
7545
7686
|
|
|
7546
7687
|
var remarkableKatex$1 = /*@__PURE__*/getDefaultExportFromCjs(remarkableKatex);
|
|
7547
7688
|
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
}
|
|
7689
|
+
const name$3 = 'katex';
|
|
7690
|
+
const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
|
|
7691
|
+
const webfontloader = buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
|
|
7692
|
+
webfontloader.data.defer = true;
|
|
7693
|
+
const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(path => buildCSSItem(path));
|
|
7694
|
+
const config$1 = {
|
|
7695
|
+
versions: {
|
|
7696
|
+
katex: "0.16.8" ,
|
|
7697
|
+
webfontloader: "1.6.28"
|
|
7698
|
+
},
|
|
7699
|
+
preloadScripts,
|
|
7700
|
+
scripts: [{
|
|
7701
|
+
type: 'iife',
|
|
7702
|
+
data: {
|
|
7703
|
+
fn: getMarkmap => {
|
|
7704
|
+
window.WebFontConfig = {
|
|
7705
|
+
custom: {
|
|
7706
|
+
families: ['KaTeX_AMS', 'KaTeX_Caligraphic:n4,n7', 'KaTeX_Fraktur:n4,n7', 'KaTeX_Main:n4,n7,i4,i7', 'KaTeX_Math:i4,i7', 'KaTeX_Script', 'KaTeX_SansSerif:n4,n7,i4', 'KaTeX_Size1', 'KaTeX_Size2', 'KaTeX_Size3', 'KaTeX_Size4', 'KaTeX_Typewriter']
|
|
7707
|
+
},
|
|
7708
|
+
active: () => {
|
|
7709
|
+
getMarkmap().refreshHook.call();
|
|
7710
|
+
}
|
|
7711
|
+
};
|
|
7712
|
+
},
|
|
7713
|
+
getParams({
|
|
7714
|
+
getMarkmap
|
|
7715
|
+
}) {
|
|
7716
|
+
return [getMarkmap];
|
|
7577
7717
|
}
|
|
7578
|
-
}
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
}
|
|
7718
|
+
}
|
|
7719
|
+
}, webfontloader],
|
|
7720
|
+
styles: styles$1
|
|
7721
|
+
};
|
|
7582
7722
|
|
|
7583
7723
|
/**
|
|
7584
7724
|
* Find NPM paths and resolve them to full URLs with the same package version as in this library.
|
|
@@ -7597,9 +7737,30 @@ function addDefaultVersions(paths, name, version) {
|
|
|
7597
7737
|
return path;
|
|
7598
7738
|
});
|
|
7599
7739
|
}
|
|
7740
|
+
function patchJSItem(transformer, item) {
|
|
7741
|
+
if (item.type === 'script' && item.data.src) {
|
|
7742
|
+
return _extends$1({}, item, {
|
|
7743
|
+
data: _extends$1({}, item.data, {
|
|
7744
|
+
src: transformer.urlBuilder.getFullUrl(item.data.src)
|
|
7745
|
+
})
|
|
7746
|
+
});
|
|
7747
|
+
}
|
|
7748
|
+
return item;
|
|
7749
|
+
}
|
|
7750
|
+
function patchCSSItem(transformer, item) {
|
|
7751
|
+
if (item.type === 'stylesheet' && item.data.href) {
|
|
7752
|
+
return _extends$1({}, item, {
|
|
7753
|
+
data: _extends$1({}, item.data, {
|
|
7754
|
+
href: transformer.urlBuilder.getFullUrl(item.data.href)
|
|
7755
|
+
})
|
|
7756
|
+
});
|
|
7757
|
+
}
|
|
7758
|
+
return item;
|
|
7759
|
+
}
|
|
7600
7760
|
|
|
7601
|
-
function createTransformHooks() {
|
|
7761
|
+
function createTransformHooks(transformer) {
|
|
7602
7762
|
return {
|
|
7763
|
+
transformer,
|
|
7603
7764
|
parser: new Hook(),
|
|
7604
7765
|
beforeParse: new Hook(),
|
|
7605
7766
|
afterParse: new Hook(),
|
|
@@ -7615,126 +7776,64 @@ function definePlugin(plugin) {
|
|
|
7615
7776
|
return plugin;
|
|
7616
7777
|
}
|
|
7617
7778
|
|
|
7618
|
-
const
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
config
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
});
|
|
7638
|
-
}
|
|
7639
|
-
autoload().then(() => {
|
|
7640
|
-
transformHooks.retransform.call();
|
|
7779
|
+
const plugin$1 = definePlugin({
|
|
7780
|
+
name: name$3,
|
|
7781
|
+
config: config$1,
|
|
7782
|
+
transform(transformHooks) {
|
|
7783
|
+
var _plugin$config, _plugin$config3, _plugin$config4;
|
|
7784
|
+
let loading;
|
|
7785
|
+
const preloadScripts = ((_plugin$config = plugin$1.config) == null || (_plugin$config = _plugin$config.preloadScripts) == null ? void 0 : _plugin$config.map(item => patchJSItem(transformHooks.transformer, item))) || [];
|
|
7786
|
+
const autoload = () => {
|
|
7787
|
+
loading || (loading = loadJS(preloadScripts));
|
|
7788
|
+
return loading;
|
|
7789
|
+
};
|
|
7790
|
+
const renderKatex = (source, displayMode) => {
|
|
7791
|
+
const {
|
|
7792
|
+
katex
|
|
7793
|
+
} = window;
|
|
7794
|
+
if (katex) {
|
|
7795
|
+
return katex.renderToString(source, {
|
|
7796
|
+
displayMode,
|
|
7797
|
+
throwOnError: false
|
|
7641
7798
|
});
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
transformHooks.parser.tap(md => {
|
|
7646
|
-
md.use(remarkableKatex$1);
|
|
7647
|
-
md.renderer.rules.katex = (tokens, idx) => {
|
|
7648
|
-
enableFeature();
|
|
7649
|
-
const result = renderKatex(tokens[idx].content, tokens[idx].block);
|
|
7650
|
-
return result;
|
|
7651
|
-
};
|
|
7652
|
-
});
|
|
7653
|
-
transformHooks.beforeParse.tap((_, context) => {
|
|
7654
|
-
enableFeature = () => {
|
|
7655
|
-
context.features[name$3] = true;
|
|
7656
|
-
};
|
|
7657
|
-
});
|
|
7658
|
-
transformHooks.afterParse.tap((_, context) => {
|
|
7659
|
-
const {
|
|
7660
|
-
frontmatter
|
|
7661
|
-
} = context;
|
|
7662
|
-
if (frontmatter != null && frontmatter.markmap) {
|
|
7663
|
-
['extraJs', 'extraCss'].forEach(key => {
|
|
7664
|
-
if (frontmatter.markmap[key]) {
|
|
7665
|
-
frontmatter.markmap[key] = addDefaultVersions(frontmatter.markmap[key], name$3, plugin.config.versions.katex);
|
|
7666
|
-
}
|
|
7667
|
-
});
|
|
7668
|
-
}
|
|
7799
|
+
}
|
|
7800
|
+
autoload().then(() => {
|
|
7801
|
+
transformHooks.retransform.call();
|
|
7669
7802
|
});
|
|
7670
|
-
return
|
|
7671
|
-
|
|
7672
|
-
|
|
7803
|
+
return source;
|
|
7804
|
+
};
|
|
7805
|
+
let enableFeature = noop;
|
|
7806
|
+
transformHooks.parser.tap(md => {
|
|
7807
|
+
md.use(remarkableKatex$1);
|
|
7808
|
+
md.renderer.rules.katex = (tokens, idx) => {
|
|
7809
|
+
enableFeature();
|
|
7810
|
+
const result = renderKatex(tokens[idx].content, !!tokens[idx].block);
|
|
7811
|
+
return result;
|
|
7673
7812
|
};
|
|
7674
|
-
}
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
function getConfig() {
|
|
7680
|
-
const preloadScripts = [`prismjs@${"1.28.0"}/components/prism-core.min.js`, `prismjs@${"1.28.0"}/plugins/autoloader/prism-autoloader.min.js`].map(buildJSItem);
|
|
7681
|
-
const styles = [`prismjs@${"1.28.0"}/themes/prism.css`].map(buildCSSItem);
|
|
7682
|
-
return {
|
|
7683
|
-
versions: {
|
|
7684
|
-
prismjs: "1.28.0"
|
|
7685
|
-
},
|
|
7686
|
-
preloadScripts,
|
|
7687
|
-
styles
|
|
7688
|
-
};
|
|
7689
|
-
}
|
|
7690
|
-
|
|
7691
|
-
const name$2 = 'prism';
|
|
7692
|
-
var prism = definePlugin(() => {
|
|
7693
|
-
const plugin = {
|
|
7694
|
-
name: name$2,
|
|
7695
|
-
config: getConfig(),
|
|
7696
|
-
transform(transformHooks) {
|
|
7697
|
-
let loading;
|
|
7698
|
-
const autoload = () => {
|
|
7699
|
-
loading || (loading = loadJS(plugin.config.preloadScripts));
|
|
7700
|
-
return loading;
|
|
7813
|
+
});
|
|
7814
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
7815
|
+
enableFeature = () => {
|
|
7816
|
+
context.features[name$3] = true;
|
|
7701
7817
|
};
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
highlight: (str, lang) => {
|
|
7713
|
-
var _Prism$languages;
|
|
7714
|
-
enableFeature();
|
|
7715
|
-
const {
|
|
7716
|
-
Prism
|
|
7717
|
-
} = window;
|
|
7718
|
-
const grammar = Prism == null || (_Prism$languages = Prism.languages) == null ? void 0 : _Prism$languages[lang];
|
|
7719
|
-
if (!grammar) {
|
|
7720
|
-
loadLanguageAndRefresh(lang, transformHooks);
|
|
7721
|
-
return '';
|
|
7722
|
-
}
|
|
7723
|
-
return Prism.highlight(str, grammar, lang);
|
|
7818
|
+
});
|
|
7819
|
+
transformHooks.afterParse.tap((_, context) => {
|
|
7820
|
+
var _context$frontmatter;
|
|
7821
|
+
const markmap = (_context$frontmatter = context.frontmatter) == null ? void 0 : _context$frontmatter.markmap;
|
|
7822
|
+
if (markmap) {
|
|
7823
|
+
['extraJs', 'extraCss'].forEach(key => {
|
|
7824
|
+
const value = markmap[key];
|
|
7825
|
+
if (value) {
|
|
7826
|
+
var _plugin$config2;
|
|
7827
|
+
markmap[key] = addDefaultVersions(value, name$3, ((_plugin$config2 = plugin$1.config) == null || (_plugin$config2 = _plugin$config2.versions) == null ? void 0 : _plugin$config2.katex) || '');
|
|
7724
7828
|
}
|
|
7725
7829
|
});
|
|
7726
|
-
}
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
styles: plugin.config.styles
|
|
7734
|
-
};
|
|
7735
|
-
}
|
|
7736
|
-
};
|
|
7737
|
-
return plugin;
|
|
7830
|
+
}
|
|
7831
|
+
});
|
|
7832
|
+
return {
|
|
7833
|
+
styles: (_plugin$config3 = plugin$1.config) == null ? void 0 : _plugin$config3.styles,
|
|
7834
|
+
scripts: (_plugin$config4 = plugin$1.config) == null ? void 0 : _plugin$config4.scripts
|
|
7835
|
+
};
|
|
7836
|
+
}
|
|
7738
7837
|
});
|
|
7739
7838
|
|
|
7740
7839
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
|
@@ -10848,9 +10947,9 @@ var jsYaml = {
|
|
|
10848
10947
|
safeDump: safeDump
|
|
10849
10948
|
};
|
|
10850
10949
|
|
|
10851
|
-
const name$
|
|
10950
|
+
const name$2 = 'frontmatter';
|
|
10852
10951
|
var frontmatter = definePlugin({
|
|
10853
|
-
name: name$
|
|
10952
|
+
name: name$2,
|
|
10854
10953
|
transform(transformHooks) {
|
|
10855
10954
|
transformHooks.beforeParse.tap((md, context) => {
|
|
10856
10955
|
const {
|
|
@@ -10898,20 +10997,22 @@ function normalizeNumber(value) {
|
|
|
10898
10997
|
return +value;
|
|
10899
10998
|
}
|
|
10900
10999
|
|
|
10901
|
-
const name = 'npmUrl';
|
|
11000
|
+
const name$1 = 'npmUrl';
|
|
10902
11001
|
var npmUrl = definePlugin({
|
|
10903
|
-
name,
|
|
11002
|
+
name: name$1,
|
|
10904
11003
|
transform(transformHooks) {
|
|
10905
11004
|
transformHooks.afterParse.tap((_, context) => {
|
|
10906
11005
|
const {
|
|
10907
11006
|
frontmatter
|
|
10908
11007
|
} = context;
|
|
10909
|
-
|
|
11008
|
+
const markmap = frontmatter == null ? void 0 : frontmatter.markmap;
|
|
11009
|
+
if (markmap) {
|
|
10910
11010
|
['extraJs', 'extraCss'].forEach(key => {
|
|
10911
|
-
|
|
10912
|
-
|
|
11011
|
+
const value = markmap[key];
|
|
11012
|
+
if (value) {
|
|
11013
|
+
markmap[key] = value.map(path => {
|
|
10913
11014
|
if (path.startsWith('npm:')) {
|
|
10914
|
-
return getFullUrl(path.slice(4));
|
|
11015
|
+
return transformHooks.transformer.urlBuilder.getFullUrl(path.slice(4));
|
|
10915
11016
|
}
|
|
10916
11017
|
return path;
|
|
10917
11018
|
});
|
|
@@ -10923,7 +11024,40 @@ var npmUrl = definePlugin({
|
|
|
10923
11024
|
}
|
|
10924
11025
|
});
|
|
10925
11026
|
|
|
10926
|
-
const
|
|
11027
|
+
const name = 'hljs';
|
|
11028
|
+
const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => buildCSSItem(path));
|
|
11029
|
+
const config = {
|
|
11030
|
+
versions: {
|
|
11031
|
+
hljs: "11.8.0"
|
|
11032
|
+
},
|
|
11033
|
+
styles
|
|
11034
|
+
};
|
|
11035
|
+
const plugin = definePlugin({
|
|
11036
|
+
name,
|
|
11037
|
+
config,
|
|
11038
|
+
transform(transformHooks) {
|
|
11039
|
+
var _plugin$config;
|
|
11040
|
+
let enableFeature = noop;
|
|
11041
|
+
transformHooks.parser.tap(md => {
|
|
11042
|
+
md.set({
|
|
11043
|
+
highlight: (str, language) => {
|
|
11044
|
+
enableFeature();
|
|
11045
|
+
return hljs.highlightAuto(str, language ? [language] : undefined).value;
|
|
11046
|
+
}
|
|
11047
|
+
});
|
|
11048
|
+
});
|
|
11049
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
11050
|
+
enableFeature = () => {
|
|
11051
|
+
context.features[name] = true;
|
|
11052
|
+
};
|
|
11053
|
+
});
|
|
11054
|
+
return {
|
|
11055
|
+
styles: (_plugin$config = plugin.config) == null ? void 0 : _plugin$config.styles
|
|
11056
|
+
};
|
|
11057
|
+
}
|
|
11058
|
+
});
|
|
11059
|
+
|
|
11060
|
+
const plugins = [frontmatter, plugin$1, plugin, npmUrl];
|
|
10927
11061
|
|
|
10928
11062
|
function cleanNode(node) {
|
|
10929
11063
|
if (node.type === 'heading') {
|
|
@@ -10957,9 +11091,7 @@ function cleanNode(node) {
|
|
|
10957
11091
|
}
|
|
10958
11092
|
});
|
|
10959
11093
|
}
|
|
10960
|
-
if (node.children.length
|
|
10961
|
-
delete node.children;
|
|
10962
|
-
} else {
|
|
11094
|
+
if (node.children.length > 0) {
|
|
10963
11095
|
node.children.forEach(child => cleanNode(child));
|
|
10964
11096
|
if (node.children.length === 1 && !node.children[0].content) {
|
|
10965
11097
|
node.children = node.children[0].children;
|
|
@@ -10967,16 +11099,16 @@ function cleanNode(node) {
|
|
|
10967
11099
|
}
|
|
10968
11100
|
}
|
|
10969
11101
|
function resetDepth(node, depth = 0) {
|
|
10970
|
-
var _node$children;
|
|
10971
11102
|
node.depth = depth;
|
|
10972
|
-
|
|
11103
|
+
node.children.forEach(child => {
|
|
10973
11104
|
resetDepth(child, depth + 1);
|
|
10974
11105
|
});
|
|
10975
11106
|
}
|
|
10976
11107
|
class Transformer {
|
|
10977
11108
|
constructor(plugins$1 = plugins) {
|
|
10978
11109
|
this.assetsMap = {};
|
|
10979
|
-
this.
|
|
11110
|
+
this.urlBuilder = new UrlBuilder();
|
|
11111
|
+
this.hooks = createTransformHooks(this);
|
|
10980
11112
|
this.plugins = plugins$1.map(plugin => typeof plugin === 'function' ? plugin() : plugin);
|
|
10981
11113
|
const assetsMap = {};
|
|
10982
11114
|
for (const {
|
|
@@ -11016,13 +11148,13 @@ class Transformer {
|
|
|
11016
11148
|
const stack = [root];
|
|
11017
11149
|
let depth = 0;
|
|
11018
11150
|
for (const token of tokens) {
|
|
11151
|
+
const payload = {};
|
|
11152
|
+
if (token.lines) {
|
|
11153
|
+
payload.lines = token.lines;
|
|
11154
|
+
}
|
|
11019
11155
|
let current = stack[stack.length - 1];
|
|
11020
11156
|
if (token.type.endsWith('_open')) {
|
|
11021
11157
|
const type = token.type.slice(0, -5);
|
|
11022
|
-
const payload = {};
|
|
11023
|
-
if (token.lines) {
|
|
11024
|
-
payload.lines = token.lines;
|
|
11025
|
-
}
|
|
11026
11158
|
if (type === 'heading') {
|
|
11027
11159
|
depth = token.hLevel;
|
|
11028
11160
|
while (((_current = current) == null ? void 0 : _current.depth) >= depth) {
|
|
@@ -11057,10 +11189,13 @@ class Transformer {
|
|
|
11057
11189
|
}
|
|
11058
11190
|
} else if (token.type === 'inline') {
|
|
11059
11191
|
const revoke = this.hooks.htmltag.tap(ctx => {
|
|
11060
|
-
|
|
11192
|
+
var _ctx$result;
|
|
11193
|
+
const comment = (_ctx$result = ctx.result) == null ? void 0 : _ctx$result.match(/^<!--([\s\S]*?)-->$/);
|
|
11061
11194
|
const data = comment == null ? void 0 : comment[1].trim().split(' ');
|
|
11062
|
-
if (data[0] === 'fold') {
|
|
11063
|
-
current.payload
|
|
11195
|
+
if ((data == null ? void 0 : data[0]) === 'fold') {
|
|
11196
|
+
current.payload = _extends$1({}, current.payload, {
|
|
11197
|
+
fold: ['all', 'recursively'].includes(data[1]) ? 2 : 1
|
|
11198
|
+
});
|
|
11064
11199
|
ctx.result = '';
|
|
11065
11200
|
}
|
|
11066
11201
|
});
|
|
@@ -11068,15 +11203,13 @@ class Transformer {
|
|
|
11068
11203
|
revoke();
|
|
11069
11204
|
current.content = `${current.content || ''}${text}`;
|
|
11070
11205
|
} else if (token.type === 'fence') {
|
|
11071
|
-
|
|
11072
|
-
// Remarkable only adds className to `<code>` but not `<pre>`, copy it to make PrismJS style work.
|
|
11073
|
-
const matches = result.match(/<code( class="[^"]*")>/);
|
|
11074
|
-
if (matches) result = result.replace('<pre>', `<pre${matches[1]}>`);
|
|
11206
|
+
const result = md.renderer.render([token], md.options, {});
|
|
11075
11207
|
current.children.push({
|
|
11076
11208
|
type: token.type,
|
|
11077
11209
|
depth: depth + 1,
|
|
11078
11210
|
content: result,
|
|
11079
|
-
children: []
|
|
11211
|
+
children: [],
|
|
11212
|
+
payload
|
|
11080
11213
|
});
|
|
11081
11214
|
} else ;
|
|
11082
11215
|
}
|
|
@@ -11116,8 +11249,8 @@ class Transformer {
|
|
|
11116
11249
|
}
|
|
11117
11250
|
}
|
|
11118
11251
|
return {
|
|
11119
|
-
styles,
|
|
11120
|
-
scripts
|
|
11252
|
+
styles: styles.map(item => patchCSSItem(this, item)),
|
|
11253
|
+
scripts: scripts.map(item => patchJSItem(this, item))
|
|
11121
11254
|
};
|
|
11122
11255
|
}
|
|
11123
11256
|
|
|
@@ -11128,17 +11261,52 @@ class Transformer {
|
|
|
11128
11261
|
const keys = this.plugins.map(plugin => plugin.name).filter(name => features[name]);
|
|
11129
11262
|
return this.getAssets(keys);
|
|
11130
11263
|
}
|
|
11264
|
+
fillTemplate(root, assets, extra) {
|
|
11265
|
+
var _extra, _extra$baseJs;
|
|
11266
|
+
extra = _extends$1({}, extra);
|
|
11267
|
+
(_extra$baseJs = (_extra = extra).baseJs) != null ? _extra$baseJs : _extra.baseJs = baseJsPaths.map(path => this.urlBuilder.getFullUrl(path)).map(path => buildJSItem(path));
|
|
11268
|
+
const {
|
|
11269
|
+
scripts,
|
|
11270
|
+
styles
|
|
11271
|
+
} = assets;
|
|
11272
|
+
const cssList = [...(styles ? persistCSS(styles) : [])];
|
|
11273
|
+
const context = {
|
|
11274
|
+
getMarkmap: () => window.markmap,
|
|
11275
|
+
getOptions: extra.getOptions,
|
|
11276
|
+
jsonOptions: extra.jsonOptions,
|
|
11277
|
+
root
|
|
11278
|
+
};
|
|
11279
|
+
const jsList = [...persistJS([...extra.baseJs, ...(scripts || []), {
|
|
11280
|
+
type: 'iife',
|
|
11281
|
+
data: {
|
|
11282
|
+
fn: (getMarkmap, getOptions, root, jsonOptions) => {
|
|
11283
|
+
const markmap = getMarkmap();
|
|
11284
|
+
window.mm = markmap.Markmap.create('svg#mindmap', (getOptions || markmap.deriveOptions)(jsonOptions), root);
|
|
11285
|
+
},
|
|
11286
|
+
getParams: ({
|
|
11287
|
+
getMarkmap,
|
|
11288
|
+
getOptions,
|
|
11289
|
+
root,
|
|
11290
|
+
jsonOptions
|
|
11291
|
+
}) => {
|
|
11292
|
+
return [getMarkmap, getOptions, root, jsonOptions];
|
|
11293
|
+
}
|
|
11294
|
+
}
|
|
11295
|
+
}], context)];
|
|
11296
|
+
const html = template.replace('<!--CSS-->', () => cssList.join('')).replace('<!--JS-->', () => jsList.join(''));
|
|
11297
|
+
return html;
|
|
11298
|
+
}
|
|
11131
11299
|
}
|
|
11132
11300
|
|
|
11133
11301
|
const transformerVersions = {
|
|
11134
|
-
'markmap-lib': '0.15.
|
|
11135
|
-
d3: "
|
|
11302
|
+
'markmap-lib': '0.15.1',
|
|
11303
|
+
d3: "7.8.5"
|
|
11136
11304
|
};
|
|
11137
11305
|
|
|
11138
11306
|
exports.Transformer = Transformer;
|
|
11139
11307
|
exports.baseJsPaths = baseJsPaths;
|
|
11140
11308
|
exports.builtInPlugins = plugins;
|
|
11141
|
-
exports.
|
|
11309
|
+
exports.template = template;
|
|
11142
11310
|
exports.transformerVersions = transformerVersions;
|
|
11143
11311
|
|
|
11144
11312
|
}));
|