stream-markdown-parser 0.0.58-beta.1 → 0.0.58-beta.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 +38 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8640,6 +8640,42 @@ function applyMath(md, mathOpts) {
|
|
|
8640
8640
|
return;
|
|
8641
8641
|
}
|
|
8642
8642
|
if (!text$1) return;
|
|
8643
|
+
const imageStart = text$1.indexOf("![");
|
|
8644
|
+
if (imageStart !== -1) {
|
|
8645
|
+
if (imageStart > 0) {
|
|
8646
|
+
const beforeImage = text$1.slice(0, imageStart);
|
|
8647
|
+
const t$2 = s.push("text", "", 0);
|
|
8648
|
+
t$2.content = beforeImage;
|
|
8649
|
+
s.pos = s.pos + beforeImage.length;
|
|
8650
|
+
searchPos = s.pos;
|
|
8651
|
+
}
|
|
8652
|
+
const imageMatch = text$1.slice(imageStart).match(/^!\[([^\]]*)\]\(([^)]+)\)/);
|
|
8653
|
+
if (imageMatch) {
|
|
8654
|
+
const [, alt, srcAndTitle] = imageMatch;
|
|
8655
|
+
const srcMatch = srcAndTitle.match(/^(\S+)(?:\s+"([^"]+)")?\s*$/);
|
|
8656
|
+
const src$1 = srcMatch ? srcMatch[1] : srcAndTitle;
|
|
8657
|
+
const title = srcMatch && srcMatch[2] ? srcMatch[2] : null;
|
|
8658
|
+
const token = s.push("image", "img", 0);
|
|
8659
|
+
token.attrs = [["src", src$1], ["alt", alt]];
|
|
8660
|
+
if (title) token.attrs.push(["title", title]);
|
|
8661
|
+
token.content = alt;
|
|
8662
|
+
token.children = [{
|
|
8663
|
+
type: "text",
|
|
8664
|
+
content: alt,
|
|
8665
|
+
tag: ""
|
|
8666
|
+
}];
|
|
8667
|
+
s.pos = s.pos + imageMatch[0].length;
|
|
8668
|
+
searchPos = s.pos;
|
|
8669
|
+
const remainingText = text$1.slice(imageStart + imageMatch[0].length);
|
|
8670
|
+
if (remainingText) pushText(remainingText);
|
|
8671
|
+
return;
|
|
8672
|
+
}
|
|
8673
|
+
const t$1 = s.push("text", "", 0);
|
|
8674
|
+
t$1.content = text$1;
|
|
8675
|
+
s.pos = s.pos + text$1.length;
|
|
8676
|
+
searchPos = s.pos;
|
|
8677
|
+
return;
|
|
8678
|
+
}
|
|
8643
8679
|
const t = s.push("text", "", 0);
|
|
8644
8680
|
t.content = text$1;
|
|
8645
8681
|
s.pos = s.pos + text$1.length;
|
|
@@ -8890,7 +8926,8 @@ function applyMath(md, mathOpts) {
|
|
|
8890
8926
|
}
|
|
8891
8927
|
}
|
|
8892
8928
|
if ((!allowLoading || strict) && !found) return false;
|
|
8893
|
-
|
|
8929
|
+
const hasMarkdownPrefix = /^\s*!\[/.test(content);
|
|
8930
|
+
if (!(openDelim === "$$" ? !hasMarkdownPrefix : openDelim === "[" ? isPlainBracketMathLike(content) : isMathLike(content))) return false;
|
|
8894
8931
|
const token = s.push("math_block", "math", 0);
|
|
8895
8932
|
token.content = normalizeStandaloneBackslashT(content);
|
|
8896
8933
|
token.markup = openDelim === "$$" ? "$$" : openDelim === "[" ? "[]" : "\\[\\]";
|