markmap-lib 0.15.9-alpha.5 → 0.15.9-alpha.6

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.
@@ -3,7 +3,7 @@
3
3
  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';
4
4
  const baseJsPaths = [
5
5
  `d3@${"7.8.5"}/dist/d3.min.js`,
6
- `markmap-view@${"0.15.9-alpha.5"}/dist/browser/index.js`
6
+ `markmap-view@${"0.15.9-alpha.6"}/dist/browser/index.js`
7
7
  ];
8
8
  const svg_marked = `<svg width="16" height="16" fill="currentColor" viewBox="0 -3 24 24"><path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"/></svg>`;
9
9
  const svg_unmarked = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 -3 24 24"><path fill-rule="evenodd" d="M6 5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1zM3 6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-5z" clip-rule="evenodd"/></svg>`;
@@ -14115,14 +14115,18 @@
14115
14115
  const $el = elMap[node.id];
14116
14116
  $el.contents().each((_, child) => {
14117
14117
  if (child.type === "comment") {
14118
- const data2 = child.data.trim();
14119
- if (data2.startsWith(MARKMAP_COMMENT_PREFIX)) {
14118
+ const data22 = child.data.trim();
14119
+ if (data22.startsWith(MARKMAP_COMMENT_PREFIX)) {
14120
14120
  node.comments || (node.comments = []);
14121
- node.comments.push(data2.slice(MARKMAP_COMMENT_PREFIX.length).trim());
14121
+ node.comments.push(data22.slice(MARKMAP_COMMENT_PREFIX.length).trim());
14122
14122
  $2(child).remove();
14123
14123
  }
14124
14124
  }
14125
14125
  });
14126
+ const data2 = $el.data();
14127
+ if (data2 && Object.keys(data2).length) {
14128
+ node.data = data2;
14129
+ }
14126
14130
  node.html = (($el.is(options.selectorPreserveTag) ? $2.html($el) : $el.html()) || "").trimEnd();
14127
14131
  });
14128
14132
  return rootNode;
@@ -14204,11 +14208,16 @@
14204
14208
  content: htmlNode.html,
14205
14209
  children: next2() || []
14206
14210
  };
14211
+ if (htmlNode.data) {
14212
+ node.payload = {
14213
+ ...htmlNode.data
14214
+ };
14215
+ }
14207
14216
  if (htmlNode.comments) {
14208
14217
  if (htmlNode.comments.includes("foldAll")) {
14209
- node.payload = { fold: 2 };
14218
+ node.payload = { ...node.payload, fold: 2 };
14210
14219
  } else if (htmlNode.comments.includes("fold")) {
14211
- node.payload = { fold: 1 };
14220
+ node.payload = { ...node.payload, fold: 1 };
14212
14221
  }
14213
14222
  }
14214
14223
  return node;
@@ -18025,229 +18034,6 @@
18025
18034
  env = env || {};
18026
18035
  return this.renderer.render(this.parseInline(str2, env), this.options, env);
18027
18036
  };
