markmap-lib 0.18.0 → 0.18.1-alpha.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.iife.js +33 -8
- package/dist/browser/index.mjs +33 -8
- package/dist/index.d.ts +2 -1
- package/dist/index.js +22 -5
- package/dist/index.mjs +22 -5
- package/dist/index.no-plugins.js +22 -5
- package/dist/index.no-plugins.mjs +22 -5
- package/dist/plugins.js +11 -3
- package/dist/plugins.mjs +11 -3
- package/dist/transform.d.ts +4 -1
- package/dist/types.d.ts +4 -2
- package/package.json +2 -2
|
@@ -25274,8 +25274,10 @@ ${end2.comment}` : end2.comment;
|
|
|
25274
25274
|
...context.parserOptions,
|
|
25275
25275
|
...(_a2 = frontmatter == null ? void 0 : frontmatter.markmap) == null ? void 0 : _a2.htmlParser
|
|
25276
25276
|
};
|
|
25277
|
-
context.
|
|
25278
|
-
|
|
25277
|
+
context.frontmatterInfo = {
|
|
25278
|
+
lines: content.slice(0, match.index).split("\n").length + 1,
|
|
25279
|
+
offset: match.index + match[0].length
|
|
25280
|
+
};
|
|
25279
25281
|
});
|
|
25280
25282
|
return {};
|
|
25281
25283
|
}
|
|
@@ -25969,13 +25971,19 @@ ${end2.comment}` : end2.comment;
|
|
|
25969
25971
|
const plugin = definePlugin({
|
|
25970
25972
|
name,
|
|
25971
25973
|
transform(transformHooks) {
|
|
25974
|
+
let frontmatterLines = 0;
|
|
25975
|
+
transformHooks.beforeParse.tap((_md, context) => {
|
|
25976
|
+
var _a2;
|
|
25977
|
+
frontmatterLines = ((_a2 = context.frontmatterInfo) == null ? void 0 : _a2.lines) || 0;
|
|
25978
|
+
});
|
|
25972
25979
|
transformHooks.parser.tap((md) => {
|
|
25973
25980
|
md.renderer.renderAttrs = wrapFunction(
|
|
25974
25981
|
md.renderer.renderAttrs,
|
|
25975
25982
|
(renderAttrs, token) => {
|
|
25976
25983
|
let attrs = renderAttrs(token);
|
|
25977
25984
|
if (token.block && token.map) {
|
|
25978
|
-
|
|
25985
|
+
const lineRange = token.map.map((line) => line + frontmatterLines);
|
|
25986
|
+
attrs += ` data-lines=${lineRange.join(",")}`;
|
|
25979
25987
|
}
|
|
25980
25988
|
return attrs;
|
|
25981
25989
|
}
|
|
@@ -26030,16 +26038,24 @@ ${end2.comment}` : end2.comment;
|
|
|
26030
26038
|
const context = {
|
|
26031
26039
|
content,
|
|
26032
26040
|
features: {},
|
|
26033
|
-
contentLineOffset: 0,
|
|
26034
26041
|
parserOptions: fallbackParserOptions
|
|
26035
26042
|
};
|
|
26036
26043
|
this.hooks.beforeParse.call(this.md, context);
|
|
26037
|
-
|
|
26044
|
+
let { content: rawContent } = context;
|
|
26045
|
+
if (context.frontmatterInfo)
|
|
26046
|
+
rawContent = rawContent.slice(context.frontmatterInfo.offset);
|
|
26047
|
+
const html2 = this.md.render(rawContent, {});
|
|
26038
26048
|
this.hooks.afterParse.call(this.md, context);
|
|
26039
26049
|
const root2 = cleanNode(buildTree(html2, context.parserOptions));
|
|
26040
26050
|
root2.content || (root2.content = `${((_a2 = context.frontmatter) == null ? void 0 : _a2.title) || ""}`);
|
|
26041
26051
|
return { ...context, root: root2 };
|
|
26042
26052
|
}
|
|
26053
|
+
resolveJS(item) {
|
|
26054
|
+
return patchJSItem(this.urlBuilder, item);
|
|
26055
|
+
}
|
|
26056
|
+
resolveCSS(item) {
|
|
26057
|
+
return patchCSSItem(this.urlBuilder, item);
|
|
26058
|
+
}
|
|
26043
26059
|
/**
|
|
26044
26060
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
26045
26061
|
*/
|
|
@@ -26054,10 +26070,17 @@ ${end2.comment}` : end2.comment;
|
|
|
26054
26070
|
}
|
|
26055
26071
|
}
|
|
26056
26072
|
return {
|
|
26057
|
-
styles: styles2.map((item) =>
|
|
26058
|
-
scripts: scripts.map((item) =>
|
|
26073
|
+
styles: styles2.map((item) => this.resolveCSS(item)),
|
|
26074
|
+
scripts: scripts.map((item) => this.resolveJS(item))
|
|
26059
26075
|
};
|
|
26060
26076
|
}
|
|
26077
|
+
getPreloadScripts() {
|
|
26078
|
+
const scripts = this.plugins.flatMap((plugin2) => {
|
|
26079
|
+
var _a2;
|
|
26080
|
+
return ((_a2 = plugin2.config) == null ? void 0 : _a2.preloadScripts) || [];
|
|
26081
|
+
}).map((item) => this.resolveJS(item));
|
|
26082
|
+
return { scripts };
|
|
26083
|
+
}
|
|
26061
26084
|
/**
|
|
26062
26085
|
* Get used assets by features object returned by `transform`.
|
|
26063
26086
|
*/
|
|
@@ -26067,10 +26090,12 @@ ${end2.comment}` : end2.comment;
|
|
|
26067
26090
|
}
|
|
26068
26091
|
}
|
|
26069
26092
|
const transformerVersions = {
|
|
26070
|
-
"markmap-lib": "0.18.
|
|
26093
|
+
"markmap-lib": "0.18.1-alpha.1"
|
|
26071
26094
|
};
|
|
26072
26095
|
exports.Transformer = Transformer;
|
|
26073
26096
|
exports.builtInPlugins = builtInPlugins;
|
|
26097
|
+
exports.patchCSSItem = patchCSSItem;
|
|
26098
|
+
exports.patchJSItem = patchJSItem;
|
|
26074
26099
|
exports.transformerVersions = transformerVersions;
|
|
26075
26100
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
26076
26101
|
})(this.markmap = this.markmap || {}, window.katex);
|
package/dist/browser/index.mjs
CHANGED
|
@@ -85,8 +85,10 @@ const pluginFrontmatter = definePlugin({
|
|
|
85
85
|
...context.parserOptions,
|
|
86
86
|
...(_a = frontmatter == null ? void 0 : frontmatter.markmap) == null ? void 0 : _a.htmlParser
|
|
87
87
|
};
|
|
88
|
-
context.
|
|
89
|
-
|
|
88
|
+
context.frontmatterInfo = {
|
|
89
|
+
lines: content.slice(0, match.index).split("\n").length + 1,
|
|
90
|
+
offset: match.index + match[0].length
|
|
91
|
+
};
|
|
90
92
|
});
|
|
91
93
|
return {};
|
|
92
94
|
}
|
|
@@ -358,13 +360,19 @@ const name = "sourceLines";
|
|
|
358
360
|
const plugin = definePlugin({
|
|
359
361
|
name,
|
|
360
362
|
transform(transformHooks) {
|
|
363
|
+
let frontmatterLines = 0;
|
|
364
|
+
transformHooks.beforeParse.tap((_md, context) => {
|
|
365
|
+
var _a;
|
|
366
|
+
frontmatterLines = ((_a = context.frontmatterInfo) == null ? void 0 : _a.lines) || 0;
|
|
367
|
+
});
|
|
361
368
|
transformHooks.parser.tap((md) => {
|
|
362
369
|
md.renderer.renderAttrs = wrapFunction(
|
|
363
370
|
md.renderer.renderAttrs,
|
|
364
371
|
(renderAttrs, token) => {
|
|
365
372
|
let attrs = renderAttrs(token);
|
|
366
373
|
if (token.block && token.map) {
|
|
367
|
-
|
|
374
|
+
const lineRange = token.map.map((line) => line + frontmatterLines);
|
|
375
|
+
attrs += ` data-lines=${lineRange.join(",")}`;
|
|
368
376
|
}
|
|
369
377
|
return attrs;
|
|
370
378
|
}
|
|
@@ -419,16 +427,24 @@ class Transformer {
|
|
|
419
427
|
const context = {
|
|
420
428
|
content,
|
|
421
429
|
features: {},
|
|
422
|
-
contentLineOffset: 0,
|
|
423
430
|
parserOptions: fallbackParserOptions
|
|
424
431
|
};
|
|
425
432
|
this.hooks.beforeParse.call(this.md, context);
|
|
426
|
-
|
|
433
|
+
let { content: rawContent } = context;
|
|
434
|
+
if (context.frontmatterInfo)
|
|
435
|
+
rawContent = rawContent.slice(context.frontmatterInfo.offset);
|
|
436
|
+
const html = this.md.render(rawContent, {});
|
|
427
437
|
this.hooks.afterParse.call(this.md, context);
|
|
428
438
|
const root = cleanNode(buildTree(html, context.parserOptions));
|
|
429
439
|
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
430
440
|
return { ...context, root };
|
|
431
441
|
}
|
|
442
|
+
resolveJS(item) {
|
|
443
|
+
return patchJSItem(this.urlBuilder, item);
|
|
444
|
+
}
|
|
445
|
+
resolveCSS(item) {
|
|
446
|
+
return patchCSSItem(this.urlBuilder, item);
|
|
447
|
+
}
|
|
432
448
|
/**
|
|
433
449
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
434
450
|
*/
|
|
@@ -443,10 +459,17 @@ class Transformer {
|
|
|
443
459
|
}
|
|
444
460
|
}
|
|
445
461
|
return {
|
|
446
|
-
styles: styles2.map((item) =>
|
|
447
|
-
scripts: scripts.map((item) =>
|
|
462
|
+
styles: styles2.map((item) => this.resolveCSS(item)),
|
|
463
|
+
scripts: scripts.map((item) => this.resolveJS(item))
|
|
448
464
|
};
|
|
449
465
|
}
|
|
466
|
+
getPreloadScripts() {
|
|
467
|
+
const scripts = this.plugins.flatMap((plugin2) => {
|
|
468
|
+
var _a;
|
|
469
|
+
return ((_a = plugin2.config) == null ? void 0 : _a.preloadScripts) || [];
|
|
470
|
+
}).map((item) => this.resolveJS(item));
|
|
471
|
+
return { scripts };
|
|
472
|
+
}
|
|
450
473
|
/**
|
|
451
474
|
* Get used assets by features object returned by `transform`.
|
|
452
475
|
*/
|
|
@@ -456,10 +479,12 @@ class Transformer {
|
|
|
456
479
|
}
|
|
457
480
|
}
|
|
458
481
|
const transformerVersions = {
|
|
459
|
-
"markmap-lib": "0.18.
|
|
482
|
+
"markmap-lib": "0.18.1-alpha.1"
|
|
460
483
|
};
|
|
461
484
|
export {
|
|
462
485
|
Transformer,
|
|
463
486
|
builtInPlugins,
|
|
487
|
+
patchCSSItem,
|
|
488
|
+
patchJSItem,
|
|
464
489
|
transformerVersions
|
|
465
490
|
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -78,16 +78,24 @@ class Transformer {
|
|
|
78
78
|
const context = {
|
|
79
79
|
content,
|
|
80
80
|
features: {},
|
|
81
|
-
contentLineOffset: 0,
|
|
82
81
|
parserOptions: fallbackParserOptions
|
|
83
82
|
};
|
|
84
83
|
this.hooks.beforeParse.call(this.md, context);
|
|
85
|
-
|
|
84
|
+
let { content: rawContent } = context;
|
|
85
|
+
if (context.frontmatterInfo)
|
|
86
|
+
rawContent = rawContent.slice(context.frontmatterInfo.offset);
|
|
87
|
+
const html = this.md.render(rawContent, {});
|
|
86
88
|
this.hooks.afterParse.call(this.md, context);
|
|
87
89
|
const root = cleanNode(markmapHtmlParser.buildTree(html, context.parserOptions));
|
|
88
90
|
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
89
91
|
return { ...context, root };
|
|
90
92
|
}
|
|
93
|
+
resolveJS(item) {
|
|
94
|
+
return patchJSItem(this.urlBuilder, item);
|
|
95
|
+
}
|
|
96
|
+
resolveCSS(item) {
|
|
97
|
+
return patchCSSItem(this.urlBuilder, item);
|
|
98
|
+
}
|
|
91
99
|
/**
|
|
92
100
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
93
101
|
*/
|
|
@@ -102,10 +110,17 @@ class Transformer {
|
|
|
102
110
|
}
|
|
103
111
|
}
|
|
104
112
|
return {
|
|
105
|
-
styles: styles.map((item) =>
|
|
106
|
-
scripts: scripts.map((item) =>
|
|
113
|
+
styles: styles.map((item) => this.resolveCSS(item)),
|
|
114
|
+
scripts: scripts.map((item) => this.resolveJS(item))
|
|
107
115
|
};
|
|
108
116
|
}
|
|
117
|
+
getPreloadScripts() {
|
|
118
|
+
const scripts = this.plugins.flatMap((plugin) => {
|
|
119
|
+
var _a;
|
|
120
|
+
return ((_a = plugin.config) == null ? void 0 : _a.preloadScripts) || [];
|
|
121
|
+
}).map((item) => this.resolveJS(item));
|
|
122
|
+
return { scripts };
|
|
123
|
+
}
|
|
109
124
|
/**
|
|
110
125
|
* Get used assets by features object returned by `transform`.
|
|
111
126
|
*/
|
|
@@ -115,8 +130,10 @@ class Transformer {
|
|
|
115
130
|
}
|
|
116
131
|
}
|
|
117
132
|
const transformerVersions = {
|
|
118
|
-
"markmap-lib": "0.18.
|
|
133
|
+
"markmap-lib": "0.18.1-alpha.1"
|
|
119
134
|
};
|
|
120
135
|
exports.Transformer = Transformer;
|
|
121
136
|
exports.builtInPlugins = builtInPlugins;
|
|
137
|
+
exports.patchCSSItem = patchCSSItem;
|
|
138
|
+
exports.patchJSItem = patchJSItem;
|
|
122
139
|
exports.transformerVersions = transformerVersions;
|
package/dist/index.mjs
CHANGED
|
@@ -76,16 +76,24 @@ class Transformer {
|
|
|
76
76
|
const context = {
|
|
77
77
|
content,
|
|
78
78
|
features: {},
|
|
79
|
-
contentLineOffset: 0,
|
|
80
79
|
parserOptions: fallbackParserOptions
|
|
81
80
|
};
|
|
82
81
|
this.hooks.beforeParse.call(this.md, context);
|
|
83
|
-
|
|
82
|
+
let { content: rawContent } = context;
|
|
83
|
+
if (context.frontmatterInfo)
|
|
84
|
+
rawContent = rawContent.slice(context.frontmatterInfo.offset);
|
|
85
|
+
const html = this.md.render(rawContent, {});
|
|
84
86
|
this.hooks.afterParse.call(this.md, context);
|
|
85
87
|
const root = cleanNode(buildTree(html, context.parserOptions));
|
|
86
88
|
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
87
89
|
return { ...context, root };
|
|
88
90
|
}
|
|
91
|
+
resolveJS(item) {
|
|
92
|
+
return patchJSItem(this.urlBuilder, item);
|
|
93
|
+
}
|
|
94
|
+
resolveCSS(item) {
|
|
95
|
+
return patchCSSItem(this.urlBuilder, item);
|
|
96
|
+
}
|
|
89
97
|
/**
|
|
90
98
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
91
99
|
*/
|
|
@@ -100,10 +108,17 @@ class Transformer {
|
|
|
100
108
|
}
|
|
101
109
|
}
|
|
102
110
|
return {
|
|
103
|
-
styles: styles.map((item) =>
|
|
104
|
-
scripts: scripts.map((item) =>
|
|
111
|
+
styles: styles.map((item) => this.resolveCSS(item)),
|
|
112
|
+
scripts: scripts.map((item) => this.resolveJS(item))
|
|
105
113
|
};
|
|
106
114
|
}
|
|
115
|
+
getPreloadScripts() {
|
|
116
|
+
const scripts = this.plugins.flatMap((plugin) => {
|
|
117
|
+
var _a;
|
|
118
|
+
return ((_a = plugin.config) == null ? void 0 : _a.preloadScripts) || [];
|
|
119
|
+
}).map((item) => this.resolveJS(item));
|
|
120
|
+
return { scripts };
|
|
121
|
+
}
|
|
107
122
|
/**
|
|
108
123
|
* Get used assets by features object returned by `transform`.
|
|
109
124
|
*/
|
|
@@ -113,10 +128,12 @@ class Transformer {
|
|
|
113
128
|
}
|
|
114
129
|
}
|
|
115
130
|
const transformerVersions = {
|
|
116
|
-
"markmap-lib": "0.18.
|
|
131
|
+
"markmap-lib": "0.18.1-alpha.1"
|
|
117
132
|
};
|
|
118
133
|
export {
|
|
119
134
|
Transformer,
|
|
120
135
|
builtInPlugins,
|
|
136
|
+
patchCSSItem,
|
|
137
|
+
patchJSItem,
|
|
121
138
|
transformerVersions
|
|
122
139
|
};
|
package/dist/index.no-plugins.js
CHANGED
|
@@ -86,16 +86,24 @@ class Transformer {
|
|
|
86
86
|
const context = {
|
|
87
87
|
content,
|
|
88
88
|
features: {},
|
|
89
|
-
contentLineOffset: 0,
|
|
90
89
|
parserOptions: fallbackParserOptions
|
|
91
90
|
};
|
|
92
91
|
this.hooks.beforeParse.call(this.md, context);
|
|
93
|
-
|
|
92
|
+
let { content: rawContent } = context;
|
|
93
|
+
if (context.frontmatterInfo)
|
|
94
|
+
rawContent = rawContent.slice(context.frontmatterInfo.offset);
|
|
95
|
+
const html = this.md.render(rawContent, {});
|
|
94
96
|
this.hooks.afterParse.call(this.md, context);
|
|
95
97
|
const root = cleanNode(markmapHtmlParser.buildTree(html, context.parserOptions));
|
|
96
98
|
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
97
99
|
return { ...context, root };
|
|
98
100
|
}
|
|
101
|
+
resolveJS(item) {
|
|
102
|
+
return patchJSItem(this.urlBuilder, item);
|
|
103
|
+
}
|
|
104
|
+
resolveCSS(item) {
|
|
105
|
+
return patchCSSItem(this.urlBuilder, item);
|
|
106
|
+
}
|
|
99
107
|
/**
|
|
100
108
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
101
109
|
*/
|
|
@@ -110,10 +118,17 @@ class Transformer {
|
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
return {
|
|
113
|
-
styles: styles.map((item) =>
|
|
114
|
-
scripts: scripts.map((item) =>
|
|
121
|
+
styles: styles.map((item) => this.resolveCSS(item)),
|
|
122
|
+
scripts: scripts.map((item) => this.resolveJS(item))
|
|
115
123
|
};
|
|
116
124
|
}
|
|
125
|
+
getPreloadScripts() {
|
|
126
|
+
const scripts = this.plugins.flatMap((plugin) => {
|
|
127
|
+
var _a;
|
|
128
|
+
return ((_a = plugin.config) == null ? void 0 : _a.preloadScripts) || [];
|
|
129
|
+
}).map((item) => this.resolveJS(item));
|
|
130
|
+
return { scripts };
|
|
131
|
+
}
|
|
117
132
|
/**
|
|
118
133
|
* Get used assets by features object returned by `transform`.
|
|
119
134
|
*/
|
|
@@ -123,8 +138,10 @@ class Transformer {
|
|
|
123
138
|
}
|
|
124
139
|
}
|
|
125
140
|
const transformerVersions = {
|
|
126
|
-
"markmap-lib": "0.18.
|
|
141
|
+
"markmap-lib": "0.18.1-alpha.1"
|
|
127
142
|
};
|
|
128
143
|
exports.Transformer = Transformer;
|
|
129
144
|
exports.builtInPlugins = builtInPlugins;
|
|
145
|
+
exports.patchCSSItem = patchCSSItem;
|
|
146
|
+
exports.patchJSItem = patchJSItem;
|
|
130
147
|
exports.transformerVersions = transformerVersions;
|
|
@@ -84,16 +84,24 @@ class Transformer {
|
|
|
84
84
|
const context = {
|
|
85
85
|
content,
|
|
86
86
|
features: {},
|
|
87
|
-
contentLineOffset: 0,
|
|
88
87
|
parserOptions: fallbackParserOptions
|
|
89
88
|
};
|
|
90
89
|
this.hooks.beforeParse.call(this.md, context);
|
|
91
|
-
|
|
90
|
+
let { content: rawContent } = context;
|
|
91
|
+
if (context.frontmatterInfo)
|
|
92
|
+
rawContent = rawContent.slice(context.frontmatterInfo.offset);
|
|
93
|
+
const html = this.md.render(rawContent, {});
|
|
92
94
|
this.hooks.afterParse.call(this.md, context);
|
|
93
95
|
const root = cleanNode(buildTree(html, context.parserOptions));
|
|
94
96
|
root.content || (root.content = `${((_a = context.frontmatter) == null ? void 0 : _a.title) || ""}`);
|
|
95
97
|
return { ...context, root };
|
|
96
98
|
}
|
|
99
|
+
resolveJS(item) {
|
|
100
|
+
return patchJSItem(this.urlBuilder, item);
|
|
101
|
+
}
|
|
102
|
+
resolveCSS(item) {
|
|
103
|
+
return patchCSSItem(this.urlBuilder, item);
|
|
104
|
+
}
|
|
97
105
|
/**
|
|
98
106
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
99
107
|
*/
|
|
@@ -108,10 +116,17 @@ class Transformer {
|
|
|
108
116
|
}
|
|
109
117
|
}
|
|
110
118
|
return {
|
|
111
|
-
styles: styles.map((item) =>
|
|
112
|
-
scripts: scripts.map((item) =>
|
|
119
|
+
styles: styles.map((item) => this.resolveCSS(item)),
|
|
120
|
+
scripts: scripts.map((item) => this.resolveJS(item))
|
|
113
121
|
};
|
|
114
122
|
}
|
|
123
|
+
getPreloadScripts() {
|
|
124
|
+
const scripts = this.plugins.flatMap((plugin) => {
|
|
125
|
+
var _a;
|
|
126
|
+
return ((_a = plugin.config) == null ? void 0 : _a.preloadScripts) || [];
|
|
127
|
+
}).map((item) => this.resolveJS(item));
|
|
128
|
+
return { scripts };
|
|
129
|
+
}
|
|
115
130
|
/**
|
|
116
131
|
* Get used assets by features object returned by `transform`.
|
|
117
132
|
*/
|
|
@@ -121,10 +136,12 @@ class Transformer {
|
|
|
121
136
|
}
|
|
122
137
|
}
|
|
123
138
|
const transformerVersions = {
|
|
124
|
-
"markmap-lib": "0.18.
|
|
139
|
+
"markmap-lib": "0.18.1-alpha.1"
|
|
125
140
|
};
|
|
126
141
|
export {
|
|
127
142
|
Transformer,
|
|
128
143
|
builtInPlugins,
|
|
144
|
+
patchCSSItem,
|
|
145
|
+
patchJSItem,
|
|
129
146
|
transformerVersions
|
|
130
147
|
};
|
package/dist/plugins.js
CHANGED
|
@@ -74,8 +74,10 @@ const pluginFrontmatter = definePlugin({
|
|
|
74
74
|
...context.parserOptions,
|
|
75
75
|
...(_a = frontmatter == null ? void 0 : frontmatter.markmap) == null ? void 0 : _a.htmlParser
|
|
76
76
|
};
|
|
77
|
-
context.
|
|
78
|
-
|
|
77
|
+
context.frontmatterInfo = {
|
|
78
|
+
lines: content.slice(0, match.index).split("\n").length + 1,
|
|
79
|
+
offset: match.index + match[0].length
|
|
80
|
+
};
|
|
79
81
|
});
|
|
80
82
|
return {};
|
|
81
83
|
}
|
|
@@ -255,13 +257,19 @@ const name = "sourceLines";
|
|
|
255
257
|
const plugin = definePlugin({
|
|
256
258
|
name,
|
|
257
259
|
transform(transformHooks) {
|
|
260
|
+
let frontmatterLines = 0;
|
|
261
|
+
transformHooks.beforeParse.tap((_md, context) => {
|
|
262
|
+
var _a;
|
|
263
|
+
frontmatterLines = ((_a = context.frontmatterInfo) == null ? void 0 : _a.lines) || 0;
|
|
264
|
+
});
|
|
258
265
|
transformHooks.parser.tap((md) => {
|
|
259
266
|
md.renderer.renderAttrs = markmapCommon.wrapFunction(
|
|
260
267
|
md.renderer.renderAttrs,
|
|
261
268
|
(renderAttrs, token) => {
|
|
262
269
|
let attrs = renderAttrs(token);
|
|
263
270
|
if (token.block && token.map) {
|
|
264
|
-
|
|
271
|
+
const lineRange = token.map.map((line) => line + frontmatterLines);
|
|
272
|
+
attrs += ` data-lines=${lineRange.join(",")}`;
|
|
265
273
|
}
|
|
266
274
|
return attrs;
|
|
267
275
|
}
|
package/dist/plugins.mjs
CHANGED
|
@@ -72,8 +72,10 @@ const pluginFrontmatter = definePlugin({
|
|
|
72
72
|
...context.parserOptions,
|
|
73
73
|
...(_a = frontmatter == null ? void 0 : frontmatter.markmap) == null ? void 0 : _a.htmlParser
|
|
74
74
|
};
|
|
75
|
-
context.
|
|
76
|
-
|
|
75
|
+
context.frontmatterInfo = {
|
|
76
|
+
lines: content.slice(0, match.index).split("\n").length + 1,
|
|
77
|
+
offset: match.index + match[0].length
|
|
78
|
+
};
|
|
77
79
|
});
|
|
78
80
|
return {};
|
|
79
81
|
}
|
|
@@ -253,13 +255,19 @@ const name = "sourceLines";
|
|
|
253
255
|
const plugin = definePlugin({
|
|
254
256
|
name,
|
|
255
257
|
transform(transformHooks) {
|
|
258
|
+
let frontmatterLines = 0;
|
|
259
|
+
transformHooks.beforeParse.tap((_md, context) => {
|
|
260
|
+
var _a;
|
|
261
|
+
frontmatterLines = ((_a = context.frontmatterInfo) == null ? void 0 : _a.lines) || 0;
|
|
262
|
+
});
|
|
256
263
|
transformHooks.parser.tap((md) => {
|
|
257
264
|
md.renderer.renderAttrs = wrapFunction(
|
|
258
265
|
md.renderer.renderAttrs,
|
|
259
266
|
(renderAttrs, token) => {
|
|
260
267
|
let attrs = renderAttrs(token);
|
|
261
268
|
if (token.block && token.map) {
|
|
262
|
-
|
|
269
|
+
const lineRange = token.map.map((line) => line + frontmatterLines);
|
|
270
|
+
attrs += ` data-lines=${lineRange.join(",")}`;
|
|
263
271
|
}
|
|
264
272
|
return attrs;
|
|
265
273
|
}
|
package/dist/transform.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type MarkdownIt from 'markdown-it';
|
|
2
|
-
import { UrlBuilder } from 'markmap-common';
|
|
2
|
+
import { CSSItem, JSItem, UrlBuilder } from 'markmap-common';
|
|
3
3
|
import { IHtmlParserOptions } from 'markmap-html-parser';
|
|
4
4
|
import { IAssets, IFeatures, ITransformHooks, ITransformPlugin, ITransformResult, ITransformer } from './types';
|
|
5
5
|
export declare const builtInPlugins: ITransformPlugin[];
|
|
@@ -11,10 +11,13 @@ export declare class Transformer implements ITransformer {
|
|
|
11
11
|
plugins: ITransformPlugin[];
|
|
12
12
|
constructor(plugins?: Array<ITransformPlugin | (() => ITransformPlugin)>);
|
|
13
13
|
transform(content: string, fallbackParserOptions?: Partial<IHtmlParserOptions>): ITransformResult;
|
|
14
|
+
resolveJS(item: JSItem): JSItem;
|
|
15
|
+
resolveCSS(item: CSSItem): CSSItem;
|
|
14
16
|
/**
|
|
15
17
|
* Get all assets from enabled plugins or filter them by plugin names as keys.
|
|
16
18
|
*/
|
|
17
19
|
getAssets(keys?: string[]): IAssets;
|
|
20
|
+
getPreloadScripts(): IAssets;
|
|
18
21
|
/**
|
|
19
22
|
* Get used assets by features object returned by `transform`.
|
|
20
23
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -52,8 +52,10 @@ export interface ITransformContext {
|
|
|
52
52
|
title?: string;
|
|
53
53
|
markmap?: IMarkmapJSONOptions;
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
frontmatterInfo?: {
|
|
56
|
+
lines: number;
|
|
57
|
+
offset: number;
|
|
58
|
+
};
|
|
57
59
|
parserOptions?: Partial<IHtmlParserOptions>;
|
|
58
60
|
}
|
|
59
61
|
export interface ITransformResult extends ITransformContext {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-lib",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1-alpha.1+f00ade4",
|
|
4
4
|
"description": "Visualize your Markdown as mindmaps with Markmap",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"^(.*\\.svg)\\?raw$": "$1"
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "f00ade49c4b34f9c34579e67cd185ad29afd6950"
|
|
100
100
|
}
|