markmap-lib 0.15.6 → 0.15.7

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.
@@ -7223,12 +7223,12 @@
7223
7223
  transform(transformHooks) {
7224
7224
  transformHooks.beforeParse.tap((md, context) => {
7225
7225
  const { content } = context;
7226
- if (!content.startsWith("---\n"))
7226
+ if (!/^---\r?\n/.test(content))
7227
7227
  return;
7228
- const endOffset = content.indexOf("\n---\n");
7229
- if (endOffset < 0)
7228
+ const match = /\n---\r?\n/.exec(content);
7229
+ if (!match)
7230
7230
  return;
7231
- const raw = content.slice(4, endOffset);
7231
+ const raw = content.slice(4, match.index);
7232
7232
  let frontmatter2;
7233
7233
  try {
7234
7234
  frontmatter2 = jsYaml.load(raw);
@@ -7241,8 +7241,8 @@
7241
7241
  return;
7242
7242
  }
7243
7243
  context.frontmatter = frontmatter2;
7244
- context.content = content.slice(endOffset + 5);
7245
- context.contentLineOffset = content.slice(0, endOffset).split("\n").length + 1;
7244
+ context.content = content.slice(match.index + match[0].length);
7245
+ context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
7246
7246
  });
7247
7247
  return {};
7248
7248
  }
@@ -182,12 +182,12 @@ const frontmatter = definePlugin({
182
182
  transform(transformHooks) {
183
183
  transformHooks.beforeParse.tap((md, context) => {
184
184
  const { content } = context;
185
- if (!content.startsWith("---\n"))
185
+ if (!/^---\r?\n/.test(content))
186
186
  return;
187
- const endOffset = content.indexOf("\n---\n");
188
- if (endOffset < 0)
187
+ const match = /\n---\r?\n/.exec(content);
188
+ if (!match)
189
189
  return;
190
- const raw = content.slice(4, endOffset);
190
+ const raw = content.slice(4, match.index);
191
191
  let frontmatter2;
192
192
  try {
193
193
  frontmatter2 = yaml.load(raw);
@@ -200,8 +200,8 @@ const frontmatter = definePlugin({
200
200
  return;
201
201
  }
202
202
  context.frontmatter = frontmatter2;
203
- context.content = content.slice(endOffset + 5);
204
- context.contentLineOffset = content.slice(0, endOffset).split("\n").length + 1;
203
+ context.content = content.slice(match.index + match[0].length);
204
+ context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
205
205
  });
206
206
  return {};
207
207
  }
package/dist/index.js CHANGED
@@ -109,12 +109,12 @@ const frontmatter = definePlugin({
109
109
  transform(transformHooks) {
110
110
  transformHooks.beforeParse.tap((md, context) => {
111
111
  const { content } = context;
112
- if (!content.startsWith("---\n"))
112
+ if (!/^---\r?\n/.test(content))
113
113
  return;
114
- const endOffset = content.indexOf("\n---\n");
115
- if (endOffset < 0)
114
+ const match = /\n---\r?\n/.exec(content);
115
+ if (!match)
116
116
  return;
117
- const raw = content.slice(4, endOffset);
117
+ const raw = content.slice(4, match.index);
118
118
  let frontmatter2;
119
119
  try {
120
120
  frontmatter2 = yaml.load(raw);
@@ -127,8 +127,8 @@ const frontmatter = definePlugin({
127
127
  return;
128
128
  }
129
129
  context.frontmatter = frontmatter2;
130
- context.content = content.slice(endOffset + 5);
131
- context.contentLineOffset = content.slice(0, endOffset).split("\n").length + 1;
130
+ context.content = content.slice(match.index + match[0].length);
131
+ context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
132
132
  });
133
133
  return {};
134
134
  }
package/dist/index.mjs CHANGED
@@ -107,12 +107,12 @@ const frontmatter = definePlugin({
107
107
  transform(transformHooks) {
108
108
  transformHooks.beforeParse.tap((md, context) => {
109
109
  const { content } = context;
110
- if (!content.startsWith("---\n"))
110
+ if (!/^---\r?\n/.test(content))
111
111
  return;
112
- const endOffset = content.indexOf("\n---\n");
113
- if (endOffset < 0)
112
+ const match = /\n---\r?\n/.exec(content);
113
+ if (!match)
114
114
  return;
115
- const raw = content.slice(4, endOffset);
115
+ const raw = content.slice(4, match.index);
116
116
  let frontmatter2;
117
117
  try {
118
118
  frontmatter2 = yaml.load(raw);
@@ -125,8 +125,8 @@ const frontmatter = definePlugin({
125
125
  return;
126
126
  }
127
127
  context.frontmatter = frontmatter2;
128
- context.content = content.slice(endOffset + 5);
129
- context.contentLineOffset = content.slice(0, endOffset).split("\n").length + 1;
128
+ context.content = content.slice(match.index + match[0].length);
129
+ context.contentLineOffset = content.slice(0, match.index).split("\n").length + 1;
130
130
  });
131
131
  return {};
132
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markmap-lib",
3
- "version": "0.15.6",
3
+ "version": "0.15.7",
4
4
  "description": "Visualize your Markdown as mindmaps with Markmap",
5
5
  "author": "Gerald <gera2ld@live.com>",
6
6
  "license": "MIT",
@@ -73,5 +73,5 @@
73
73
  ]
74
74
  }
75
75
  },
76
- "gitHead": "7309ee74a3fed2c40a2fc37f1b5df208f25f3c3a"
76
+ "gitHead": "9d71c074d32c6912591dceb42c4381e27de05fbf"
77
77
  }