stream-markdown-parser 1.0.2 → 1.0.3

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/index.js CHANGED
@@ -13435,15 +13435,18 @@ function applyMath(md, mathOpts) {
13435
13435
  }
13436
13436
  if (!matched) return false;
13437
13437
  if (silent) return true;
13438
- if (lineText.includes(closeDelim) && lineText.indexOf(closeDelim) > openDelim.length) {
13439
- const startDelimIndex = lineText.indexOf(openDelim);
13440
- const endDelimIndex = lineText.indexOf(closeDelim, startDelimIndex + openDelim.length);
13441
- const content$1 = lineText.slice(startDelimIndex + openDelim.length, endDelimIndex);
13438
+ const startDelimIndex = lineText.indexOf(openDelim);
13439
+ const closeSearchStart = startDelimIndex + openDelim.length;
13440
+ const escapedPlainBracketCloseIndex = !strict && openDelim === "[" ? lineText.indexOf("\\]", closeSearchStart) : -1;
13441
+ const sameLineCloseDelim = escapedPlainBracketCloseIndex >= 0 ? "\\]" : closeDelim;
13442
+ const sameLineCloseIndex = escapedPlainBracketCloseIndex >= 0 ? escapedPlainBracketCloseIndex : lineText.indexOf(closeDelim, closeSearchStart);
13443
+ if (sameLineCloseIndex > openDelim.length) {
13444
+ const content$1 = lineText.slice(startDelimIndex + openDelim.length, sameLineCloseIndex);
13442
13445
  const token$1 = s.push("math_block", "math", 0);
13443
13446
  token$1.content = normalizeStandaloneBackslashT(content$1);
13444
13447
  token$1.markup = openDelim === "$$" ? "$$" : openDelim === "[" ? "[]" : "\\[\\]";
13445
13448
  token$1.map = [startLine, startLine + 1];
13446
- token$1.raw = `${openDelim}${content$1}${closeDelim}`;
13449
+ token$1.raw = `${openDelim}${content$1}${sameLineCloseDelim}`;
13447
13450
  token$1.block = true;
13448
13451
  token$1.loading = false;
13449
13452
  s.line = startLine + 1;
@@ -13465,14 +13468,26 @@ function applyMath(md, mathOpts) {
13465
13468
  const lineStart = s.bMarks[nextLine] + s.tShift[nextLine];
13466
13469
  const lineEnd = s.eMarks[nextLine];
13467
13470
  const currentLine = s.src.slice(lineStart, lineEnd);
13471
+ const currentLineTrimmed = currentLine.trim();
13472
+ if (!strict && openDelim === "[" && currentLineTrimmed === "\\]") {
13473
+ closeDelim = "\\]";
13474
+ found = true;
13475
+ break;
13476
+ }
13468
13477
  if (fallbackPlainBracketClose && currentLine.trim() === fallbackPlainBracketClose) {
13469
13478
  closeDelim = fallbackPlainBracketClose;
13470
13479
  found = true;
13471
13480
  break;
13472
13481
  }
13473
- if (currentLine.trim() === closeDelim) {
13482
+ if (currentLineTrimmed === closeDelim) {
13474
13483
  found = true;
13475
13484
  break;
13485
+ } else if (!strict && openDelim === "[" && currentLine.includes("\\]")) {
13486
+ found = true;
13487
+ const endIndex = currentLine.indexOf("\\]");
13488
+ closeDelim = "\\]";
13489
+ content += (content ? "\n" : "") + currentLine.slice(0, endIndex);
13490
+ break;
13476
13491
  } else if (currentLine.includes(closeDelim)) {
13477
13492
  found = true;
13478
13493
  const endIndex = currentLine.indexOf(closeDelim);