markmap-lib 0.14.5-alpha.19 → 0.14.5-alpha.21
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 +71 -468
- package/dist/browser/index.mjs +180 -10958
- package/dist/index.js +48 -63
- package/dist/index.mjs +48 -63
- package/package.json +5 -4
- package/types/plugins/hljs.d.ts +2 -0
- package/types/plugins/katex.config.d.ts +1 -0
- package/types/plugins/prism.config.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
/*! markmap-lib v0.14.5-alpha.
|
|
1
|
+
/*! markmap-lib v0.14.5-alpha.21+fb81f2c | MIT License */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
5
5
|
var markmapCommon = require('markmap-common');
|
|
6
6
|
var remarkable = require('remarkable');
|
|
7
7
|
var remarkableKatex = require('remarkable-katex');
|
|
8
|
-
var Prism = require('prismjs');
|
|
9
|
-
var loadLanguages = require('prismjs/components/index.js');
|
|
10
8
|
var yaml = require('js-yaml');
|
|
9
|
+
var hljs$1 = require('highlight.js');
|
|
11
10
|
|
|
12
11
|
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" ;
|
|
13
|
-
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.
|
|
12
|
+
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.21"}/dist/browser/index.js`];
|
|
14
13
|
function fillTemplate(root, assets, extra) {
|
|
15
14
|
var _extra, _extra$baseJs;
|
|
16
15
|
extra = _extends({}, extra);
|
|
@@ -47,6 +46,7 @@ function fillTemplate(root, assets, extra) {
|
|
|
47
46
|
return html;
|
|
48
47
|
}
|
|
49
48
|
|
|
49
|
+
const name$3 = 'katex';
|
|
50
50
|
function getConfig$1() {
|
|
51
51
|
const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => markmapCommon.buildJSItem(path));
|
|
52
52
|
const webfontloader = markmapCommon.buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
|
|
@@ -99,7 +99,6 @@ function definePlugin(plugin) {
|
|
|
99
99
|
return plugin;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const name$3 = 'katex';
|
|
103
102
|
var katex = definePlugin(() => {
|
|
104
103
|
const plugin = {
|
|
105
104
|
name: name$3,
|
|
@@ -127,57 +126,9 @@ var katex = definePlugin(() => {
|
|
|
127
126
|
return plugin;
|
|
128
127
|
});
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
const preloadScripts = [`prismjs@${"1.29.0"}/components/prism-core.min.js`, `prismjs@${"1.29.0"}/plugins/autoloader/prism-autoloader.min.js`].map(path => markmapCommon.buildJSItem(path));
|
|
132
|
-
const styles = [`prismjs@${"1.29.0"}/themes/prism.css`].map(path => markmapCommon.buildCSSItem(path));
|
|
133
|
-
return {
|
|
134
|
-
versions: {
|
|
135
|
-
prismjs: "1.29.0"
|
|
136
|
-
},
|
|
137
|
-
preloadScripts,
|
|
138
|
-
styles
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const name$2 = 'prism';
|
|
143
|
-
var prism = definePlugin(() => {
|
|
144
|
-
const plugin = {
|
|
145
|
-
name: name$2,
|
|
146
|
-
config: getConfig(),
|
|
147
|
-
transform(transformHooks) {
|
|
148
|
-
let enableFeature = markmapCommon.noop;
|
|
149
|
-
transformHooks.parser.tap(md => {
|
|
150
|
-
md.set({
|
|
151
|
-
highlight: (str, lang) => {
|
|
152
|
-
enableFeature();
|
|
153
|
-
let grammar = Prism.languages[lang];
|
|
154
|
-
if (!grammar && lang) {
|
|
155
|
-
loadLanguages([lang]);
|
|
156
|
-
grammar = Prism.languages[lang];
|
|
157
|
-
}
|
|
158
|
-
if (grammar) {
|
|
159
|
-
return Prism.highlight(str, grammar, lang);
|
|
160
|
-
}
|
|
161
|
-
return '';
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
transformHooks.beforeParse.tap((_, context) => {
|
|
166
|
-
enableFeature = () => {
|
|
167
|
-
context.features[name$2] = true;
|
|
168
|
-
};
|
|
169
|
-
});
|
|
170
|
-
return {
|
|
171
|
-
styles: plugin.config.styles
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
return plugin;
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
const name$1 = 'frontmatter';
|
|
129
|
+
const name$2 = 'frontmatter';
|
|
179
130
|
var frontmatter = definePlugin({
|
|
180
|
-
name: name$
|
|
131
|
+
name: name$2,
|
|
181
132
|
transform(transformHooks) {
|
|
182
133
|
transformHooks.beforeParse.tap((md, context) => {
|
|
183
134
|
const {
|
|
@@ -225,9 +176,9 @@ function normalizeNumber(value) {
|
|
|
225
176
|
return +value;
|
|
226
177
|
}
|
|
227
178
|
|
|
228
|
-
const name = 'npmUrl';
|
|
179
|
+
const name$1 = 'npmUrl';
|
|
229
180
|
var npmUrl = definePlugin({
|
|
230
|
-
name,
|
|
181
|
+
name: name$1,
|
|
231
182
|
transform(transformHooks) {
|
|
232
183
|
transformHooks.afterParse.tap((_, context) => {
|
|
233
184
|
const {
|
|
@@ -252,7 +203,44 @@ var npmUrl = definePlugin({
|
|
|
252
203
|
}
|
|
253
204
|
});
|
|
254
205
|
|
|
255
|
-
const
|
|
206
|
+
const name = 'hljs';
|
|
207
|
+
function getConfig() {
|
|
208
|
+
const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => markmapCommon.buildCSSItem(path));
|
|
209
|
+
return {
|
|
210
|
+
versions: {
|
|
211
|
+
hljs: "11.8.0"
|
|
212
|
+
},
|
|
213
|
+
styles
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
var hljs = definePlugin(() => {
|
|
217
|
+
const plugin = {
|
|
218
|
+
name,
|
|
219
|
+
config: getConfig(),
|
|
220
|
+
transform(transformHooks) {
|
|
221
|
+
let enableFeature = markmapCommon.noop;
|
|
222
|
+
transformHooks.parser.tap(md => {
|
|
223
|
+
md.set({
|
|
224
|
+
highlight: (str, language) => {
|
|
225
|
+
enableFeature();
|
|
226
|
+
return hljs$1.highlightAuto(str, language ? [language] : undefined).value;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
231
|
+
enableFeature = () => {
|
|
232
|
+
context.features[name] = true;
|
|
233
|
+
};
|
|
234
|
+
});
|
|
235
|
+
return {
|
|
236
|
+
styles: plugin.config.styles
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
return plugin;
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const plugins = [frontmatter, katex, hljs, npmUrl];
|
|
256
244
|
|
|
257
245
|
function cleanNode(node) {
|
|
258
246
|
if (node.type === 'heading') {
|
|
@@ -397,10 +385,7 @@ class Transformer {
|
|
|
397
385
|
revoke();
|
|
398
386
|
current.content = `${current.content || ''}${text}`;
|
|
399
387
|
} else if (token.type === 'fence') {
|
|
400
|
-
|
|
401
|
-
// Remarkable only adds className to `<code>` but not `<pre>`, copy it to make PrismJS style work.
|
|
402
|
-
const matches = result.match(/<code( class="[^"]*")>/);
|
|
403
|
-
if (matches) result = result.replace('<pre>', `<pre${matches[1]}>`);
|
|
388
|
+
const result = md.renderer.render([token], md.options, {});
|
|
404
389
|
current.children.push({
|
|
405
390
|
type: token.type,
|
|
406
391
|
depth: depth + 1,
|
|
@@ -461,7 +446,7 @@ class Transformer {
|
|
|
461
446
|
}
|
|
462
447
|
|
|
463
448
|
const transformerVersions = {
|
|
464
|
-
'markmap-lib': '0.14.5-alpha.
|
|
449
|
+
'markmap-lib': '0.14.5-alpha.21+fb81f2c',
|
|
465
450
|
d3: "7.8.5"
|
|
466
451
|
};
|
|
467
452
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
/*! markmap-lib v0.14.5-alpha.
|
|
1
|
+
/*! markmap-lib v0.14.5-alpha.21+fb81f2c | MIT License */
|
|
2
2
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
3
3
|
import { buildJSItem, persistCSS, persistJS, buildCSSItem, Hook, wrapFunction, noop, getFullUrl } from 'markmap-common';
|
|
4
4
|
import { Remarkable } from 'remarkable';
|
|
5
5
|
import remarkableKatex from 'remarkable-katex';
|
|
6
|
-
import Prism from 'prismjs';
|
|
7
|
-
import loadLanguages from 'prismjs/components/index.js';
|
|
8
6
|
import yaml from 'js-yaml';
|
|
7
|
+
import hljs$1 from 'highlight.js';
|
|
9
8
|
|
|
10
9
|
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" ;
|
|
11
|
-
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.
|
|
10
|
+
const baseJsPaths = [`d3@${"7.8.5"}/dist/d3.min.js`, `markmap-view@${"0.14.5-alpha.21"}/dist/browser/index.js`];
|
|
12
11
|
function fillTemplate(root, assets, extra) {
|
|
13
12
|
var _extra, _extra$baseJs;
|
|
14
13
|
extra = _extends({}, extra);
|
|
@@ -45,6 +44,7 @@ function fillTemplate(root, assets, extra) {
|
|
|
45
44
|
return html;
|
|
46
45
|
}
|
|
47
46
|
|
|
47
|
+
const name$3 = 'katex';
|
|
48
48
|
function getConfig$1() {
|
|
49
49
|
const preloadScripts = [`katex@${"0.16.8"}/dist/katex.min.js`].map(path => buildJSItem(path));
|
|
50
50
|
const webfontloader = buildJSItem(`webfontloader@${"1.6.28"}/webfontloader.js`);
|
|
@@ -97,7 +97,6 @@ function definePlugin(plugin) {
|
|
|
97
97
|
return plugin;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
const name$3 = 'katex';
|
|
101
100
|
var katex = definePlugin(() => {
|
|
102
101
|
const plugin = {
|
|
103
102
|
name: name$3,
|
|
@@ -125,57 +124,9 @@ var katex = definePlugin(() => {
|
|
|
125
124
|
return plugin;
|
|
126
125
|
});
|
|
127
126
|
|
|
128
|
-
|
|
129
|
-
const preloadScripts = [`prismjs@${"1.29.0"}/components/prism-core.min.js`, `prismjs@${"1.29.0"}/plugins/autoloader/prism-autoloader.min.js`].map(path => buildJSItem(path));
|
|
130
|
-
const styles = [`prismjs@${"1.29.0"}/themes/prism.css`].map(path => buildCSSItem(path));
|
|
131
|
-
return {
|
|
132
|
-
versions: {
|
|
133
|
-
prismjs: "1.29.0"
|
|
134
|
-
},
|
|
135
|
-
preloadScripts,
|
|
136
|
-
styles
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const name$2 = 'prism';
|
|
141
|
-
var prism = definePlugin(() => {
|
|
142
|
-
const plugin = {
|
|
143
|
-
name: name$2,
|
|
144
|
-
config: getConfig(),
|
|
145
|
-
transform(transformHooks) {
|
|
146
|
-
let enableFeature = noop;
|
|
147
|
-
transformHooks.parser.tap(md => {
|
|
148
|
-
md.set({
|
|
149
|
-
highlight: (str, lang) => {
|
|
150
|
-
enableFeature();
|
|
151
|
-
let grammar = Prism.languages[lang];
|
|
152
|
-
if (!grammar && lang) {
|
|
153
|
-
loadLanguages([lang]);
|
|
154
|
-
grammar = Prism.languages[lang];
|
|
155
|
-
}
|
|
156
|
-
if (grammar) {
|
|
157
|
-
return Prism.highlight(str, grammar, lang);
|
|
158
|
-
}
|
|
159
|
-
return '';
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
transformHooks.beforeParse.tap((_, context) => {
|
|
164
|
-
enableFeature = () => {
|
|
165
|
-
context.features[name$2] = true;
|
|
166
|
-
};
|
|
167
|
-
});
|
|
168
|
-
return {
|
|
169
|
-
styles: plugin.config.styles
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
return plugin;
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const name$1 = 'frontmatter';
|
|
127
|
+
const name$2 = 'frontmatter';
|
|
177
128
|
var frontmatter = definePlugin({
|
|
178
|
-
name: name$
|
|
129
|
+
name: name$2,
|
|
179
130
|
transform(transformHooks) {
|
|
180
131
|
transformHooks.beforeParse.tap((md, context) => {
|
|
181
132
|
const {
|
|
@@ -223,9 +174,9 @@ function normalizeNumber(value) {
|
|
|
223
174
|
return +value;
|
|
224
175
|
}
|
|
225
176
|
|
|
226
|
-
const name = 'npmUrl';
|
|
177
|
+
const name$1 = 'npmUrl';
|
|
227
178
|
var npmUrl = definePlugin({
|
|
228
|
-
name,
|
|
179
|
+
name: name$1,
|
|
229
180
|
transform(transformHooks) {
|
|
230
181
|
transformHooks.afterParse.tap((_, context) => {
|
|
231
182
|
const {
|
|
@@ -250,7 +201,44 @@ var npmUrl = definePlugin({
|
|
|
250
201
|
}
|
|
251
202
|
});
|
|
252
203
|
|
|
253
|
-
const
|
|
204
|
+
const name = 'hljs';
|
|
205
|
+
function getConfig() {
|
|
206
|
+
const styles = [`highlight.js@${"11.8.0"}/styles/default.css`].map(path => buildCSSItem(path));
|
|
207
|
+
return {
|
|
208
|
+
versions: {
|
|
209
|
+
hljs: "11.8.0"
|
|
210
|
+
},
|
|
211
|
+
styles
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
var hljs = definePlugin(() => {
|
|
215
|
+
const plugin = {
|
|
216
|
+
name,
|
|
217
|
+
config: getConfig(),
|
|
218
|
+
transform(transformHooks) {
|
|
219
|
+
let enableFeature = noop;
|
|
220
|
+
transformHooks.parser.tap(md => {
|
|
221
|
+
md.set({
|
|
222
|
+
highlight: (str, language) => {
|
|
223
|
+
enableFeature();
|
|
224
|
+
return hljs$1.highlightAuto(str, language ? [language] : undefined).value;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
transformHooks.beforeParse.tap((_, context) => {
|
|
229
|
+
enableFeature = () => {
|
|
230
|
+
context.features[name] = true;
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
return {
|
|
234
|
+
styles: plugin.config.styles
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
return plugin;
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const plugins = [frontmatter, katex, hljs, npmUrl];
|
|
254
242
|
|
|
255
243
|
function cleanNode(node) {
|
|
256
244
|
if (node.type === 'heading') {
|
|
@@ -395,10 +383,7 @@ class Transformer {
|
|
|
395
383
|
revoke();
|
|
396
384
|
current.content = `${current.content || ''}${text}`;
|
|
397
385
|
} else if (token.type === 'fence') {
|
|
398
|
-
|
|
399
|
-
// Remarkable only adds className to `<code>` but not `<pre>`, copy it to make PrismJS style work.
|
|
400
|
-
const matches = result.match(/<code( class="[^"]*")>/);
|
|
401
|
-
if (matches) result = result.replace('<pre>', `<pre${matches[1]}>`);
|
|
386
|
+
const result = md.renderer.render([token], md.options, {});
|
|
402
387
|
current.children.push({
|
|
403
388
|
type: token.type,
|
|
404
389
|
depth: depth + 1,
|
|
@@ -459,7 +444,7 @@ class Transformer {
|
|
|
459
444
|
}
|
|
460
445
|
|
|
461
446
|
const transformerVersions = {
|
|
462
|
-
'markmap-lib': '0.14.5-alpha.
|
|
447
|
+
'markmap-lib': '0.14.5-alpha.21+fb81f2c',
|
|
463
448
|
d3: "7.8.5"
|
|
464
449
|
};
|
|
465
450
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.14.5-alpha.
|
|
3
|
+
"version": "0.14.5-alpha.21+fb81f2c",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,12 +47,13 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/remarkable": "^2.0.3",
|
|
50
|
-
"markmap-common": "0.14.5-alpha.
|
|
51
|
-
"markmap-view": "0.14.5-alpha.
|
|
50
|
+
"markmap-common": "0.14.5-alpha.21+fb81f2c",
|
|
51
|
+
"markmap-view": "0.14.5-alpha.21+fb81f2c",
|
|
52
52
|
"webfontloader": "^1.6.28"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/runtime": "^7.22.6",
|
|
56
|
+
"highlight.js": "^11.8.0",
|
|
56
57
|
"js-yaml": "^4.1.0",
|
|
57
58
|
"katex": "^0.16.8",
|
|
58
59
|
"prismjs": "^1.29.0",
|
|
@@ -62,5 +63,5 @@
|
|
|
62
63
|
"peerDependencies": {
|
|
63
64
|
"markmap-common": "*"
|
|
64
65
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "fb81f2cb688f400f17f911774539267219f639ce"
|
|
66
67
|
}
|