18028
- const rkatex = (md, options) => {
18029
- const backslash = "\\";
18030
- const dollar = "$";
18031
- const opts = options || {};
18032
- const delimiter = opts.delimiter || dollar;
18033
- if (delimiter.length !== 1) {
18034
- throw new Error("invalid delimiter");
18035
- }
18036
- const katex = require$$0;
18037
- const renderKatex = (source, displayMode) => katex.renderToString(
18038
- source,
18039
- {
18040
- displayMode,
18041
- throwOnError: false
18042
- }
18043
- );
18044
- const parseBlockKatex = (state, startLine, endLine) => {
18045
- let haveEndMarker = false;
18046
- let pos = state.bMarks[startLine] + state.tShift[startLine];
18047
- let max = state.eMarks[startLine];
18048
- if (pos + 1 > max) {
18049
- return false;
18050
- }
18051
- const marker = state.src.charAt(pos);
18052
- if (marker !== delimiter) {
18053
- return false;
18054
- }
18055
- let mem = pos;
18056
- pos = state.skipChars(pos, marker);
18057
- let len = pos - mem;
18058
- if (len !== 2) {
18059
- return false;
18060
- }
18061
- let nextLine = startLine;
18062
- for (; ; ) {
18063
- ++nextLine;
18064
- if (nextLine >= endLine) {
18065
- break;
18066
- }
18067
- pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
18068
- max = state.eMarks[nextLine];
18069
- if (pos < max && state.tShift[nextLine] < state.blkIndent) {
18070
- break;
18071
- }
18072
- if (state.src.charAt(pos) !== delimiter) {
18073
- continue;
18074
- }
18075
- if (state.tShift[nextLine] - state.blkIndent >= 4) {
18076
- continue;
18077
- }
18078
- pos = state.skipChars(pos, marker);
18079
- if (pos - mem < len) {
18080
- continue;
18081
- }
18082
- pos = state.skipSpaces(pos);
18083
- if (pos < max) {
18084
- continue;
18085
- }
18086
- haveEndMarker = true;
18087
- break;
18088
- }
18089
- len = state.tShift[startLine];
18090
- state.line = nextLine + (haveEndMarker ? 1 : 0);
18091
- const content = state.getLines(startLine + 1, nextLine, len, true).replace(/[ \n]+/g, " ").trim();
18092
- state.tokens.push({
18093
- type: "katex",
18094
- params: null,
18095
- content,
18096
- lines: [startLine, state.line],
18097
- level: state.level,
18098
- block: true
18099
- });
18100
- return true;
18101
- };
18102
- const parseInlineKatex = (state, silent) => {
18103
- const start = state.pos;
18104
- const max = state.posMax;
18105
- let pos = start;
18106
- if (state.src.charAt(pos) !== delimiter) {
18107
- return false;
18108
- }
18109
- ++pos;
18110
- while (pos < max && state.src.charAt(pos) === delimiter) {
18111
- ++pos;
18112
- }
18113
- const marker = state.src.slice(start, pos);
18114
- if (marker.length > 2) {
18115
- return false;
18116
- }
18117
- const spanStart = pos;
18118
- let escapedDepth = 0;
18119
- while (pos < max) {
18120
- const char = state.src.charAt(pos);
18121
- if (char === "{" && (pos == 0 || state.src.charAt(pos - 1) != backslash)) {
18122
- escapedDepth += 1;
18123
- } else if (char === "}" && (pos == 0 || state.src.charAt(pos - 1) != backslash)) {
18124
- escapedDepth -= 1;
18125
- if (escapedDepth < 0) {
18126
- return false;
18127
- }
18128
- } else if (char === delimiter && escapedDepth === 0) {
18129
- const matchStart = pos;
18130
- let matchEnd = pos + 1;
18131
- while (matchEnd < max && state.src.charAt(matchEnd) === delimiter) {
18132
- ++matchEnd;
18133
- }
18134
- if (matchEnd - matchStart === marker.length) {
18135
- if (!silent) {
18136
- const content = state.src.slice(spanStart, matchStart).replace(/[ \n]+/g, " ").trim();
18137
- state.push({ type: "katex", content, block: marker.length > 1, level: state.level });
18138
- }
18139
- state.pos = matchEnd;
18140
- return true;
18141
- }
18142
- }
18143
- pos += 1;
18144
- }
18145
- if (!silent) {
18146
- state.pending += marker;
18147
- }
18148
- state.pos += marker.length;
18149
- return true;
18150
- };
18151
- md.inline.ruler.push("katex", parseInlineKatex, options);
18152
- md.block.ruler.push("katex", parseBlockKatex, options);
18153
- md.renderer.rules.katex = (tokens, idx) => renderKatex(tokens[idx].content, tokens[idx].block);
18154
- md.renderer.rules.katex.delimiter = delimiter;
18155
- };
18156
- var remarkableKatex = rkatex;
18157
- const remarkableKatex$1 = /* @__PURE__ */ getDefaultExportFromCjs(remarkableKatex);
18158
- const name$4 = "katex";
18159
- const preloadScripts$1 = [
18160
- `katex@${"0.16.8"}/dist/katex.min.js`
18161
- ].map((path) => buildJSItem(path));
18162
- const webfontloader = buildJSItem(
18163
- `webfontloader@${"1.6.28"}/webfontloader.js`
18164
- );
18165
- webfontloader.data.defer = true;
18166
- const styles$1 = [`katex@${"0.16.8"}/dist/katex.min.css`].map(
18167
- (path) => buildCSSItem(path)
18168
- );
18169
- const config$1 = {
18170
- versions: {
18171
- katex: "0.16.8",
18172
- webfontloader: "1.6.28"
18173
- },
18174
- preloadScripts: preloadScripts$1,
18175
- scripts: [
18176
- {
18177
- type: "iife",
18178
- data: {
18179
- fn: (getMarkmap) => {
18180
- window.WebFontConfig = {
18181
- custom: {
18182
- families: [
18183
- "KaTeX_AMS",
18184
- "KaTeX_Caligraphic:n4,n7",
18185
- "KaTeX_Fraktur:n4,n7",
18186
- "KaTeX_Main:n4,n7,i4,i7",
18187
- "KaTeX_Math:i4,i7",
18188
- "KaTeX_Script",
18189
- "KaTeX_SansSerif:n4,n7,i4",
18190
- "KaTeX_Size1",
18191
- "KaTeX_Size2",
18192
- "KaTeX_Size3",
18193
- "KaTeX_Size4",
18194
- "KaTeX_Typewriter"
18195
- ]
18196
- },
18197
- active: () => {
18198
- getMarkmap().refreshHook.call();
18199
- }
18200
- };
18201
- },
18202
- getParams({ getMarkmap }) {
18203
- return [getMarkmap];
18204
- }
18205
- }
18206
- },
18207
- webfontloader
18208
- ],
18209
- styles: styles$1
18210
- };
18211
- function addDefaultVersions(paths, name2, version) {
18212
- return paths.map((path) => {
18213
- if (typeof path === "string" && !path.includes("://")) {
18214
- if (!path.startsWith("npm:")) {
18215
- path = `npm:${path}`;
18216
- }
18217
- const prefixLength = 4 + name2.length;
18218
- if (path.startsWith(`npm:${name2}/`)) {
18219
- path = `${path.slice(0, prefixLength)}@${version}${path.slice(
18220
- prefixLength
18221
- )}`;
18222
- }
18223
- }
18224
- return path;
18225
- });
18226
- }
18227
- function patchJSItem(urlBuilder, item) {
18228
- if (item.type === "script" && item.data.src) {
18229
- return {
18230
- ...item,
18231
- data: {
18232
- ...item.data,
18233
- src: urlBuilder.getFullUrl(item.data.src)
18234
- }
18235
- };
18236
- }
18237
- return item;
18238
- }
18239
- function patchCSSItem(urlBuilder, item) {
18240
- if (item.type === "stylesheet" && item.data.href) {
18241
- return {
18242
- ...item,
18243
- data: {
18244
- ...item.data,
18245
- href: urlBuilder.getFullUrl(item.data.href)
18246
- }
18247
- };
18248
- }
18249
- return item;
18250
- }
18251
18037
  function createTransformHooks(transformer) {
18252
18038
  return {
18253
18039
  transformer,
@@ -18261,67 +18047,35 @@
18261
18047
  function definePlugin(plugin2) {
18262
18048
  return plugin2;
18263
18049
  }
18264
- const plugin$2 = definePlugin({
18265
- name: name$4,
18266
- config: config$1,
18050
+ const name$5 = "checkbox";
18051
+ const plugin$3 = definePlugin({
18052
+ name: name$5,
18267
18053
  transform(transformHooks) {
18268
- var _a2, _b, _c, _d;
18269
- let loading;
18270
- const preloadScripts2 = ((_b = (_a2 = plugin$2.config) == null ? void 0 : _a2.preloadScripts) == null ? void 0 : _b.map(
18271
- (item) => patchJSItem(transformHooks.transformer.urlBuilder, item)
18272
- )) || [];
18273
- const autoload = () => {
18274
- loading || (loading = loadJS(preloadScripts2));
18275
- return loading;
18276
- };
18277
- const renderKatex = (source, displayMode) => {
18278
- const { katex } = window;
18279
- if (katex) {
18280
- return katex.renderToString(source, {
18281
- displayMode,
18282
- throwOnError: false
18283
- });
18284
- }
18285
- autoload().then(() => {
18286
- transformHooks.retransform.call();
18287
- });
18288
- return source;
18289
- };
18290
- let enableFeature = noop;
18291
18054
  transformHooks.parser.tap((md) => {
18292
- md.use(remarkableKatex$1);
18293
- md.renderer.rules.katex = (tokens, idx) => {
18294
- enableFeature();
18295
- const result = renderKatex(tokens[idx].content, !!tokens[idx].block);
18296
- return result;
18297
- };
18298
- });
18299
- transformHooks.beforeParse.tap((_, context) => {
18300
- enableFeature = () => {
18301
- context.features[name$4] = true;
18302
- };
18303
- });
18304
- transformHooks.afterParse.tap((_, context) => {
18305
- var _a3;
18306
- const markmap = (_a3 = context.frontmatter) == null ? void 0 : _a3.markmap;
18307
- if (markmap) {
18308
- ["extraJs", "extraCss"].forEach((key) => {
18309
- var _a4, _b2;
18310
- const value = markmap[key];
18311
- if (value) {
18312
- markmap[key] = addDefaultVersions(
18313
- value,
18314
- name$4,
18315
- ((_b2 = (_a4 = plugin$2.config) == null ? void 0 : _a4.versions) == null ? void 0 : _b2.katex) || ""
18316
- );
18055
+ md.core.ruler.before(
18056
+ "inline",
18057
+ "checkbox",
18058
+ (state) => {
18059
+ for (let i2 = 2; i2 < state.tokens.length; i2 += 1) {
18060
+ const token = state.tokens[i2];
18061
+ if (token.type === "inline" && token.content) {
18062
+ const prevType = state.tokens[i2 - 1].type;
18063
+ const prevPrevType = state.tokens[i2 - 2].type;
18064
+ if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
18065
+ if (token.content.startsWith("[ ]")) {
18066
+ token.content = `${svg_unmarked} ${token.content.slice(3)}`;
18067
+ } else if (token.content.startsWith("[x]")) {
18068
+ token.content = `${svg_marked} ${token.content.slice(3)}`;
18069
+ }
18070
+ }
18071
+ }
18317
18072
  }
18318
- });
18319
- }
18073
+ return false;
18074
+ },
18075
+ {}
18076
+ );
18320
18077
  });
18321
- return {
18322
- styles: (_c = plugin$2.config) == null ? void 0 : _c.styles,
18323
- scripts: (_d = plugin$2.config) == null ? void 0 : _d.scripts
18324
- };
18078
+ return {};
18325
18079
  }
18326
18080
  });
18327
18081
  /*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
@@ -21012,9 +20766,9 @@
21012
20766
  safeLoadAll,
21013
20767
  safeDump
21014
20768
  };
21015
- const name$3 = "frontmatter";
20769
+ const name$4 = "frontmatter";
21016
20770
  const frontmatter = definePlugin({
21017
- name: name$3,
20771
+ name: name$4,
21018
20772
  transform(transformHooks) {
21019
20773
  transformHooks.beforeParse.tap((md, context) => {
21020
20774
  const { content } = context;
@@ -21068,54 +20822,52 @@
21068
20822
  return;
21069
20823
  return +value;
21070
20824
  }
21071
- const name$2 = "npmUrl";
21072
- const npmUrl = definePlugin({
21073
- name: name$2,
21074
- transform(transformHooks) {
21075
- transformHooks.afterParse.tap((_, context) => {
21076
- const { frontmatter: frontmatter2 } = context;
21077
- const markmap = frontmatter2 == null ? void 0 : frontmatter2.markmap;
21078
- if (markmap) {
21079
- ["extraJs", "extraCss"].forEach((key) => {
21080
- const value = markmap[key];
21081
- if (value) {
21082
- markmap[key] = value.map((path) => {
21083
- if (path.startsWith("npm:")) {
21084
- return transformHooks.transformer.urlBuilder.getFullUrl(
21085
- path.slice(4)
21086
- );
21087
- }
21088
- return path;
21089
- });
21090
- }
21091
- });
20825
+ function patchJSItem(urlBuilder, item) {
20826
+ if (item.type === "script" && item.data.src) {
20827
+ return {
20828
+ ...item,
20829
+ data: {
20830
+ ...item.data,
20831
+ src: urlBuilder.getFullUrl(item.data.src)
21092
20832
  }
21093
- });
21094
- return {};
20833
+ };
21095
20834
  }
21096
- });
21097
- const name$1 = "hljs";
21098
- const preloadScripts = [
20835
+ return item;
20836
+ }
20837
+ function patchCSSItem(urlBuilder, item) {
20838
+ if (item.type === "stylesheet" && item.data.href) {
20839
+ return {
20840
+ ...item,
20841
+ data: {
20842
+ ...item.data,
20843
+ href: urlBuilder.getFullUrl(item.data.href)
20844
+ }
20845
+ };
20846
+ }
20847
+ return item;
20848
+ }
20849
+ const name$3 = "hljs";
20850
+ const preloadScripts$1 = [
21099
20851
  `@highlightjs/cdn-assets@${"11.8.0"}/highlight.min.js`
21100
20852
  ].map((path) => buildJSItem(path));
21101
- const styles = [
20853
+ const styles$1 = [
21102
20854
  `@highlightjs/cdn-assets@${"11.8.0"}/styles/default.min.css`
21103
20855
  // `highlight.js@${process.env.HLJS_VERSION}/styles/default.css`,
21104
20856
  ].map((path) => buildCSSItem(path));
21105
- const config = {
20857
+ const config$1 = {
21106
20858
  versions: {
21107
20859
  hljs: "11.8.0"
21108
20860
  },
21109
- preloadScripts,
21110
- styles
20861
+ preloadScripts: preloadScripts$1,
20862
+ styles: styles$1
21111
20863
  };
21112
- const plugin$1 = definePlugin({
21113
- name: name$1,
21114
- config,
20864
+ const plugin$2 = definePlugin({
20865
+ name: name$3,
20866
+ config: config$1,
21115
20867
  transform(transformHooks) {
21116
20868
  var _a2, _b, _c;
21117
20869
  let loading;
21118
- const preloadScripts2 = ((_b = (_a2 = plugin$1.config) == null ? void 0 : _a2.preloadScripts) == null ? void 0 : _b.map(
20870
+ const preloadScripts2 = ((_b = (_a2 = plugin$2.config) == null ? void 0 : _a2.preloadScripts) == null ? void 0 : _b.map(
21119
20871
  (item) => patchJSItem(transformHooks.transformer.urlBuilder, item)
21120
20872
  )) || [];
21121
20873
  const autoload = () => {
@@ -21140,46 +20892,341 @@
21140
20892
  });
21141
20893
  transformHooks.beforeParse.tap((_, context) => {
21142
20894
  enableFeature = () => {
21143
- context.features[name$1] = true;
20895
+ context.features[name$3] = true;
21144
20896
  };
21145
20897
  });
21146
20898
  return {
21147
- styles: (_c = plugin$1.config) == null ? void 0 : _c.styles
20899
+ styles: (_c = plugin$2.config) == null ? void 0 : _c.styles
21148
20900
  };
21149
20901
  }
21150
20902
  });
21151
- const name = "checkbox";
21152
- const plugin = definePlugin({
21153
- name,
20903
+ const rkatex = (md, options) => {
20904
+ const backslash = "\\";
20905
+ const dollar = "$";
20906
+ const opts = options || {};
20907
+ const delimiter = opts.delimiter || dollar;
20908
+ if (delimiter.length !== 1) {
20909
+ throw new Error("invalid delimiter");
20910
+ }
20911
+ const katex = require$$0;
20912
+ const renderKatex = (source, displayMode) => katex.renderToString(
20913
+ source,
20914
+ {
20915
+ displayMode,
20916
+ throwOnError: false
20917
+ }
20918
+ );
20919
+ const parseBlockKatex = (state, startLine, endLine) => {
20920
+ let haveEndMarker = false;
20921
+ let pos = state.bMarks[startLine] + state.tShift[startLine];
20922
+ let max = state.eMarks[startLine];
20923
+ if (pos + 1 > max) {
20924
+ return false;
20925
+ }
20926
+ const marker = state.src.charAt(pos);
20927
+ if (marker !== delimiter) {
20928
+ return false;
20929
+ }
20930
+ let mem = pos;
20931
+ pos = state.skipChars(pos, marker);
20932
+ let len = pos - mem;
20933
+ if (len !== 2) {
20934
+ return false;
20935
+ }
20936
+ let nextLine = startLine;
20937
+ for (; ; ) {
20938
+ ++nextLine;
20939
+ if (nextLine >= endLine) {
20940
+ break;
20941
+ }
20942
+ pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
20943
+ max = state.eMarks[nextLine];
20944
+ if (pos < max && state.tShift[nextLine] < state.blkIndent) {
20945
+ break;
20946
+ }
20947
+ if (state.src.charAt(pos) !== delimiter) {
20948
+ continue;
20949
+ }
20950
+ if (state.tShift[nextLine] - state.blkIndent >= 4) {
20951
+ continue;
20952
+ }
20953
+ pos = state.skipChars(pos, marker);
20954
+ if (pos - mem < len) {
20955
+ continue;
20956
+ }
20957
+ pos = state.skipSpaces(pos);
20958
+ if (pos < max) {
20959
+ continue;
20960
+ }
20961
+ haveEndMarker = true;
20962
+ break;
20963
+ }
20964
+ len = state.tShift[startLine];
20965
+ state.line = nextLine + (haveEndMarker ? 1 : 0);
20966
+ const content = state.getLines(startLine + 1, nextLine, len, true).replace(/[ \n]+/g, " ").trim();
20967
+ state.tokens.push({
20968
+ type: "katex",
20969
+ params: null,
20970
+ content,
20971
+ lines: [startLine, state.line],
20972
+ level: state.level,
20973
+ block: true
20974
+ });
20975
+ return true;
20976
+ };
20977
+ const parseInlineKatex = (state, silent) => {
20978
+ const start = state.pos;
20979
+ const max = state.posMax;
20980
+ let pos = start;
20981
+ if (state.src.charAt(pos) !== delimiter) {
20982
+ return false;
20983
+ }
20984
+ ++pos;
20985
+ while (pos < max && state.src.charAt(pos) === delimiter) {
20986
+ ++pos;
20987
+ }
20988
+ const marker = state.src.slice(start, pos);
20989
+ if (marker.length > 2) {
20990
+ return false;
20991
+ }
20992
+ const spanStart = pos;
20993
+ let escapedDepth = 0;
20994
+ while (pos < max) {
20995
+ const char = state.src.charAt(pos);
20996
+ if (char === "{" && (pos == 0 || state.src.charAt(pos - 1) != backslash)) {
20997
+ escapedDepth += 1;
20998
+ } else if (char === "}" && (pos == 0 || state.src.charAt(pos - 1) != backslash)) {
20999
+ escapedDepth -= 1;
21000
+ if (escapedDepth < 0) {
21001
+ return false;
21002
+ }
21003
+ } else if (char === delimiter && escapedDepth === 0) {
21004
+ const matchStart = pos;
21005
+ let matchEnd = pos + 1;
21006
+ while (matchEnd < max && state.src.charAt(matchEnd) === delimiter) {
21007
+ ++matchEnd;
21008
+ }
21009
+ if (matchEnd - matchStart === marker.length) {
21010
+ if (!silent) {
21011
+ const content = state.src.slice(spanStart, matchStart).replace(/[ \n]+/g, " ").trim();
21012
+ state.push({ type: "katex", content, block: marker.length > 1, level: state.level });
21013
+ }
21014
+ state.pos = matchEnd;
21015
+ return true;
21016
+ }
21017
+ }
21018
+ pos += 1;
21019
+ }
21020
+ if (!silent) {
21021
+ state.pending += marker;
21022
+ }
21023
+ state.pos += marker.length;
21024
+ return true;
21025
+ };
21026
+ md.inline.ruler.push("katex", parseInlineKatex, options);
21027
+ md.block.ruler.push("katex", parseBlockKatex, options);
21028
+ md.renderer.rules.katex = (tokens, idx) => renderKatex(tokens[idx].content, tokens[idx].block);
21029
+ md.renderer.rules.katex.delimiter = delimiter;
21030
+ };
21031
+ var remarkableKatex = rkatex;
21032
+ const remarkableKatex$1 = /* @__PURE__ */ getDefaultExportFromCjs(remarkableKatex);
21033
+ const name$2 = "katex";
21034
+ const preloadScripts = [
21035
+ `katex@${"0.16.8"}/dist/katex.min.js`
21036
+ ].map((path) => buildJSItem(path));
21037
+ const webfontloader = buildJSItem(
21038
+ `webfontloader@${"1.6.28"}/webfontloader.js`
21039
+ );
21040
+ webfontloader.data.defer = true;
21041
+ const styles = [`katex@${"0.16.8"}/dist/katex.min.css`].map(
21042
+ (path) => buildCSSItem(path)
21043
+ );
21044
+ const config = {
21045
+ versions: {
21046
+ katex: "0.16.8",
21047
+ webfontloader: "1.6.28"
21048
+ },
21049
+ preloadScripts,
21050
+ scripts: [
21051
+ {
21052
+ type: "iife",
21053
+ data: {
21054
+ fn: (getMarkmap) => {
21055
+ window.WebFontConfig = {
21056
+ custom: {
21057
+ families: [
21058
+ "KaTeX_AMS",
21059
+ "KaTeX_Caligraphic:n4,n7",
21060
+ "KaTeX_Fraktur:n4,n7",
21061
+ "KaTeX_Main:n4,n7,i4,i7",
21062
+ "KaTeX_Math:i4,i7",
21063
+ "KaTeX_Script",
21064
+ "KaTeX_SansSerif:n4,n7,i4",
21065
+ "KaTeX_Size1",
21066
+ "KaTeX_Size2",
21067
+ "KaTeX_Size3",
21068
+ "KaTeX_Size4",
21069
+ "KaTeX_Typewriter"
21070
+ ]
21071
+ },
21072
+ active: () => {
21073
+ getMarkmap().refreshHook.call();
21074
+ }
21075
+ };
21076
+ },
21077
+ getParams({ getMarkmap }) {
21078
+ return [getMarkmap];
21079
+ }
21080
+ }
21081
+ },
21082
+ webfontloader
21083
+ ],
21084
+ styles
21085
+ };
21086
+ function addDefaultVersions(paths, name2, version) {
21087
+ return paths.map((path) => {
21088
+ if (typeof path === "string" && !path.includes("://")) {
21089
+ if (!path.startsWith("npm:")) {
21090
+ path = `npm:${path}`;
21091
+ }
21092
+ const prefixLength = 4 + name2.length;
21093
+ if (path.startsWith(`npm:${name2}/`)) {
21094
+ path = `${path.slice(0, prefixLength)}@${version}${path.slice(
21095
+ prefixLength
21096
+ )}`;
21097
+ }
21098
+ }
21099
+ return path;
21100
+ });
21101
+ }
21102
+ const plugin$1 = definePlugin({
21103
+ name: name$2,
21104
+ config,
21154
21105
  transform(transformHooks) {
21106
+ var _a2, _b, _c, _d;
21107
+ let loading;
21108
+ const preloadScripts2 = ((_b = (_a2 = plugin$1.config) == null ? void 0 : _a2.preloadScripts) == null ? void 0 : _b.map(
21109
+ (item) => patchJSItem(transformHooks.transformer.urlBuilder, item)
21110
+ )) || [];
21111
+ const autoload = () => {
21112
+ loading || (loading = loadJS(preloadScripts2));
21113
+ return loading;
21114
+ };
21115
+ const renderKatex = (source, displayMode) => {
21116
+ const { katex } = window;
21117
+ if (katex) {
21118
+ return katex.renderToString(source, {
21119
+ displayMode,
21120
+ throwOnError: false
21121
+ });
21122
+ }
21123
+ autoload().then(() => {
21124
+ transformHooks.retransform.call();
21125
+ });
21126
+ return source;
21127
+ };
21128
+ let enableFeature = noop;
21155
21129
  transformHooks.parser.tap((md) => {
21156
- md.core.ruler.before(
21157
- "inline",
21158
- "checkbox",
21159
- (state) => {
21160
- for (let i2 = 2; i2 < state.tokens.length; i2 += 1) {
21161
- const token = state.tokens[i2];
21162
- if (token.type === "inline" && token.content) {
21163
- const prevType = state.tokens[i2 - 1].type;
21164
- const prevPrevType = state.tokens[i2 - 2].type;
21165
- if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
21166
- if (token.content.startsWith("[ ]")) {
21167
- token.content = `${svg_unmarked} ${token.content.slice(3)}`;
21168
- } else if (token.content.startsWith("[x]")) {
21169
- token.content = `${svg_marked} ${token.content.slice(3)}`;
21170
- }
21130
+ md.use(remarkableKatex$1);
21131
+ md.renderer.rules.katex = (tokens, idx) => {
21132
+ enableFeature();
21133
+ const result = renderKatex(tokens[idx].content, !!tokens[idx].block);
21134
+ return result;
21135
+ };
21136
+ });
21137
+ transformHooks.beforeParse.tap((_, context) => {
21138
+ enableFeature = () => {
21139
+ context.features[name$2] = true;
21140
+ };
21141
+ });
21142
+ transformHooks.afterParse.tap((_, context) => {
21143
+ var _a3;
21144
+ const markmap = (_a3 = context.frontmatter) == null ? void 0 : _a3.markmap;
21145
+ if (markmap) {
21146
+ ["extraJs", "extraCss"].forEach((key) => {
21147
+ var _a4, _b2;
21148
+ const value = markmap[key];
21149
+ if (value) {
21150
+ markmap[key] = addDefaultVersions(
21151
+ value,
21152
+ name$2,
21153
+ ((_b2 = (_a4 = plugin$1.config) == null ? void 0 : _a4.versions) == null ? void 0 : _b2.katex) || ""
21154
+ );
21155
+ }
21156
+ });
21157
+ }
21158
+ });
21159
+ return {
21160
+ styles: (_c = plugin$1.config) == null ? void 0 : _c.styles,
21161
+ scripts: (_d = plugin$1.config) == null ? void 0 : _d.scripts
21162
+ };
21163
+ }
21164
+ });
21165
+ const name$1 = "npmUrl";
21166
+ const npmUrl = definePlugin({
21167
+ name: name$1,
21168
+ transform(transformHooks) {
21169
+ transformHooks.afterParse.tap((_, context) => {
21170
+ const { frontmatter: frontmatter2 } = context;
21171
+ const markmap = frontmatter2 == null ? void 0 : frontmatter2.markmap;
21172
+ if (markmap) {
21173
+ ["extraJs", "extraCss"].forEach((key) => {
21174
+ const value = markmap[key];
21175
+ if (value) {
21176
+ markmap[key] = value.map((path) => {
21177
+ if (path.startsWith("npm:")) {
21178
+ return transformHooks.transformer.urlBuilder.getFullUrl(
21179
+ path.slice(4)
21180
+ );
21171
21181
  }
21172
- }
21182
+ return path;
21183
+ });
21173
21184
  }
21174
- return false;
21175
- },
21176
- {}
21177
- );
21185
+ });
21186
+ }
21187
+ });
21188
+ return {};
21189
+ }
21190
+ });
21191
+ const name = "sourceLines";
21192
+ const plugin = definePlugin({
21193
+ name,
21194
+ transform(transformHooks) {
21195
+ transformHooks.parser.tap((md) => {
21196
+ Object.entries(md.renderer.rules).forEach(([key, value]) => {
21197
+ if (typeof value === "function") {
21198
+ md.renderer.rules[key] = patchRule(value);
21199
+ } else {
21200
+ Object.entries(value).forEach(([k, v]) => {
21201
+ value[k] = patchRule(v);
21202
+ });
21203
+ }
21204
+ });
21178
21205
  });
21179
21206
  return {};
21180
21207
  }
21181
21208
  });
21182
- const plugins = [frontmatter, plugin$2, plugin$1, npmUrl, plugin];
21209
+ function patchRule(rule) {
21210
+ return wrapFunction(rule, (render2, tokens, idx, ...rest) => {
21211
+ let html2 = render2(tokens, idx, ...rest);
21212
+ const { lines } = tokens[idx];
21213
+ if (lines) {
21214
+ html2 = html2.replace(
21215
+ /^<[\w-]+/,
21216
+ (m) => `${m} data-lines="${lines.join(",")}"`
21217
+ );
21218
+ }
21219
+ return html2;
21220
+ });
21221
+ }
21222
+ const plugins = [
21223
+ frontmatter,
21224
+ plugin$1,
21225
+ plugin$2,
21226
+ npmUrl,
21227
+ plugin$3,
21228
+ plugin
21229
+ ];
21183
21230
  function cleanNode(node) {
21184
21231
  while (!node.content && node.children.length === 1) {
21185
21232
  node = node.children[0];