@ai-matrx/content-ir 0.19.8 → 0.19.10
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/CHANGELOG.md +12 -0
- package/dist/index.cjs +95 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +93 -10
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +95 -9
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +33 -10
- package/dist/source.d.ts +33 -10
- package/dist/source.js +93 -10
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.d.cts
CHANGED
|
@@ -630,11 +630,16 @@ declare function pairDisplayMath(text: string): Map<number, number>;
|
|
|
630
630
|
* boundary). Code spans get no special treatment: GFM splits rows before
|
|
631
631
|
* inline parsing, so an unescaped `|` inside backticks is a boundary too.
|
|
632
632
|
* - A cell's `\|` shows as `|` — inside code spans too (spec example 200).
|
|
633
|
-
* - A table starts at a header
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
633
|
+
* - A table starts at a header line whose NEXT line is a delimiter row (`--- |
|
|
634
|
+
* :-:`, edge pipes optional, never a list item such as `- | -`) of the SAME
|
|
635
|
+
* width; the header needs no pipe of its own (`Notes` over `|---|` is a
|
|
636
|
+
* one-column table), is not indented code, and is not a lazy continuation of a
|
|
637
|
+
* list item's or quote's paragraph. It runs to a blank line, a
|
|
638
|
+
* line that starts another block (`- x`, `> y`, `# z`, `1.`, a fence, a rule,
|
|
639
|
+
* an HTML block — CommonMark 4.6's seven start conditions), or a line indented
|
|
640
|
+
* four or more columns past the table's container (indented code); every other
|
|
641
|
+
* line is a row, with or without a pipe (spec example 202), a lone `|` included
|
|
642
|
+
* (an empty row).
|
|
638
643
|
*
|
|
639
644
|
* Pure TS, no dependencies.
|
|
640
645
|
*/
|
|
@@ -644,19 +649,37 @@ declare function splitRowSegments(line: string): string[];
|
|
|
644
649
|
declare function rowCells(line: string): string[];
|
|
645
650
|
/** GFM's table-level unescape: a cell's `\|` is a pipe, in code spans too. */
|
|
646
651
|
declare function unescapeCellPipes(cell: string): string;
|
|
652
|
+
/** The trimmed line starts an HTML block (any of CommonMark 4.6's seven conditions). */
|
|
653
|
+
declare function startsHtmlBlock(trimmed: string): boolean;
|
|
654
|
+
/** The column a line's content starts at: spaces count 1, a tab runs to the next multiple of 4. */
|
|
655
|
+
declare function lineIndent(line: string): number;
|
|
656
|
+
/**
|
|
657
|
+
* The content column of the container a table at `start` sits in: the list item
|
|
658
|
+
* whose content the header line belongs to (the nearest list-marker line above,
|
|
659
|
+
* past blank and continuation lines, whose content column is at or left of the
|
|
660
|
+
* header's), or 0 at top level. Indentation past it by 4+ columns is indented
|
|
661
|
+
* code, which ends the table.
|
|
662
|
+
*/
|
|
663
|
+
declare function tableContainerIndent(lines: readonly string[], start: number): number;
|
|
647
664
|
/** A GFM delimiter row: every cell `---`, `:--`, `--:` or `:-:`, with at least one pipe. */
|
|
648
665
|
declare function isGfmDelimiterRow(line: string): boolean;
|
|
649
666
|
/** A pipe-led row: `|` first, and another `|` after it. */
|
|
650
667
|
declare function isPipeLedRow(line: string): boolean;
|
|
651
|
-
/**
|
|
668
|
+
/**
|
|
669
|
+
* True when `header` + `delimiter` open a table whose header is NOT a pipe-led
|
|
670
|
+
* row: `a | b` (no edge pipes), `| a` (one pipe), or even `Notes` (no pipe — a
|
|
671
|
+
* one-column table over `|---|`). The delimiter must match the header's width.
|
|
672
|
+
*/
|
|
652
673
|
declare function startsPipelessTable(header: string, delimiter: string | undefined): boolean;
|
|
653
674
|
/**
|
|
654
675
|
* A line that continues an open table — GFM's rule (spec example 202): the table
|
|
655
|
-
* runs to the first blank line
|
|
676
|
+
* runs to the first blank line, the first line that starts another block (an
|
|
677
|
+
* HTML block included), or the first line indented 4+ columns past the table's
|
|
678
|
+
* container (`containerIndent`, from `tableContainerIndent`; indented code). Any
|
|
656
679
|
* other line is a row, even one without a pipe (`bar` → a one-cell row) and a
|
|
657
|
-
* lone `|` (an empty row). verify-RC-B4 R7-2.
|
|
680
|
+
* lone `|` (an empty row). verify-RC-B4 R7-2 / round 9.
|
|
658
681
|
*/
|
|
659
|
-
declare function continuesTable(line: string): boolean;
|
|
682
|
+
declare function continuesTable(line: string, containerIndent?: number): boolean;
|
|
660
683
|
/** Line `index` opens a table: a pipe-led row, or a pipe-less GFM header over its delimiter row. */
|
|
661
684
|
declare function opensTable(lines: readonly string[], index: number): boolean;
|
|
662
685
|
/** A WHOLE table header at `index`: a table opens here AND its next line is a GFM delimiter row. */
|
|
@@ -666,4 +689,4 @@ declare function findTableStart(lines: readonly string[], from?: number): number
|
|
|
666
689
|
/** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
|
|
667
690
|
declare function findTableEnd(lines: readonly string[], start: number): number;
|
|
668
691
|
|
|
669
|
-
export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
|
692
|
+
export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, lineIndent, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsHtmlBlock, startsPipelessTable, tableContainerIndent, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
package/dist/source.d.ts
CHANGED
|
@@ -630,11 +630,16 @@ declare function pairDisplayMath(text: string): Map<number, number>;
|
|
|
630
630
|
* boundary). Code spans get no special treatment: GFM splits rows before
|
|
631
631
|
* inline parsing, so an unescaped `|` inside backticks is a boundary too.
|
|
632
632
|
* - A cell's `\|` shows as `|` — inside code spans too (spec example 200).
|
|
633
|
-
* - A table starts at a header
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
633
|
+
* - A table starts at a header line whose NEXT line is a delimiter row (`--- |
|
|
634
|
+
* :-:`, edge pipes optional, never a list item such as `- | -`) of the SAME
|
|
635
|
+
* width; the header needs no pipe of its own (`Notes` over `|---|` is a
|
|
636
|
+
* one-column table), is not indented code, and is not a lazy continuation of a
|
|
637
|
+
* list item's or quote's paragraph. It runs to a blank line, a
|
|
638
|
+
* line that starts another block (`- x`, `> y`, `# z`, `1.`, a fence, a rule,
|
|
639
|
+
* an HTML block — CommonMark 4.6's seven start conditions), or a line indented
|
|
640
|
+
* four or more columns past the table's container (indented code); every other
|
|
641
|
+
* line is a row, with or without a pipe (spec example 202), a lone `|` included
|
|
642
|
+
* (an empty row).
|
|
638
643
|
*
|
|
639
644
|
* Pure TS, no dependencies.
|
|
640
645
|
*/
|
|
@@ -644,19 +649,37 @@ declare function splitRowSegments(line: string): string[];
|
|
|
644
649
|
declare function rowCells(line: string): string[];
|
|
645
650
|
/** GFM's table-level unescape: a cell's `\|` is a pipe, in code spans too. */
|
|
646
651
|
declare function unescapeCellPipes(cell: string): string;
|
|
652
|
+
/** The trimmed line starts an HTML block (any of CommonMark 4.6's seven conditions). */
|
|
653
|
+
declare function startsHtmlBlock(trimmed: string): boolean;
|
|
654
|
+
/** The column a line's content starts at: spaces count 1, a tab runs to the next multiple of 4. */
|
|
655
|
+
declare function lineIndent(line: string): number;
|
|
656
|
+
/**
|
|
657
|
+
* The content column of the container a table at `start` sits in: the list item
|
|
658
|
+
* whose content the header line belongs to (the nearest list-marker line above,
|
|
659
|
+
* past blank and continuation lines, whose content column is at or left of the
|
|
660
|
+
* header's), or 0 at top level. Indentation past it by 4+ columns is indented
|
|
661
|
+
* code, which ends the table.
|
|
662
|
+
*/
|
|
663
|
+
declare function tableContainerIndent(lines: readonly string[], start: number): number;
|
|
647
664
|
/** A GFM delimiter row: every cell `---`, `:--`, `--:` or `:-:`, with at least one pipe. */
|
|
648
665
|
declare function isGfmDelimiterRow(line: string): boolean;
|
|
649
666
|
/** A pipe-led row: `|` first, and another `|` after it. */
|
|
650
667
|
declare function isPipeLedRow(line: string): boolean;
|
|
651
|
-
/**
|
|
668
|
+
/**
|
|
669
|
+
* True when `header` + `delimiter` open a table whose header is NOT a pipe-led
|
|
670
|
+
* row: `a | b` (no edge pipes), `| a` (one pipe), or even `Notes` (no pipe — a
|
|
671
|
+
* one-column table over `|---|`). The delimiter must match the header's width.
|
|
672
|
+
*/
|
|
652
673
|
declare function startsPipelessTable(header: string, delimiter: string | undefined): boolean;
|
|
653
674
|
/**
|
|
654
675
|
* A line that continues an open table — GFM's rule (spec example 202): the table
|
|
655
|
-
* runs to the first blank line
|
|
676
|
+
* runs to the first blank line, the first line that starts another block (an
|
|
677
|
+
* HTML block included), or the first line indented 4+ columns past the table's
|
|
678
|
+
* container (`containerIndent`, from `tableContainerIndent`; indented code). Any
|
|
656
679
|
* other line is a row, even one without a pipe (`bar` → a one-cell row) and a
|
|
657
|
-
* lone `|` (an empty row). verify-RC-B4 R7-2.
|
|
680
|
+
* lone `|` (an empty row). verify-RC-B4 R7-2 / round 9.
|
|
658
681
|
*/
|
|
659
|
-
declare function continuesTable(line: string): boolean;
|
|
682
|
+
declare function continuesTable(line: string, containerIndent?: number): boolean;
|
|
660
683
|
/** Line `index` opens a table: a pipe-led row, or a pipe-less GFM header over its delimiter row. */
|
|
661
684
|
declare function opensTable(lines: readonly string[], index: number): boolean;
|
|
662
685
|
/** A WHOLE table header at `index`: a table opens here AND its next line is a GFM delimiter row. */
|
|
@@ -666,4 +689,4 @@ declare function findTableStart(lines: readonly string[], from?: number): number
|
|
|
666
689
|
/** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
|
|
667
690
|
declare function findTableEnd(lines: readonly string[], start: number): number;
|
|
668
691
|
|
|
669
|
-
export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
|
692
|
+
export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, lineIndent, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsHtmlBlock, startsPipelessTable, tableContainerIndent, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
package/dist/source.js
CHANGED
|
@@ -2625,14 +2625,61 @@ function rowCells(line) {
|
|
|
2625
2625
|
const cells = splitRowSegments(line).map((cell) => cell.trim());
|
|
2626
2626
|
if (cells.length > 1 && cells[0] === "") cells.shift();
|
|
2627
2627
|
if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
|
|
2628
|
-
else if (cells.length === 1 && cells[0] === "") cells.pop();
|
|
2628
|
+
else if (cells.length === 1 && cells[0] === "" && !line.includes("|")) cells.pop();
|
|
2629
2629
|
return cells;
|
|
2630
2630
|
}
|
|
2631
2631
|
function unescapeCellPipes(cell) {
|
|
2632
2632
|
return cell.replace(/\\\|/g, "|");
|
|
2633
2633
|
}
|
|
2634
2634
|
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
|
|
2635
|
-
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed);
|
|
2635
|
+
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
2636
|
+
var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
|
|
2637
|
+
var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
|
|
2638
|
+
var HTML_BLOCK_NAMES = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
2639
|
+
var HTML_BLOCK_TAG = new RegExp(`^</?(?:${HTML_BLOCK_NAMES})(?:[\\s>]|/>|$)`, "i");
|
|
2640
|
+
var ATTRIBUTE = `\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:[^\\s"'=<>\`]+|'[^']*'|"[^"]*"))?`;
|
|
2641
|
+
var HTML_COMPLETE_TAG = new RegExp(`^(?:<[A-Za-z][A-Za-z0-9-]*(?:${ATTRIBUTE})*\\s*/?>|</[A-Za-z][A-Za-z0-9-]*\\s*>)\\s*$`);
|
|
2642
|
+
function startsHtmlBlock(trimmed) {
|
|
2643
|
+
if (!trimmed.startsWith("<")) return false;
|
|
2644
|
+
return HTML_RAW.test(trimmed) || HTML_COMMENT_ETC.test(trimmed) || HTML_BLOCK_TAG.test(trimmed) || HTML_COMPLETE_TAG.test(trimmed);
|
|
2645
|
+
}
|
|
2646
|
+
function lineIndent(line) {
|
|
2647
|
+
let column = 0;
|
|
2648
|
+
for (const ch of line) {
|
|
2649
|
+
if (ch === " ") column += 1;
|
|
2650
|
+
else if (ch === " ") column += 4 - column % 4;
|
|
2651
|
+
else break;
|
|
2652
|
+
}
|
|
2653
|
+
return column;
|
|
2654
|
+
}
|
|
2655
|
+
var LIST_MARKER = /^([ \t]*)([-+*]|\d{1,9}[.)])([ \t]+|$)/;
|
|
2656
|
+
function markerContentColumn(marker) {
|
|
2657
|
+
const markerEnd = lineIndent(marker[1] ?? "") + (marker[2] ?? "").length;
|
|
2658
|
+
const gap = marker[3] ? lineIndent(" ".repeat(markerEnd) + marker[3]) - markerEnd : 1;
|
|
2659
|
+
return markerEnd + (gap >= 1 && gap <= 4 ? gap : 1);
|
|
2660
|
+
}
|
|
2661
|
+
function tableContainerIndent(lines, start) {
|
|
2662
|
+
return tableContainerIndentOf(lines, start, false);
|
|
2663
|
+
}
|
|
2664
|
+
function tableContainerIndentOf(lines, start, ownItem) {
|
|
2665
|
+
const own = ownItem ? LIST_MARKER.exec(lines[start] ?? "") : null;
|
|
2666
|
+
if (own) return markerContentColumn(own);
|
|
2667
|
+
const header = lineIndent(lines[start] ?? "");
|
|
2668
|
+
if (header === 0) return 0;
|
|
2669
|
+
for (let k = start - 1; k >= 0; k -= 1) {
|
|
2670
|
+
const line = lines[k] ?? "";
|
|
2671
|
+
if (!line.trim()) continue;
|
|
2672
|
+
const indent = lineIndent(line);
|
|
2673
|
+
const marker = LIST_MARKER.exec(line);
|
|
2674
|
+
if (marker && indent < header) {
|
|
2675
|
+
const content = markerContentColumn(marker);
|
|
2676
|
+
if (content <= header) return content;
|
|
2677
|
+
continue;
|
|
2678
|
+
}
|
|
2679
|
+
if (indent === 0) return 0;
|
|
2680
|
+
}
|
|
2681
|
+
return 0;
|
|
2682
|
+
}
|
|
2636
2683
|
var DELIMITER_CELL = /^:?-+:?$/;
|
|
2637
2684
|
function isGfmDelimiterRow(line) {
|
|
2638
2685
|
const trimmed = line.trim();
|
|
@@ -2644,35 +2691,71 @@ function isPipeLedRow(line) {
|
|
|
2644
2691
|
const trimmed = line.trim();
|
|
2645
2692
|
return trimmed.startsWith("|") && trimmed.includes("|", 1);
|
|
2646
2693
|
}
|
|
2694
|
+
function isTableDelimiter(line) {
|
|
2695
|
+
if (line === void 0 || !isGfmDelimiterRow(line)) return false;
|
|
2696
|
+
return !BLOCK_START.test(line.trim());
|
|
2697
|
+
}
|
|
2647
2698
|
function startsPipelessTable(header, delimiter) {
|
|
2648
2699
|
const head = header.trim();
|
|
2649
|
-
if (!head || head.startsWith("|")
|
|
2650
|
-
if (
|
|
2651
|
-
if (delimiter === void 0 || !isGfmDelimiterRow(delimiter)) return false;
|
|
2700
|
+
if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
|
|
2701
|
+
if (!isTableDelimiter(delimiter)) return false;
|
|
2652
2702
|
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
2653
2703
|
}
|
|
2654
|
-
function continuesTable(line) {
|
|
2704
|
+
function continuesTable(line, containerIndent = 0) {
|
|
2655
2705
|
const trimmed = line.trim();
|
|
2656
2706
|
if (!trimmed) return false;
|
|
2707
|
+
if (lineIndent(line) - containerIndent >= 4) return false;
|
|
2657
2708
|
return trimmed.startsWith("|") || !startsBlock(trimmed);
|
|
2658
2709
|
}
|
|
2659
2710
|
function opensTable(lines, index) {
|
|
2660
2711
|
const line = lines[index] ?? "";
|
|
2661
|
-
|
|
2712
|
+
if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
|
|
2713
|
+
return !isLazyContinuation(lines, index);
|
|
2714
|
+
}
|
|
2715
|
+
var QUOTE_LINE = /^ {0,3}>/;
|
|
2716
|
+
var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
2717
|
+
var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
2718
|
+
function isLazyContinuation(lines, index) {
|
|
2719
|
+
const header = lines[index] ?? "";
|
|
2720
|
+
let first = -1;
|
|
2721
|
+
for (let k = index - 1; k >= 0; k -= 1) {
|
|
2722
|
+
const line = lines[k] ?? "";
|
|
2723
|
+
const trimmed = line.trim();
|
|
2724
|
+
if (!trimmed) break;
|
|
2725
|
+
if (breaksParagraph(trimmed)) break;
|
|
2726
|
+
const marker = LIST_MARKER.exec(line);
|
|
2727
|
+
if (marker) {
|
|
2728
|
+
const rest = line.slice(marker[0].length).trim();
|
|
2729
|
+
if (!rest || breaksParagraph(rest)) break;
|
|
2730
|
+
first = k;
|
|
2731
|
+
break;
|
|
2732
|
+
}
|
|
2733
|
+
first = k;
|
|
2734
|
+
if (QUOTE_LINE.test(line)) break;
|
|
2735
|
+
}
|
|
2736
|
+
if (first < 0) return false;
|
|
2737
|
+
const start = lines[first] ?? "";
|
|
2738
|
+
if (QUOTE_LINE.test(start)) return !QUOTE_LINE.test(header);
|
|
2739
|
+
return lineIndent(header) < tableContainerIndentOf(lines, first, true);
|
|
2662
2740
|
}
|
|
2663
2741
|
function tableStartsAt(lines, index) {
|
|
2664
|
-
|
|
2742
|
+
const header = lines[index] ?? "";
|
|
2743
|
+
const delimiter = lines[index + 1];
|
|
2744
|
+
if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
|
|
2745
|
+
if (rowCells(header).length !== rowCells(delimiter).length) return false;
|
|
2746
|
+
return lineIndent(header) - tableContainerIndent(lines, index) < 4;
|
|
2665
2747
|
}
|
|
2666
2748
|
function findTableStart(lines, from = 0) {
|
|
2667
2749
|
for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
|
|
2668
2750
|
return -1;
|
|
2669
2751
|
}
|
|
2670
2752
|
function findTableEnd(lines, start) {
|
|
2753
|
+
const container = tableContainerIndent(lines, start);
|
|
2671
2754
|
let end = Math.min(lines.length, start + 2);
|
|
2672
|
-
while (end < lines.length && continuesTable(lines[end] ?? "")) end += 1;
|
|
2755
|
+
while (end < lines.length && continuesTable(lines[end] ?? "", container)) end += 1;
|
|
2673
2756
|
return end;
|
|
2674
2757
|
}
|
|
2675
2758
|
|
|
2676
|
-
export { AFTER_WINDOW, BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
|
2759
|
+
export { AFTER_WINDOW, BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findInlineCodeSpans, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, lineIndent, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapInlineCodeSpans, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsHtmlBlock, startsPipelessTable, tableContainerIndent, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
|
|
2677
2760
|
//# sourceMappingURL=source.js.map
|
|
2678
2761
|
//# sourceMappingURL=source.js.map
|