stream-markdown-parser 0.0.67 → 0.0.69
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.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +202 -21
- package/dist/index.js.map +1 -1
- package/package.json +14 -12
package/dist/index.d.ts
CHANGED
|
@@ -350,11 +350,7 @@ interface ParseOptions {
|
|
|
350
350
|
type PostTransformNodesHook = (nodes: ParsedNode[]) => ParsedNode[];
|
|
351
351
|
//#endregion
|
|
352
352
|
//#region src/parser/inline-parsers/index.d.ts
|
|
353
|
-
declare function parseInlineTokens(tokens: MarkdownToken[], raw?: string, pPreToken?: MarkdownToken, options?:
|
|
354
|
-
requireClosingStrong?: boolean;
|
|
355
|
-
customHtmlTags?: readonly string[];
|
|
356
|
-
validateLink?: (url: string) => boolean;
|
|
357
|
-
}): ParsedNode[];
|
|
353
|
+
declare function parseInlineTokens(tokens: MarkdownToken[], raw?: string, pPreToken?: MarkdownToken, options?: ParseOptions): ParsedNode[];
|
|
358
354
|
//#endregion
|
|
359
355
|
//#region src/parser/index.d.ts
|
|
360
356
|
declare function parseMarkdownToStructure(markdown: string, md: MarkdownIt$1, options?: ParseOptions): ParsedNode[];
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/factory.ts","../src/types.ts","../src/parser/inline-parsers/index.ts","../src/parser/index.ts","../src/config.ts","../src/findMatchingClose.ts","../src/parser/inline-parsers/fence-parser.ts","../src/plugins/containers.ts","../src/plugins/isMathLike.ts","../src/plugins/math.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;UAaiB,cAAA,SAAuB;sBAClB;;EADL,gBAAA,CAAe,EAAA,OAAA;;;;ECXf,CAAA;EAaL;AAEZ;AAMA;;EAKY,cAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EALyB;;AAQrC;AAMA;EAMiB,0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A,EAAA,MAAA;EACA,KAAA,CAAA,EAAA,CAAA,MAAA,EAAA,MAAA,CAAA,EAAA;EACA,QAAA,EA9NM,UA8NN,EAAA;;AAEA,UA7NW,SAAA,SAAkB,QA6N7B,CAAA;EACA,IAAA,EAAA,OAAA;EACA,GAAA,EAAA,MAAA;EACA,GAAA,EAAA,MAAA;EACA,KAAA,EAAA,MAAA,GAAA,IAAA;;AACW,UA3NA,iBAAA,SAA0B,QA2N1B,CAAA;EACA,IAAA,EAAA,gBAAgB;AAmCjC;AAEiB,UA7PA,gBAAA,CA8PM;EA6BX,IAAA,EAAA;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/factory.ts","../src/types.ts","../src/parser/inline-parsers/index.ts","../src/parser/index.ts","../src/config.ts","../src/findMatchingClose.ts","../src/parser/inline-parsers/fence-parser.ts","../src/plugins/containers.ts","../src/plugins/isMathLike.ts","../src/plugins/math.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;UAaiB,cAAA,SAAuB;sBAClB;;EADL,gBAAA,CAAe,EAAA,OAAA;;;;ECXf,CAAA;EAaL;AAEZ;AAMA;;EAKY,cAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EALyB;;AAQrC;AAMA;EAMiB,0BAKR,CAAA,EAAA,OAAA;AAGT;;;UAjDiB,QAAA;;EDWA,GAAA,EAAA,MAAA;;;;ACXjB;AAaA;AAEA;AAMA;;;AAAqC,KARzB,WAAA,GAAc,QAQW,GARA,MAQA,CAAA,MAAA,EAAA,OAAA,CAAA;AAAQ,UAN5B,QAAA,SAAiB,QAMW,CAAA;EAQ5B,IAAA,EAAA,MAAA;EAMA,OAAA,EAAA,MAAW;EAMX,MAAA,CAAA,EAAA,OAAS;AAQ1B;AAKiB,UAjCA,WAAA,SAAoB,QAiCU,CAAA;EAiB9B,IAAA,EAAA,SAAA;EAOA,KAAA,EAAA,MAAA;EAYL,IAAA,EAAA,MAAA;EAYK,KAAA,CAAA,EA7EP,MA6EO,C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iBA0MhD,SAAA,KAAc,yBAAuB;;;ATvXpC,iBUQD,sBAAA,CVR8B,MAAA,EAAA,OAAA,CAAA,EAAA,IAAA;iBUY9B,8BAAA,CAAA;ATMC,USkBA,kBAAA,SAA2B,cTlBG,CAAA;EAM9B,MAAA,CAAA,ESaN,KTbiB,CAAA,OAAA,CAAA;EAMX,KAAA,CAAA,ESQP,KTRgB,CAAA,CAAA,EAAA,ESQL,UTHZ,EAAA,GAAA,IALyB,CAAA;EAQjB;AAKjB;AAiBA;AAOA;EAYY,IAAA,CAAA,EAAA,CAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAoB,MAAA,CAAA,GSpCK,MTsC/B,CAAA,MACA,EAAK,MAAA,CAAA;AASX;AAKU,iBSlDM,WAAA,CTkDN,KAAA,CAAA,EAAA,MAAA,EAAA,OAAA,CAAA,ESlDmE,kBTkDnE,CAAA,ESlD0F,UTkD1F"}
|
package/dist/index.js
CHANGED
|
@@ -9499,6 +9499,41 @@ function findCodeSpanRangeAt(ranges, index) {
|
|
|
9499
9499
|
for (const range of ranges) if (index >= range[0] && index < range[1]) return range;
|
|
9500
9500
|
return null;
|
|
9501
9501
|
}
|
|
9502
|
+
function isEscapedAt(src, index) {
|
|
9503
|
+
let cursor = index - 1;
|
|
9504
|
+
let backslashes = 0;
|
|
9505
|
+
while (cursor >= 0 && src[cursor] === "\\") {
|
|
9506
|
+
backslashes++;
|
|
9507
|
+
cursor--;
|
|
9508
|
+
}
|
|
9509
|
+
return backslashes % 2 === 1;
|
|
9510
|
+
}
|
|
9511
|
+
function findNextUnescapedDollar(src, startIdx) {
|
|
9512
|
+
let searchPos = startIdx;
|
|
9513
|
+
while (searchPos < src.length) {
|
|
9514
|
+
const index = src.indexOf("$", searchPos);
|
|
9515
|
+
if (index === -1) return -1;
|
|
9516
|
+
if (isEscapedAt(src, index)) {
|
|
9517
|
+
searchPos = index + 1;
|
|
9518
|
+
continue;
|
|
9519
|
+
}
|
|
9520
|
+
return index;
|
|
9521
|
+
}
|
|
9522
|
+
return -1;
|
|
9523
|
+
}
|
|
9524
|
+
function findSingleDollarClose(src, startIdx) {
|
|
9525
|
+
let searchPos = startIdx;
|
|
9526
|
+
while (searchPos < src.length) {
|
|
9527
|
+
const index = findNextUnescapedDollar(src, searchPos);
|
|
9528
|
+
if (index === -1) return -1;
|
|
9529
|
+
if (index > 0 && src[index - 1] === "$" || index + 1 < src.length && src[index + 1] === "$") {
|
|
9530
|
+
searchPos = index + 1;
|
|
9531
|
+
continue;
|
|
9532
|
+
}
|
|
9533
|
+
return index;
|
|
9534
|
+
}
|
|
9535
|
+
return -1;
|
|
9536
|
+
}
|
|
9502
9537
|
function isLikelyCurrencyRangeDollar(content, nextChar) {
|
|
9503
9538
|
const stripped = String(content ?? "").trim();
|
|
9504
9539
|
if (!stripped) return false;
|
|
@@ -9551,7 +9586,7 @@ function applyMath(md, mathOpts) {
|
|
|
9551
9586
|
if (open === "$$" && text$1.includes("$")) {
|
|
9552
9587
|
let localPos = 0;
|
|
9553
9588
|
while (localPos < text$1.length) {
|
|
9554
|
-
const dollarIndex = text$1
|
|
9589
|
+
const dollarIndex = findNextUnescapedDollar(text$1, localPos);
|
|
9555
9590
|
if (dollarIndex === -1) {
|
|
9556
9591
|
const rest = text$1.slice(localPos);
|
|
9557
9592
|
if (rest) {
|
|
@@ -9580,7 +9615,7 @@ function applyMath(md, mathOpts) {
|
|
|
9580
9615
|
s.pos = s.pos + before.length;
|
|
9581
9616
|
searchPos = s.pos;
|
|
9582
9617
|
}
|
|
9583
|
-
const closingDollarIndex = text$1
|
|
9618
|
+
const closingDollarIndex = findSingleDollarClose(text$1, dollarIndex + 1);
|
|
9584
9619
|
if (closingDollarIndex === -1) {
|
|
9585
9620
|
const rest = text$1.slice(dollarIndex);
|
|
9586
9621
|
const t$2 = s.push("text", "", 0);
|
|
@@ -9659,6 +9694,10 @@ function applyMath(md, mathOpts) {
|
|
|
9659
9694
|
if (searchPos >= src.length) break;
|
|
9660
9695
|
const index = src.indexOf(open, searchPos);
|
|
9661
9696
|
if (index === -1) break;
|
|
9697
|
+
if (isEscapedAt(src, index)) {
|
|
9698
|
+
searchPos = index + Math.max(1, open.length);
|
|
9699
|
+
continue;
|
|
9700
|
+
}
|
|
9662
9701
|
const codeSpanAtIndex = findCodeSpanRangeAt(codeSpanRanges, index);
|
|
9663
9702
|
if (codeSpanAtIndex) {
|
|
9664
9703
|
searchPos = codeSpanAtIndex[1];
|
|
@@ -9691,7 +9730,7 @@ function applyMath(md, mathOpts) {
|
|
|
9691
9730
|
searchPos = index + 2;
|
|
9692
9731
|
continue;
|
|
9693
9732
|
}
|
|
9694
|
-
const endIdx = findMatchingClose_default(src, index + open.length, open, close);
|
|
9733
|
+
const endIdx = open === "$" ? findSingleDollarClose(src, index + open.length) : findMatchingClose_default(src, index + open.length, open, close);
|
|
9695
9734
|
if (endIdx === -1) {
|
|
9696
9735
|
const content$1 = src.slice(index + open.length);
|
|
9697
9736
|
if (content$1.includes(open)) {
|
|
@@ -9808,7 +9847,7 @@ function applyMath(md, mathOpts) {
|
|
|
9808
9847
|
let remainingPos = searchPos;
|
|
9809
9848
|
while (true) {
|
|
9810
9849
|
if (remainingPos >= src.length) break;
|
|
9811
|
-
const dollarIndex = src
|
|
9850
|
+
const dollarIndex = findNextUnescapedDollar(src, remainingPos);
|
|
9812
9851
|
if (dollarIndex === -1) break;
|
|
9813
9852
|
if (dollarIndex + 1 < src.length && src[dollarIndex + 1] === "$") {
|
|
9814
9853
|
remainingPos = dollarIndex + 2;
|
|
@@ -9818,12 +9857,8 @@ function applyMath(md, mathOpts) {
|
|
|
9818
9857
|
remainingPos = dollarIndex + 1;
|
|
9819
9858
|
continue;
|
|
9820
9859
|
}
|
|
9821
|
-
const closingDollarIndex = src
|
|
9860
|
+
const closingDollarIndex = findSingleDollarClose(src, dollarIndex + 1);
|
|
9822
9861
|
if (closingDollarIndex === -1) break;
|
|
9823
|
-
if (closingDollarIndex + 1 < src.length && src[closingDollarIndex + 1] === "$") {
|
|
9824
|
-
remainingPos = dollarIndex + 1;
|
|
9825
|
-
continue;
|
|
9826
|
-
}
|
|
9827
9862
|
const content = src.slice(dollarIndex + 1, closingDollarIndex);
|
|
9828
9863
|
const hasBacktick = content.includes("`");
|
|
9829
9864
|
const isEmpty = !content || !content.trim();
|
|
@@ -10076,6 +10111,7 @@ function parseEmphasisToken(tokens, startIndex, options) {
|
|
|
10076
10111
|
}
|
|
10077
10112
|
children.push(...parseInlineTokens(innerTokens, void 0, void 0, {
|
|
10078
10113
|
requireClosingStrong: options?.requireClosingStrong,
|
|
10114
|
+
final: options?.final,
|
|
10079
10115
|
customHtmlTags: options?.customHtmlTags,
|
|
10080
10116
|
validateLink: options?.validateLink
|
|
10081
10117
|
}));
|
|
@@ -10188,7 +10224,9 @@ function parseHighlightToken(tokens, startIndex, options) {
|
|
|
10188
10224
|
}
|
|
10189
10225
|
children.push(...parseInlineTokens(innerTokens, void 0, void 0, {
|
|
10190
10226
|
requireClosingStrong: options?.requireClosingStrong,
|
|
10191
|
-
|
|
10227
|
+
final: options?.final,
|
|
10228
|
+
customHtmlTags: options?.customHtmlTags,
|
|
10229
|
+
validateLink: options?.validateLink
|
|
10192
10230
|
}));
|
|
10193
10231
|
return {
|
|
10194
10232
|
node: {
|
|
@@ -10508,7 +10546,9 @@ function parseInsertToken(tokens, startIndex, options) {
|
|
|
10508
10546
|
}
|
|
10509
10547
|
children.push(...parseInlineTokens(innerTokens, void 0, void 0, {
|
|
10510
10548
|
requireClosingStrong: options?.requireClosingStrong,
|
|
10511
|
-
|
|
10549
|
+
final: options?.final,
|
|
10550
|
+
customHtmlTags: options?.customHtmlTags,
|
|
10551
|
+
validateLink: options?.validateLink
|
|
10512
10552
|
}));
|
|
10513
10553
|
return {
|
|
10514
10554
|
node: {
|
|
@@ -10562,7 +10602,9 @@ function parseLinkToken(tokens, startIndex, options) {
|
|
|
10562
10602
|
if (tokens[i]?.type === "link_close") loading = false;
|
|
10563
10603
|
const children = parseInlineTokens(linkTokens, void 0, void 0, {
|
|
10564
10604
|
requireClosingStrong: options?.requireClosingStrong,
|
|
10565
|
-
|
|
10605
|
+
final: options?.final,
|
|
10606
|
+
customHtmlTags: options?.customHtmlTags,
|
|
10607
|
+
validateLink: options?.validateLink
|
|
10566
10608
|
});
|
|
10567
10609
|
const linkText = children.map((node) => {
|
|
10568
10610
|
const nodeAny = node;
|
|
@@ -10622,7 +10664,9 @@ function parseStrikethroughToken(tokens, startIndex, options) {
|
|
|
10622
10664
|
}
|
|
10623
10665
|
children.push(...parseInlineTokens(innerTokens, void 0, void 0, {
|
|
10624
10666
|
requireClosingStrong: options?.requireClosingStrong,
|
|
10625
|
-
|
|
10667
|
+
final: options?.final,
|
|
10668
|
+
customHtmlTags: options?.customHtmlTags,
|
|
10669
|
+
validateLink: options?.validateLink
|
|
10626
10670
|
}));
|
|
10627
10671
|
return {
|
|
10628
10672
|
node: {
|
|
@@ -10654,6 +10698,7 @@ function parseStrongToken(tokens, startIndex, raw, options) {
|
|
|
10654
10698
|
}
|
|
10655
10699
|
children.push(...parseInlineTokens(innerTokens, raw, void 0, {
|
|
10656
10700
|
requireClosingStrong: options?.requireClosingStrong,
|
|
10701
|
+
final: options?.final,
|
|
10657
10702
|
customHtmlTags: options?.customHtmlTags,
|
|
10658
10703
|
validateLink: options?.validateLink
|
|
10659
10704
|
}));
|
|
@@ -10681,7 +10726,9 @@ function parseSubscriptToken(tokens, startIndex, options) {
|
|
|
10681
10726
|
}
|
|
10682
10727
|
children.push(...parseInlineTokens(innerTokens, void 0, void 0, {
|
|
10683
10728
|
requireClosingStrong: options?.requireClosingStrong,
|
|
10684
|
-
|
|
10729
|
+
final: options?.final,
|
|
10730
|
+
customHtmlTags: options?.customHtmlTags,
|
|
10731
|
+
validateLink: options?.validateLink
|
|
10685
10732
|
}));
|
|
10686
10733
|
const startContent = String(tokens[startIndex].content ?? "");
|
|
10687
10734
|
const display = subText || startContent;
|
|
@@ -10713,7 +10760,9 @@ function parseSuperscriptToken(tokens, startIndex, options) {
|
|
|
10713
10760
|
}
|
|
10714
10761
|
children.push(...parseInlineTokens(innerTokens, void 0, void 0, {
|
|
10715
10762
|
requireClosingStrong: options?.requireClosingStrong,
|
|
10716
|
-
|
|
10763
|
+
final: options?.final,
|
|
10764
|
+
customHtmlTags: options?.customHtmlTags,
|
|
10765
|
+
validateLink: options?.validateLink
|
|
10717
10766
|
}));
|
|
10718
10767
|
return {
|
|
10719
10768
|
node: {
|
|
@@ -10746,6 +10795,20 @@ const STRONG_PAIR_RE = /\*\*([\s\S]*?)\*\*/;
|
|
|
10746
10795
|
const STRIKETHROUGH_RE = /[^~]*~{2,}[^~]+/;
|
|
10747
10796
|
const HAS_STRONG_RE = /\*\*/;
|
|
10748
10797
|
const ESCAPED_PUNCTUATION_RE = /\\([\\()[\]`$|*_\-!])/g;
|
|
10798
|
+
const ESCAPABLE_PUNCTUATION = new Set([
|
|
10799
|
+
"\\",
|
|
10800
|
+
"(",
|
|
10801
|
+
")",
|
|
10802
|
+
"[",
|
|
10803
|
+
"]",
|
|
10804
|
+
"`",
|
|
10805
|
+
"$",
|
|
10806
|
+
"|",
|
|
10807
|
+
"*",
|
|
10808
|
+
"_",
|
|
10809
|
+
"-",
|
|
10810
|
+
"!"
|
|
10811
|
+
]);
|
|
10749
10812
|
function countUnescapedAsterisks(str) {
|
|
10750
10813
|
let count = 0;
|
|
10751
10814
|
let i = 0;
|
|
@@ -10759,6 +10822,52 @@ function countUnescapedAsterisks(str) {
|
|
|
10759
10822
|
}
|
|
10760
10823
|
return count;
|
|
10761
10824
|
}
|
|
10825
|
+
function findNextUnescapedAsterisk(rawContent, startContentIndex = 0) {
|
|
10826
|
+
if (!rawContent) return -1;
|
|
10827
|
+
let contentIndex = 0;
|
|
10828
|
+
for (let rawIndex = 0; rawIndex < rawContent.length; rawIndex++) {
|
|
10829
|
+
const char = rawContent[rawIndex];
|
|
10830
|
+
const nextChar = rawContent[rawIndex + 1];
|
|
10831
|
+
if (char === "\\" && nextChar && ESCAPABLE_PUNCTUATION.has(nextChar)) {
|
|
10832
|
+
if (nextChar === "*" && contentIndex >= startContentIndex) {
|
|
10833
|
+
contentIndex++;
|
|
10834
|
+
rawIndex++;
|
|
10835
|
+
continue;
|
|
10836
|
+
}
|
|
10837
|
+
contentIndex++;
|
|
10838
|
+
rawIndex++;
|
|
10839
|
+
continue;
|
|
10840
|
+
}
|
|
10841
|
+
if (char === "*" && contentIndex >= startContentIndex) return contentIndex;
|
|
10842
|
+
contentIndex++;
|
|
10843
|
+
}
|
|
10844
|
+
return -1;
|
|
10845
|
+
}
|
|
10846
|
+
function decodeVisibleTextFromRaw(rawText) {
|
|
10847
|
+
let output = "";
|
|
10848
|
+
let index = 0;
|
|
10849
|
+
while (index < rawText.length) {
|
|
10850
|
+
if (rawText[index] !== "\\") {
|
|
10851
|
+
output += rawText[index];
|
|
10852
|
+
index++;
|
|
10853
|
+
continue;
|
|
10854
|
+
}
|
|
10855
|
+
let slashCount = 0;
|
|
10856
|
+
while (index + slashCount < rawText.length && rawText[index + slashCount] === "\\") slashCount++;
|
|
10857
|
+
const nextChar = rawText[index + slashCount];
|
|
10858
|
+
output += "\\".repeat(Math.floor(slashCount / 2));
|
|
10859
|
+
if (slashCount % 2 === 1) {
|
|
10860
|
+
if (nextChar && ESCAPABLE_PUNCTUATION.has(nextChar)) {
|
|
10861
|
+
output += nextChar;
|
|
10862
|
+
index += slashCount + 1;
|
|
10863
|
+
continue;
|
|
10864
|
+
}
|
|
10865
|
+
output += "\\";
|
|
10866
|
+
}
|
|
10867
|
+
index += slashCount;
|
|
10868
|
+
}
|
|
10869
|
+
return output;
|
|
10870
|
+
}
|
|
10762
10871
|
const WORD_CHAR_RE = /[\p{L}\p{N}]/u;
|
|
10763
10872
|
const WORD_ONLY_RE = /^[\p{L}\p{N}]+$/u;
|
|
10764
10873
|
function isWordChar(ch) {
|
|
@@ -10949,7 +11058,9 @@ function parseInlineTokens(tokens, raw, pPreToken, options) {
|
|
|
10949
11058
|
return true;
|
|
10950
11059
|
}
|
|
10951
11060
|
if (/[^*]*\*[^*]+/.test(content)) {
|
|
10952
|
-
|
|
11061
|
+
const rawSource = tokens.length === 1 ? raw : String(token.content ?? "");
|
|
11062
|
+
let idx = rawSource ? findNextUnescapedAsterisk(rawSource, 0) : content.indexOf("*");
|
|
11063
|
+
if (rawSource && idx === -1) return false;
|
|
10953
11064
|
if (idx === -1) idx = 0;
|
|
10954
11065
|
const _text = content.slice(0, idx);
|
|
10955
11066
|
if (_text) if (currentTextNode) {
|
|
@@ -10964,8 +11075,14 @@ function parseInlineTokens(tokens, raw, pPreToken, options) {
|
|
|
10964
11075
|
result.push(currentTextNode);
|
|
10965
11076
|
}
|
|
10966
11077
|
const runInfo = getAsteriskRunInfo(content, idx);
|
|
10967
|
-
const closeIndex = content.indexOf("*", idx + 1);
|
|
10968
|
-
|
|
11078
|
+
const closeIndex = rawSource ? findNextUnescapedAsterisk(rawSource, idx + 1) : content.indexOf("*", idx + 1);
|
|
11079
|
+
const nextInlineToken = tokens[i + 1];
|
|
11080
|
+
if (options?.final && nextInlineToken?.type === "em_open" && closeIndex !== -1 && content.slice(idx + 1, closeIndex).trim() !== content.slice(idx + 1, closeIndex)) {
|
|
11081
|
+
pushText(content.slice(idx), content.slice(idx));
|
|
11082
|
+
i++;
|
|
11083
|
+
return true;
|
|
11084
|
+
}
|
|
11085
|
+
if (closeIndex === -1 && (options?.final || runInfo.intraword || !isWordChar(content[idx + 1]))) {
|
|
10969
11086
|
pushText(content.slice(idx), content.slice(idx));
|
|
10970
11087
|
i++;
|
|
10971
11088
|
return true;
|
|
@@ -11314,7 +11431,8 @@ function parseInlineTokens(tokens, raw, pPreToken, options) {
|
|
|
11314
11431
|
function handleTextToken(token) {
|
|
11315
11432
|
let index = result.length - 1;
|
|
11316
11433
|
const rawContent = String(token.content ?? "");
|
|
11317
|
-
|
|
11434
|
+
const rawSource = tokens.length === 1 && rawContent.includes("\\") && typeof raw === "string" ? String(raw) : "";
|
|
11435
|
+
let content = rawSource ? decodeVisibleTextFromRaw(rawSource) : rawContent.replace(ESCAPED_PUNCTUATION_RE, "$1");
|
|
11318
11436
|
if (token.content === "<" || content === "1" && tokens[i - 1]?.tag === "br") {
|
|
11319
11437
|
i++;
|
|
11320
11438
|
return;
|
|
@@ -11367,7 +11485,7 @@ function parseInlineTokens(tokens, raw, pPreToken, options) {
|
|
|
11367
11485
|
}
|
|
11368
11486
|
function handleLinkOpen(token) {
|
|
11369
11487
|
resetCurrentTextNode();
|
|
11370
|
-
const { node, nextIndex } = parseLinkToken(tokens, i,
|
|
11488
|
+
const { node, nextIndex } = parseLinkToken(tokens, i, options);
|
|
11371
11489
|
i = nextIndex;
|
|
11372
11490
|
if (options?.validateLink && !options.validateLink(node.href)) {
|
|
11373
11491
|
pushText(node.text, node.text);
|
|
@@ -11665,6 +11783,7 @@ function parseList(tokens, index, options) {
|
|
|
11665
11783
|
type: "paragraph",
|
|
11666
11784
|
children: parseInlineTokens(contentToken.children || [], String(contentToken.content ?? ""), preToken, {
|
|
11667
11785
|
requireClosingStrong: options?.requireClosingStrong,
|
|
11786
|
+
final: options?.final,
|
|
11668
11787
|
customHtmlTags: options?.customHtmlTags,
|
|
11669
11788
|
validateLink: options?.validateLink
|
|
11670
11789
|
}),
|
|
@@ -11723,6 +11842,7 @@ function parseAdmonition(tokens, index, match, options) {
|
|
|
11723
11842
|
type: "paragraph",
|
|
11724
11843
|
children: parseInlineTokens(contentToken.children || [], String(contentToken.content ?? ""), void 0, {
|
|
11725
11844
|
requireClosingStrong: options?.requireClosingStrong,
|
|
11845
|
+
final: options?.final,
|
|
11726
11846
|
customHtmlTags: options?.customHtmlTags,
|
|
11727
11847
|
validateLink: options?.validateLink
|
|
11728
11848
|
}),
|
|
@@ -11796,6 +11916,7 @@ function parseContainer(tokens, index, options) {
|
|
|
11796
11916
|
type: "paragraph",
|
|
11797
11917
|
children: parseInlineTokens(_children || [], void 0, void 0, {
|
|
11798
11918
|
requireClosingStrong: options?.requireClosingStrong,
|
|
11919
|
+
final: options?.final,
|
|
11799
11920
|
customHtmlTags: options?.customHtmlTags,
|
|
11800
11921
|
validateLink: options?.validateLink
|
|
11801
11922
|
}),
|
|
@@ -11854,6 +11975,7 @@ function parseBlockquote(tokens, index, options) {
|
|
|
11854
11975
|
type: "paragraph",
|
|
11855
11976
|
children: parseInlineTokens(contentToken.children || [], String(contentToken.content ?? ""), void 0, {
|
|
11856
11977
|
requireClosingStrong: options?.requireClosingStrong,
|
|
11978
|
+
final: options?.final,
|
|
11857
11979
|
customHtmlTags: options?.customHtmlTags,
|
|
11858
11980
|
validateLink: options?.validateLink
|
|
11859
11981
|
}),
|
|
@@ -11919,6 +12041,7 @@ function parseDefinitionList(tokens, index, options) {
|
|
|
11919
12041
|
const termToken = tokens[j + 1];
|
|
11920
12042
|
termNodes = parseInlineTokens(termToken.children || [], void 0, void 0, {
|
|
11921
12043
|
requireClosingStrong: options?.requireClosingStrong,
|
|
12044
|
+
final: options?.final,
|
|
11922
12045
|
customHtmlTags: options?.customHtmlTags,
|
|
11923
12046
|
validateLink: options?.validateLink
|
|
11924
12047
|
});
|
|
@@ -11932,6 +12055,7 @@ function parseDefinitionList(tokens, index, options) {
|
|
|
11932
12055
|
type: "paragraph",
|
|
11933
12056
|
children: parseInlineTokens(contentToken.children || [], String(contentToken.content ?? ""), void 0, {
|
|
11934
12057
|
requireClosingStrong: options?.requireClosingStrong,
|
|
12058
|
+
final: options?.final,
|
|
11935
12059
|
customHtmlTags: options?.customHtmlTags,
|
|
11936
12060
|
validateLink: options?.validateLink
|
|
11937
12061
|
}),
|
|
@@ -11972,6 +12096,7 @@ function parseFootnote(tokens, index, options) {
|
|
|
11972
12096
|
type: "paragraph",
|
|
11973
12097
|
children: parseInlineTokens(contentToken.children || [], String(contentToken.content ?? ""), void 0, {
|
|
11974
12098
|
requireClosingStrong: options?.requireClosingStrong,
|
|
12099
|
+
final: options?.final,
|
|
11975
12100
|
customHtmlTags: options?.customHtmlTags,
|
|
11976
12101
|
validateLink: options?.validateLink
|
|
11977
12102
|
}),
|
|
@@ -12004,6 +12129,7 @@ function parseHeading(tokens, index, options) {
|
|
|
12004
12129
|
...attrsRecord ? { attrs: attrsRecord } : {},
|
|
12005
12130
|
children: parseInlineTokens(headingContentToken.children || [], headingContent, void 0, {
|
|
12006
12131
|
requireClosingStrong: options?.requireClosingStrong,
|
|
12132
|
+
final: options?.final,
|
|
12007
12133
|
customHtmlTags: options?.customHtmlTags,
|
|
12008
12134
|
validateLink: options?.validateLink
|
|
12009
12135
|
}),
|
|
@@ -12120,6 +12246,7 @@ function parseTable(tokens, index, options) {
|
|
|
12120
12246
|
header: isHeaderCell || isHeader,
|
|
12121
12247
|
children: parseInlineTokens(contentToken.children || [], content, void 0, {
|
|
12122
12248
|
requireClosingStrong: options?.requireClosingStrong,
|
|
12249
|
+
final: options?.final,
|
|
12123
12250
|
customHtmlTags: options?.customHtmlTags,
|
|
12124
12251
|
validateLink: options?.validateLink
|
|
12125
12252
|
}),
|
|
@@ -12221,6 +12348,7 @@ function parseVmrContainer(tokens, index, options) {
|
|
|
12221
12348
|
type: "paragraph",
|
|
12222
12349
|
children: parseInlineTokens(childrenArr || [], void 0, void 0, {
|
|
12223
12350
|
requireClosingStrong: options?.requireClosingStrong,
|
|
12351
|
+
final: options?.final,
|
|
12224
12352
|
customHtmlTags: options?.customHtmlTags,
|
|
12225
12353
|
validateLink: options?.validateLink
|
|
12226
12354
|
}),
|
|
@@ -12485,6 +12613,7 @@ function parseParagraph(tokens, index, options) {
|
|
|
12485
12613
|
type: "paragraph",
|
|
12486
12614
|
children: parseInlineTokens(paragraphContentToken.children || [], paragraphContent, void 0, {
|
|
12487
12615
|
requireClosingStrong: options?.requireClosingStrong,
|
|
12616
|
+
final: options?.final,
|
|
12488
12617
|
customHtmlTags: options?.customHtmlTags,
|
|
12489
12618
|
validateLink: options?.validateLink
|
|
12490
12619
|
}),
|
|
@@ -13046,6 +13175,18 @@ function ensureBlankLineBeforeCustomHtmlBlocks(markdown, tags) {
|
|
|
13046
13175
|
complete: false
|
|
13047
13176
|
};
|
|
13048
13177
|
};
|
|
13178
|
+
const parseStandaloneCompleteHtmlTagLine = (line) => {
|
|
13179
|
+
if (isIndentedCodeLine(line)) return null;
|
|
13180
|
+
const trimmed = trimStartIndentWs(line).replace(/[ \t]+$/, "");
|
|
13181
|
+
if (!trimmed.startsWith("<")) return null;
|
|
13182
|
+
if (/^<\s*(?:!--|!doctype\b|\?)/i.test(trimmed)) return null;
|
|
13183
|
+
const selfClosingMatch = trimmed.match(/^<\s*([A-Z][\w:-]*)\b[^>]*\/\s*>\s*$/i);
|
|
13184
|
+
if (selfClosingMatch?.[1]) return selfClosingMatch[1].toLowerCase();
|
|
13185
|
+
const fullMatch = trimmed.match(/^<\s*([A-Z][\w:-]*)\b[^>]*>[\s\S]*<\s*\/\s*([A-Z][\w:-]*)\s*>\s*$/i);
|
|
13186
|
+
if (!fullMatch?.[1] || !fullMatch[2]) return null;
|
|
13187
|
+
const openTag = fullMatch[1].toLowerCase();
|
|
13188
|
+
return openTag === fullMatch[2].toLowerCase() ? openTag : null;
|
|
13189
|
+
};
|
|
13049
13190
|
let inFence = false;
|
|
13050
13191
|
let fenceChar = "";
|
|
13051
13192
|
let fenceLen = 0;
|
|
@@ -13065,10 +13206,46 @@ function ensureBlankLineBeforeCustomHtmlBlocks(markdown, tags) {
|
|
|
13065
13206
|
};
|
|
13066
13207
|
};
|
|
13067
13208
|
const fenceMatchLine = (rawLine) => parseFenceMarker(rawLine);
|
|
13209
|
+
const lineStartsWithBlockMarker = (line) => {
|
|
13210
|
+
const trimmed = trimStartIndentWs(line);
|
|
13211
|
+
if (!trimmed) return false;
|
|
13212
|
+
if (isIndentedCodeLine(line)) return true;
|
|
13213
|
+
return /^(?:#{1,6}[ \t]+|>|[*+-][ \t]+|\d+[.)][ \t]+|`{3,}|~{3,}|\||\$\$|:{3,}|\[\^[^\]]+\]:|-{3,}|\*{3,}|_{3,})/.test(trimmed);
|
|
13214
|
+
};
|
|
13215
|
+
const currentCustomBlockNeedsBoundary = (lineStart, currentQuoteKey, tagName) => {
|
|
13216
|
+
let scanIdx = lineStart;
|
|
13217
|
+
let depth = 0;
|
|
13218
|
+
while (scanIdx < markdown.length) {
|
|
13219
|
+
const nl = markdown.indexOf("\n", scanIdx);
|
|
13220
|
+
const hasNl = nl !== -1;
|
|
13221
|
+
const isCrlf = hasNl && nl > scanIdx && markdown[nl - 1] === "\r";
|
|
13222
|
+
const lineEnd = hasNl ? isCrlf ? nl - 1 : nl : markdown.length;
|
|
13223
|
+
const rawLine = markdown.slice(scanIdx, lineEnd);
|
|
13224
|
+
const blockquote$1 = parseBlockquotePrefix(rawLine);
|
|
13225
|
+
const quoteKey = blockquote$1?.key ?? "";
|
|
13226
|
+
if (depth > 0 && currentQuoteKey && quoteKey !== currentQuoteKey) break;
|
|
13227
|
+
const contentLine = blockquote$1?.content ?? rawLine;
|
|
13228
|
+
const lineTag = parseLineStartCustomTag(contentLine);
|
|
13229
|
+
if (lineTag?.name === tagName) {
|
|
13230
|
+
if (lineTag.type === "open") {
|
|
13231
|
+
if (!lineTag.complete) depth++;
|
|
13232
|
+
} else if (depth > 0) {
|
|
13233
|
+
depth--;
|
|
13234
|
+
if (depth === 0) return false;
|
|
13235
|
+
}
|
|
13236
|
+
} else if (depth > 0) {
|
|
13237
|
+
if (lineIsBlank(contentLine) || lineStartsWithBlockMarker(contentLine)) return true;
|
|
13238
|
+
}
|
|
13239
|
+
if (hasNl) scanIdx = nl + 1;
|
|
13240
|
+
else break;
|
|
13241
|
+
}
|
|
13242
|
+
return false;
|
|
13243
|
+
};
|
|
13068
13244
|
let out = "";
|
|
13069
13245
|
let idx = 0;
|
|
13070
13246
|
let prevLineBlank = true;
|
|
13071
13247
|
let prevLineHtmlish = false;
|
|
13248
|
+
let prevLineStandaloneCompleteHtmlTag = false;
|
|
13072
13249
|
let lastNewline = "\n";
|
|
13073
13250
|
const customBlockStack = [];
|
|
13074
13251
|
let prevQuoteKey = "";
|
|
@@ -13098,7 +13275,9 @@ function ensureBlankLineBeforeCustomHtmlBlocks(markdown, tags) {
|
|
|
13098
13275
|
}
|
|
13099
13276
|
const insideCustomBlock = customBlockStack.length > 0;
|
|
13100
13277
|
if (!inFence && !insideCustomBlock) {
|
|
13101
|
-
|
|
13278
|
+
const opening = parseOpeningCustomTagName(contentLine);
|
|
13279
|
+
const needsBoundaryAfterStandaloneHtml = !!opening && !prevLineBlank && prevLineHtmlish && prevLineStandaloneCompleteHtmlTag && currentCustomBlockNeedsBoundary(idx, quoteKey, opening);
|
|
13280
|
+
if (opening && !prevLineBlank && (!prevLineHtmlish || needsBoundaryAfterStandaloneHtml)) {
|
|
13102
13281
|
if (quoteKey && prevQuoteKey && quoteKey === prevQuoteKey) out += `${quoteKey}${lastNewline}`;
|
|
13103
13282
|
else if (!quoteKey) out += lastNewline;
|
|
13104
13283
|
}
|
|
@@ -13120,6 +13299,7 @@ function ensureBlankLineBeforeCustomHtmlBlocks(markdown, tags) {
|
|
|
13120
13299
|
const blank = lineIsBlank(contentLine);
|
|
13121
13300
|
prevLineBlank = blank;
|
|
13122
13301
|
prevLineHtmlish = !blank && previousLineLooksHtmlish(contentLine);
|
|
13302
|
+
prevLineStandaloneCompleteHtmlTag = !blank && !!parseStandaloneCompleteHtmlTagLine(contentLine);
|
|
13123
13303
|
prevQuoteKey = quoteKey;
|
|
13124
13304
|
idx = hasNl ? nl + 1 : markdown.length;
|
|
13125
13305
|
}
|
|
@@ -13266,6 +13446,7 @@ function processTokens(tokens, options) {
|
|
|
13266
13446
|
{
|
|
13267
13447
|
const parsed = parseInlineTokens(token.children || [], String(token.content ?? ""), void 0, {
|
|
13268
13448
|
requireClosingStrong: options?.requireClosingStrong,
|
|
13449
|
+
final: options?.final,
|
|
13269
13450
|
customHtmlTags: options?.customHtmlTags,
|
|
13270
13451
|
validateLink: options?.validateLink
|
|
13271
13452
|
});
|