mrkdwn.js 4.0.5 → 6.6.1
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/README.md +85 -66
- package/dist/ast/ast.d.cts +1 -1
- package/dist/ast/ast.d.ts +1 -1
- package/dist/{ast-8XCbjRQT.d.cts → ast-CNfTgS0N.d.cts} +35 -35
- package/dist/{ast-8XCbjRQT.d.ts → ast-CNfTgS0N.d.ts} +35 -35
- package/dist/block/block.cjs +12 -4
- package/dist/block/block.d.cts +9 -5
- package/dist/block/block.d.ts +9 -5
- package/dist/block/block.js +8 -4
- package/dist/block/definitions.d.cts +2 -2
- package/dist/block/definitions.d.ts +2 -2
- package/dist/block/node.d.cts +4 -4
- package/dist/block/node.d.ts +4 -4
- package/dist/block/table.d.cts +1 -1
- package/dist/block/table.d.ts +1 -1
- package/dist/codec.cjs +1 -1
- package/dist/codec.d.cts +1625 -23
- package/dist/codec.d.ts +1625 -23
- package/dist/codec.js +2 -2
- package/dist/defaults/defaults.d.cts +1 -1
- package/dist/defaults/defaults.d.ts +1 -1
- package/dist/diagnostics/diagnostics.cjs +17 -7
- package/dist/diagnostics/diagnostics.d.cts +2 -2
- package/dist/diagnostics/diagnostics.d.ts +2 -2
- package/dist/diagnostics/diagnostics.js +17 -8
- package/dist/{diagnostics-BWK1iGy7.d.cts → diagnostics-CjfBoW4K.d.cts} +14 -10
- package/dist/{diagnostics-BWK1iGy7.d.ts → diagnostics-CjfBoW4K.d.ts} +14 -10
- package/dist/emit/emit.cjs +378 -42
- package/dist/emit/emit.js +381 -45
- package/dist/emit/front-matter.cjs +22 -5
- package/dist/emit/front-matter.js +22 -5
- package/dist/emit/html-table.cjs +104 -0
- package/dist/emit/html-table.d.cts +7 -0
- package/dist/emit/html-table.d.ts +7 -0
- package/dist/emit/html-table.js +102 -0
- package/dist/emit/inline.cjs +69 -26
- package/dist/emit/inline.d.cts +2 -12
- package/dist/emit/inline.d.ts +2 -12
- package/dist/emit/inline.js +68 -27
- package/dist/emit/table.cjs +18 -11
- package/dist/emit/table.d.cts +3 -2
- package/dist/emit/table.d.ts +3 -2
- package/dist/emit/table.js +18 -11
- package/dist/html/html-table.cjs +243 -0
- package/dist/html/html-table.d.cts +5 -0
- package/dist/html/html-table.d.ts +5 -0
- package/dist/html/html-table.js +242 -0
- package/dist/html/render.d.cts +1 -1
- package/dist/html/render.d.ts +1 -1
- package/dist/image/image.cjs +4 -4
- package/dist/image/image.d.cts +1 -1
- package/dist/image/image.d.ts +1 -1
- package/dist/image/image.js +4 -4
- package/dist/{image-C4KYmz_L.d.cts → image-B5L0HpAJ.d.cts} +1 -1
- package/dist/{image-DescdRgq.d.cts → image-BtmTG4_a.d.cts} +1 -1
- package/dist/{image-DescdRgq.d.ts → image-BtmTG4_a.d.ts} +1 -1
- package/dist/{image-Cm3hT5PS.d.ts → image-C390OIB3.d.ts} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/inline/delimiter.d.cts +2 -2
- package/dist/inline/delimiter.d.ts +2 -2
- package/dist/inline/inline.d.cts +1 -1
- package/dist/inline/inline.d.ts +1 -1
- package/dist/inline/link.d.cts +17 -1
- package/dist/inline/link.d.ts +17 -1
- package/dist/inline/node.d.cts +2 -2
- package/dist/inline/node.d.ts +2 -2
- package/dist/{inline-CXVQWQnW.d.cts → inline-CnO86zMw.d.cts} +2 -2
- package/dist/inline-DCIKQ83j.d.cts +14 -0
- package/dist/{inline-B_V7bs5j.d.ts → inline-DItZ-VVw.d.ts} +2 -2
- package/dist/inline-INoDAG37.d.ts +14 -0
- package/dist/lower/front-matter.cjs +73 -26
- package/dist/lower/front-matter.d.cts +2 -1
- package/dist/lower/front-matter.d.ts +2 -1
- package/dist/lower/front-matter.js +72 -25
- package/dist/lower/image.d.cts +1 -1
- package/dist/lower/image.d.ts +1 -1
- package/dist/lower/inline.cjs +87 -33
- package/dist/lower/inline.d.cts +9 -12
- package/dist/lower/inline.d.ts +9 -12
- package/dist/lower/inline.js +89 -34
- package/dist/lower/lower.cjs +143 -113
- package/dist/lower/lower.d.cts +8 -1
- package/dist/lower/lower.d.ts +8 -1
- package/dist/lower/lower.js +144 -115
- package/dist/lower/table.cjs +3 -2
- package/dist/lower/table.d.cts +1 -1
- package/dist/lower/table.d.ts +1 -1
- package/dist/lower/table.js +3 -2
- package/dist/options/options.d.cts +10 -10
- package/dist/options/options.d.ts +10 -10
- package/dist/read.cjs +45 -9
- package/dist/read.d.cts +3 -3
- package/dist/read.d.ts +3 -3
- package/dist/read.js +47 -11
- package/dist/scan/entity-table.cjs +2125 -2125
- package/dist/scan/entity-table.js +2125 -2125
- package/dist/shared/line-ending.cjs +7 -0
- package/dist/shared/line-ending.d.cts +5 -0
- package/dist/shared/line-ending.d.ts +5 -0
- package/dist/shared/line-ending.js +5 -0
- package/dist/shared/list-id.cjs +11 -3
- package/dist/shared/list-id.d.cts +7 -4
- package/dist/shared/list-id.d.ts +7 -4
- package/dist/shared/list-id.js +11 -4
- package/dist/shared/style-constants.cjs +0 -2
- package/dist/shared/style-constants.d.cts +1 -2
- package/dist/shared/style-constants.d.ts +1 -2
- package/dist/shared/style-constants.js +1 -2
- package/dist/write.cjs +33 -6
- package/dist/write.d.cts +2 -2
- package/dist/write.d.ts +2 -2
- package/dist/write.js +34 -7
- package/package.json +29 -30
- package/dist/link-Dv4kxVjk.d.cts +0 -18
- package/dist/link-Dv4kxVjk.d.ts +0 -18
|
@@ -8,33 +8,33 @@ interface MarkdownPosition {
|
|
|
8
8
|
type MarkdownNode = MarkdownBlockNode | MarkdownInlineNode;
|
|
9
9
|
type MarkdownBlockNode = MarkdownDocumentNode | MarkdownParagraphNode | MarkdownHeadingNode | MarkdownBlockquoteNode | MarkdownListNode | MarkdownListItemNode | MarkdownCodeBlockNode | MarkdownThematicBreakNode | MarkdownHtmlBlockNode | MarkdownTableNode | MarkdownTableRowNode | MarkdownTableCellNode | MarkdownMathBlockNode | MarkdownFootnoteDefinitionNode;
|
|
10
10
|
interface MarkdownDocumentNode {
|
|
11
|
-
readonly type:
|
|
11
|
+
readonly type: "document";
|
|
12
12
|
readonly children: MarkdownBlockNode[];
|
|
13
13
|
readonly position?: MarkdownPosition;
|
|
14
14
|
}
|
|
15
15
|
interface MarkdownParagraphNode {
|
|
16
|
-
readonly type:
|
|
16
|
+
readonly type: "paragraph";
|
|
17
17
|
readonly children: MarkdownInlineNode[];
|
|
18
18
|
readonly position?: MarkdownPosition;
|
|
19
19
|
}
|
|
20
|
-
type MarkdownHeadingStyle =
|
|
20
|
+
type MarkdownHeadingStyle = "atx" | "setext";
|
|
21
21
|
interface MarkdownHeadingNode {
|
|
22
|
-
readonly type:
|
|
22
|
+
readonly type: "heading";
|
|
23
23
|
readonly level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
24
24
|
readonly style: MarkdownHeadingStyle;
|
|
25
25
|
readonly children: MarkdownInlineNode[];
|
|
26
26
|
readonly position?: MarkdownPosition;
|
|
27
27
|
}
|
|
28
28
|
interface MarkdownBlockquoteNode {
|
|
29
|
-
readonly type:
|
|
29
|
+
readonly type: "blockquote";
|
|
30
30
|
readonly children: MarkdownBlockNode[];
|
|
31
31
|
readonly position?: MarkdownPosition;
|
|
32
32
|
}
|
|
33
|
-
type MarkdownListMarkerType =
|
|
34
|
-
type MarkdownBulletMarker =
|
|
35
|
-
type MarkdownOrderedListDelimiter =
|
|
33
|
+
type MarkdownListMarkerType = "bullet" | "ordered";
|
|
34
|
+
type MarkdownBulletMarker = "-" | "*" | "+";
|
|
35
|
+
type MarkdownOrderedListDelimiter = "." | ")";
|
|
36
36
|
interface MarkdownListNode {
|
|
37
|
-
readonly type:
|
|
37
|
+
readonly type: "list";
|
|
38
38
|
readonly markerType: MarkdownListMarkerType;
|
|
39
39
|
readonly bulletMarker?: MarkdownBulletMarker;
|
|
40
40
|
readonly orderedDelimiter?: MarkdownOrderedListDelimiter;
|
|
@@ -44,95 +44,95 @@ interface MarkdownListNode {
|
|
|
44
44
|
readonly position?: MarkdownPosition;
|
|
45
45
|
}
|
|
46
46
|
interface MarkdownListItemNode {
|
|
47
|
-
readonly type:
|
|
47
|
+
readonly type: "listItem";
|
|
48
48
|
readonly checked?: boolean;
|
|
49
49
|
readonly children: MarkdownBlockNode[];
|
|
50
50
|
readonly position?: MarkdownPosition;
|
|
51
51
|
}
|
|
52
52
|
interface MarkdownCodeBlockNode {
|
|
53
|
-
readonly type:
|
|
53
|
+
readonly type: "codeBlock";
|
|
54
54
|
readonly fenced: boolean;
|
|
55
|
-
readonly fenceChar?:
|
|
55
|
+
readonly fenceChar?: "`" | "~";
|
|
56
56
|
readonly infoString?: string;
|
|
57
57
|
readonly literal: string;
|
|
58
58
|
readonly position?: MarkdownPosition;
|
|
59
59
|
}
|
|
60
60
|
interface MarkdownThematicBreakNode {
|
|
61
|
-
readonly type:
|
|
61
|
+
readonly type: "thematicBreak";
|
|
62
62
|
readonly position?: MarkdownPosition;
|
|
63
63
|
}
|
|
64
64
|
interface MarkdownHtmlBlockNode {
|
|
65
|
-
readonly type:
|
|
65
|
+
readonly type: "htmlBlock";
|
|
66
66
|
readonly literal: string;
|
|
67
67
|
readonly position?: MarkdownPosition;
|
|
68
68
|
}
|
|
69
|
-
type MarkdownTableAlignment =
|
|
69
|
+
type MarkdownTableAlignment = "left" | "right" | "center" | "none";
|
|
70
70
|
interface MarkdownTableNode {
|
|
71
|
-
readonly type:
|
|
71
|
+
readonly type: "table";
|
|
72
72
|
readonly alignments: MarkdownTableAlignment[];
|
|
73
73
|
readonly children: MarkdownTableRowNode[];
|
|
74
74
|
readonly position?: MarkdownPosition;
|
|
75
75
|
}
|
|
76
76
|
interface MarkdownTableRowNode {
|
|
77
|
-
readonly type:
|
|
77
|
+
readonly type: "tableRow";
|
|
78
78
|
readonly header: boolean;
|
|
79
79
|
readonly children: MarkdownTableCellNode[];
|
|
80
80
|
readonly position?: MarkdownPosition;
|
|
81
81
|
}
|
|
82
82
|
interface MarkdownTableCellNode {
|
|
83
|
-
readonly type:
|
|
83
|
+
readonly type: "tableCell";
|
|
84
84
|
readonly children: MarkdownInlineNode[];
|
|
85
85
|
readonly position?: MarkdownPosition;
|
|
86
86
|
}
|
|
87
87
|
interface MarkdownMathBlockNode {
|
|
88
|
-
readonly type:
|
|
88
|
+
readonly type: "mathBlock";
|
|
89
89
|
readonly literal: string;
|
|
90
90
|
readonly position?: MarkdownPosition;
|
|
91
91
|
}
|
|
92
92
|
interface MarkdownFootnoteDefinitionNode {
|
|
93
|
-
readonly type:
|
|
93
|
+
readonly type: "footnoteDefinition";
|
|
94
94
|
readonly label: string;
|
|
95
95
|
readonly children: MarkdownBlockNode[];
|
|
96
96
|
readonly position?: MarkdownPosition;
|
|
97
97
|
}
|
|
98
98
|
type MarkdownInlineNode = MarkdownTextNode | MarkdownEmphasisNode | MarkdownStrongNode | MarkdownStrikethroughNode | MarkdownCodeSpanNode | MarkdownLinkNode | MarkdownImageNode | MarkdownAutolinkNode | MarkdownHardBreakNode | MarkdownSoftBreakNode | MarkdownRawHtmlNode | MarkdownEntityNode | MarkdownMathInlineNode | MarkdownFootnoteReferenceNode;
|
|
99
|
-
type MarkdownEmphasisMarker =
|
|
99
|
+
type MarkdownEmphasisMarker = "_" | "*";
|
|
100
100
|
interface MarkdownTextNode {
|
|
101
|
-
readonly type:
|
|
101
|
+
readonly type: "text";
|
|
102
102
|
readonly value: string;
|
|
103
103
|
readonly position?: MarkdownPosition;
|
|
104
104
|
}
|
|
105
105
|
interface MarkdownEmphasisNode {
|
|
106
|
-
readonly type:
|
|
106
|
+
readonly type: "emphasis";
|
|
107
107
|
readonly marker: MarkdownEmphasisMarker;
|
|
108
108
|
readonly children: MarkdownInlineNode[];
|
|
109
109
|
readonly position?: MarkdownPosition;
|
|
110
110
|
}
|
|
111
111
|
interface MarkdownStrongNode {
|
|
112
|
-
readonly type:
|
|
112
|
+
readonly type: "strong";
|
|
113
113
|
readonly marker: MarkdownEmphasisMarker;
|
|
114
114
|
readonly children: MarkdownInlineNode[];
|
|
115
115
|
readonly position?: MarkdownPosition;
|
|
116
116
|
}
|
|
117
117
|
interface MarkdownStrikethroughNode {
|
|
118
|
-
readonly type:
|
|
118
|
+
readonly type: "strikethrough";
|
|
119
119
|
readonly children: MarkdownInlineNode[];
|
|
120
120
|
readonly position?: MarkdownPosition;
|
|
121
121
|
}
|
|
122
122
|
interface MarkdownCodeSpanNode {
|
|
123
|
-
readonly type:
|
|
123
|
+
readonly type: "codeSpan";
|
|
124
124
|
readonly literal: string;
|
|
125
125
|
readonly position?: MarkdownPosition;
|
|
126
126
|
}
|
|
127
127
|
interface MarkdownLinkNode {
|
|
128
|
-
readonly type:
|
|
128
|
+
readonly type: "link";
|
|
129
129
|
readonly destination: string;
|
|
130
130
|
readonly title?: string;
|
|
131
131
|
readonly children: MarkdownInlineNode[];
|
|
132
132
|
readonly position?: MarkdownPosition;
|
|
133
133
|
}
|
|
134
134
|
interface MarkdownImageNode {
|
|
135
|
-
readonly type:
|
|
135
|
+
readonly type: "image";
|
|
136
136
|
readonly destination: string;
|
|
137
137
|
readonly title?: string;
|
|
138
138
|
readonly alt: string;
|
|
@@ -141,37 +141,37 @@ interface MarkdownImageNode {
|
|
|
141
141
|
readonly position?: MarkdownPosition;
|
|
142
142
|
}
|
|
143
143
|
interface MarkdownAutolinkNode {
|
|
144
|
-
readonly type:
|
|
144
|
+
readonly type: "autolink";
|
|
145
145
|
readonly destination: string;
|
|
146
146
|
readonly email: boolean;
|
|
147
147
|
readonly position?: MarkdownPosition;
|
|
148
148
|
}
|
|
149
149
|
interface MarkdownHardBreakNode {
|
|
150
|
-
readonly type:
|
|
150
|
+
readonly type: "hardBreak";
|
|
151
151
|
readonly position?: MarkdownPosition;
|
|
152
152
|
}
|
|
153
153
|
interface MarkdownSoftBreakNode {
|
|
154
|
-
readonly type:
|
|
154
|
+
readonly type: "softBreak";
|
|
155
155
|
readonly position?: MarkdownPosition;
|
|
156
156
|
}
|
|
157
157
|
interface MarkdownRawHtmlNode {
|
|
158
|
-
readonly type:
|
|
158
|
+
readonly type: "rawHtml";
|
|
159
159
|
readonly literal: string;
|
|
160
160
|
readonly position?: MarkdownPosition;
|
|
161
161
|
}
|
|
162
162
|
interface MarkdownEntityNode {
|
|
163
|
-
readonly type:
|
|
163
|
+
readonly type: "entity";
|
|
164
164
|
readonly raw: string;
|
|
165
165
|
readonly value: string;
|
|
166
166
|
readonly position?: MarkdownPosition;
|
|
167
167
|
}
|
|
168
168
|
interface MarkdownMathInlineNode {
|
|
169
|
-
readonly type:
|
|
169
|
+
readonly type: "mathInline";
|
|
170
170
|
readonly literal: string;
|
|
171
171
|
readonly position?: MarkdownPosition;
|
|
172
172
|
}
|
|
173
173
|
interface MarkdownFootnoteReferenceNode {
|
|
174
|
-
readonly type:
|
|
174
|
+
readonly type: "footnoteReference";
|
|
175
175
|
readonly label: string;
|
|
176
176
|
readonly position?: MarkdownPosition;
|
|
177
177
|
}
|
package/dist/block/block.cjs
CHANGED
|
@@ -5,6 +5,7 @@ const require_diagnostics_diagnostics = require("../diagnostics/diagnostics.cjs"
|
|
|
5
5
|
const require_html_html = require("../html/html.cjs");
|
|
6
6
|
const require_inline_entity = require("../inline/entity.cjs");
|
|
7
7
|
const require_inline_inline = require("../inline/inline.cjs");
|
|
8
|
+
const require_shared_line_ending = require("../shared/line-ending.cjs");
|
|
8
9
|
const require_block_definitions = require("./definitions.cjs");
|
|
9
10
|
const require_block_line = require("./line.cjs");
|
|
10
11
|
const require_block_list = require("./list.cjs");
|
|
@@ -14,7 +15,6 @@ const require_block_table = require("./table.cjs");
|
|
|
14
15
|
const TASK_LIST_MARKER_PATTERN = /^\[([ xX])\][ \t]/;
|
|
15
16
|
const NUL_REPLACEMENT = "�";
|
|
16
17
|
const NUL_PATTERN = /\0/g;
|
|
17
|
-
const LINE_ENDING_PATTERN = /\r\n|\n|\r/;
|
|
18
18
|
const MAYBE_SPECIAL_PATTERN = /^[#$`~*+_=<>[0-9|:-]/;
|
|
19
19
|
const ATX_MARKER_PATTERN = /^#{1,6}(?:[ \t]+|$)/;
|
|
20
20
|
const ATX_ONLY_CLOSING_SEQUENCE_PATTERN = /^[ \t]*#+[ \t]*$/;
|
|
@@ -67,7 +67,7 @@ var BlockParser = class {
|
|
|
67
67
|
this.maxNesting = options.maxNesting ?? 250;
|
|
68
68
|
}
|
|
69
69
|
parse(source) {
|
|
70
|
-
const lines = source.split(LINE_ENDING_PATTERN);
|
|
70
|
+
const lines = source.split(require_shared_line_ending.LINE_ENDING_PATTERN);
|
|
71
71
|
const count = source.endsWith("\n") || source.endsWith("\r") ? lines.length - 1 : lines.length;
|
|
72
72
|
for (let index = 0; index < count; index += 1) {
|
|
73
73
|
const text = lines[index];
|
|
@@ -312,7 +312,7 @@ var BlockParser = class {
|
|
|
312
312
|
footnoteDefinitionMayOpenIn(container) {
|
|
313
313
|
let node = container;
|
|
314
314
|
while (node?.kind === "list") node = node.parent;
|
|
315
|
-
return node?.kind === "document";
|
|
315
|
+
return node?.kind === "document" || node?.kind === "blockquote" || node?.kind === "listItem";
|
|
316
316
|
}
|
|
317
317
|
tryHtmlBlockStart(container) {
|
|
318
318
|
if (this.line.indented || this.line.peekNextNonspace() !== "<") return "none";
|
|
@@ -470,8 +470,12 @@ var BlockParser = class {
|
|
|
470
470
|
node.literal = breakIndex === -1 ? "" : node.content.slice(breakIndex + 1);
|
|
471
471
|
}
|
|
472
472
|
};
|
|
473
|
+
const BLOCK_EDGE_SPACE_OR_TAB_PATTERN = /^[ \t]+|[ \t]+$/g;
|
|
474
|
+
function trimBlockContent(text) {
|
|
475
|
+
return (text.endsWith("\n") ? text.slice(0, -1) : text).replace(BLOCK_EDGE_SPACE_OR_TAB_PATTERN, "");
|
|
476
|
+
}
|
|
473
477
|
function toInlineChildren(content, context) {
|
|
474
|
-
return require_inline_inline.parseInlines(content
|
|
478
|
+
return require_inline_inline.parseInlines(trimBlockContent(content), context.references, context.footnotes, context.options);
|
|
475
479
|
}
|
|
476
480
|
function toHeadingNode(node, context) {
|
|
477
481
|
return {
|
|
@@ -618,4 +622,8 @@ function parseMarkdown(source, options = {}) {
|
|
|
618
622
|
};
|
|
619
623
|
}
|
|
620
624
|
//#endregion
|
|
625
|
+
exports.ATX_MARKER_PATTERN = ATX_MARKER_PATTERN;
|
|
626
|
+
exports.CODE_FENCE_PATTERN = CODE_FENCE_PATTERN;
|
|
627
|
+
exports.MATH_BLOCK_MARKER_PATTERN = MATH_BLOCK_MARKER_PATTERN;
|
|
628
|
+
exports.THEMATIC_BREAK_PATTERN = THEMATIC_BREAK_PATTERN;
|
|
621
629
|
exports.parseMarkdown = parseMarkdown;
|
package/dist/block/block.d.cts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { s as MarkdownDocumentNode } from "../ast-
|
|
1
|
+
import { s as MarkdownDocumentNode } from "../ast-CNfTgS0N.cjs";
|
|
2
2
|
import { r as FootnoteLabelSet } from "../footnote-CKk4JbLk.cjs";
|
|
3
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
4
|
-
import {
|
|
5
|
-
import { t as InlineParseOptions } from "../inline-
|
|
3
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.cjs";
|
|
4
|
+
import { LinkReferenceMap } from "../inline/link.cjs";
|
|
5
|
+
import { t as InlineParseOptions } from "../inline-CnO86zMw.cjs";
|
|
6
6
|
//#region src/block/block.d.ts
|
|
7
|
+
declare const ATX_MARKER_PATTERN: RegExp;
|
|
8
|
+
declare const CODE_FENCE_PATTERN: RegExp;
|
|
9
|
+
declare const MATH_BLOCK_MARKER_PATTERN: RegExp;
|
|
10
|
+
declare const THEMATIC_BREAK_PATTERN: RegExp;
|
|
7
11
|
interface MarkdownParseOptions extends InlineParseOptions {
|
|
8
12
|
readonly gfmTables?: boolean;
|
|
9
13
|
readonly gfmTaskLists?: boolean;
|
|
@@ -18,4 +22,4 @@ interface ParsedMarkdown {
|
|
|
18
22
|
}
|
|
19
23
|
declare function parseMarkdown(source: string, options?: MarkdownParseOptions): ParsedMarkdown;
|
|
20
24
|
//#endregion
|
|
21
|
-
export { MarkdownParseOptions, ParsedMarkdown, parseMarkdown };
|
|
25
|
+
export { ATX_MARKER_PATTERN, CODE_FENCE_PATTERN, MATH_BLOCK_MARKER_PATTERN, MarkdownParseOptions, ParsedMarkdown, THEMATIC_BREAK_PATTERN, parseMarkdown };
|
package/dist/block/block.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { s as MarkdownDocumentNode } from "../ast-
|
|
1
|
+
import { s as MarkdownDocumentNode } from "../ast-CNfTgS0N.js";
|
|
2
2
|
import { r as FootnoteLabelSet } from "../footnote-CKk4JbLk.js";
|
|
3
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
4
|
-
import {
|
|
5
|
-
import { t as InlineParseOptions } from "../inline-
|
|
3
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.js";
|
|
4
|
+
import { LinkReferenceMap } from "../inline/link.js";
|
|
5
|
+
import { t as InlineParseOptions } from "../inline-DItZ-VVw.js";
|
|
6
6
|
//#region src/block/block.d.ts
|
|
7
|
+
declare const ATX_MARKER_PATTERN: RegExp;
|
|
8
|
+
declare const CODE_FENCE_PATTERN: RegExp;
|
|
9
|
+
declare const MATH_BLOCK_MARKER_PATTERN: RegExp;
|
|
10
|
+
declare const THEMATIC_BREAK_PATTERN: RegExp;
|
|
7
11
|
interface MarkdownParseOptions extends InlineParseOptions {
|
|
8
12
|
readonly gfmTables?: boolean;
|
|
9
13
|
readonly gfmTaskLists?: boolean;
|
|
@@ -18,4 +22,4 @@ interface ParsedMarkdown {
|
|
|
18
22
|
}
|
|
19
23
|
declare function parseMarkdown(source: string, options?: MarkdownParseOptions): ParsedMarkdown;
|
|
20
24
|
//#endregion
|
|
21
|
-
export { MarkdownParseOptions, ParsedMarkdown, parseMarkdown };
|
|
25
|
+
export { ATX_MARKER_PATTERN, CODE_FENCE_PATTERN, MATH_BLOCK_MARKER_PATTERN, MarkdownParseOptions, ParsedMarkdown, THEMATIC_BREAK_PATTERN, parseMarkdown };
|
package/dist/block/block.js
CHANGED
|
@@ -4,6 +4,7 @@ import { MarkdownDiagnosticCodes, MarkdownNestingLimitExceededError, NOOP_MARKDO
|
|
|
4
4
|
import { matchHtmlBlockStart, matchesHtmlBlockEnd } from "../html/html.js";
|
|
5
5
|
import { unescapeString } from "../inline/entity.js";
|
|
6
6
|
import { parseInlines } from "../inline/inline.js";
|
|
7
|
+
import { LINE_ENDING_PATTERN } from "../shared/line-ending.js";
|
|
7
8
|
import { extractDefinitions } from "./definitions.js";
|
|
8
9
|
import { LineCursor } from "./line.js";
|
|
9
10
|
import { finalizeListTightness, listsMatch, parseListMarker } from "./list.js";
|
|
@@ -13,7 +14,6 @@ import { fitRowToColumns, parseTableDelimiterRow, splitTableRow } from "./table.
|
|
|
13
14
|
const TASK_LIST_MARKER_PATTERN = /^\[([ xX])\][ \t]/;
|
|
14
15
|
const NUL_REPLACEMENT = "�";
|
|
15
16
|
const NUL_PATTERN = /\0/g;
|
|
16
|
-
const LINE_ENDING_PATTERN = /\r\n|\n|\r/;
|
|
17
17
|
const MAYBE_SPECIAL_PATTERN = /^[#$`~*+_=<>[0-9|:-]/;
|
|
18
18
|
const ATX_MARKER_PATTERN = /^#{1,6}(?:[ \t]+|$)/;
|
|
19
19
|
const ATX_ONLY_CLOSING_SEQUENCE_PATTERN = /^[ \t]*#+[ \t]*$/;
|
|
@@ -311,7 +311,7 @@ var BlockParser = class {
|
|
|
311
311
|
footnoteDefinitionMayOpenIn(container) {
|
|
312
312
|
let node = container;
|
|
313
313
|
while (node?.kind === "list") node = node.parent;
|
|
314
|
-
return node?.kind === "document";
|
|
314
|
+
return node?.kind === "document" || node?.kind === "blockquote" || node?.kind === "listItem";
|
|
315
315
|
}
|
|
316
316
|
tryHtmlBlockStart(container) {
|
|
317
317
|
if (this.line.indented || this.line.peekNextNonspace() !== "<") return "none";
|
|
@@ -469,8 +469,12 @@ var BlockParser = class {
|
|
|
469
469
|
node.literal = breakIndex === -1 ? "" : node.content.slice(breakIndex + 1);
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
|
+
const BLOCK_EDGE_SPACE_OR_TAB_PATTERN = /^[ \t]+|[ \t]+$/g;
|
|
473
|
+
function trimBlockContent(text) {
|
|
474
|
+
return (text.endsWith("\n") ? text.slice(0, -1) : text).replace(BLOCK_EDGE_SPACE_OR_TAB_PATTERN, "");
|
|
475
|
+
}
|
|
472
476
|
function toInlineChildren(content, context) {
|
|
473
|
-
return parseInlines(content
|
|
477
|
+
return parseInlines(trimBlockContent(content), context.references, context.footnotes, context.options);
|
|
474
478
|
}
|
|
475
479
|
function toHeadingNode(node, context) {
|
|
476
480
|
return {
|
|
@@ -617,4 +621,4 @@ function parseMarkdown(source, options = {}) {
|
|
|
617
621
|
};
|
|
618
622
|
}
|
|
619
623
|
//#endregion
|
|
620
|
-
export { parseMarkdown };
|
|
624
|
+
export { ATX_MARKER_PATTERN, CODE_FENCE_PATTERN, MATH_BLOCK_MARKER_PATTERN, THEMATIC_BREAK_PATTERN, parseMarkdown };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
2
|
-
import {
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.cjs";
|
|
2
|
+
import { LinkReferenceDefinition } from "../inline/link.cjs";
|
|
3
3
|
//#region src/block/definitions.d.ts
|
|
4
4
|
declare function extractDefinitions(content: string, references: Map<string, LinkReferenceDefinition>, sink?: MarkdownDiagnosticSink, startLine?: number): string;
|
|
5
5
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
2
|
-
import {
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.js";
|
|
2
|
+
import { LinkReferenceDefinition } from "../inline/link.js";
|
|
3
3
|
//#region src/block/definitions.d.ts
|
|
4
4
|
declare function extractDefinitions(content: string, references: Map<string, LinkReferenceDefinition>, sink?: MarkdownDiagnosticSink, startLine?: number): string;
|
|
5
5
|
//#endregion
|
package/dist/block/node.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { E as MarkdownOrderedListDelimiter, N as MarkdownTableAlignment, i as MarkdownBulletMarker } from "../ast-
|
|
1
|
+
import { E as MarkdownOrderedListDelimiter, N as MarkdownTableAlignment, i as MarkdownBulletMarker } from "../ast-CNfTgS0N.cjs";
|
|
2
2
|
import { t as HtmlBlockType } from "../html-bkz2QTuq.cjs";
|
|
3
3
|
//#region src/block/node.d.ts
|
|
4
|
-
type BlockNodeKind =
|
|
4
|
+
type BlockNodeKind = "document" | "paragraph" | "heading" | "blockquote" | "list" | "listItem" | "codeBlock" | "htmlBlock" | "thematicBreak" | "table" | "mathBlock" | "footnoteDefinition";
|
|
5
5
|
type BlockHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
6
6
|
interface ListMarkerData {
|
|
7
|
-
readonly type:
|
|
7
|
+
readonly type: "bullet" | "ordered";
|
|
8
8
|
readonly bulletChar?: MarkdownBulletMarker;
|
|
9
9
|
readonly delimiter?: MarkdownOrderedListDelimiter;
|
|
10
10
|
readonly start?: number;
|
|
@@ -23,7 +23,7 @@ declare class BlockNode {
|
|
|
23
23
|
level: BlockHeadingLevel;
|
|
24
24
|
setext: boolean;
|
|
25
25
|
fenced: boolean;
|
|
26
|
-
fenceChar:
|
|
26
|
+
fenceChar: "`" | "~";
|
|
27
27
|
fenceLength: number;
|
|
28
28
|
fenceOffset: number;
|
|
29
29
|
infoString: string;
|
package/dist/block/node.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { E as MarkdownOrderedListDelimiter, N as MarkdownTableAlignment, i as MarkdownBulletMarker } from "../ast-
|
|
1
|
+
import { E as MarkdownOrderedListDelimiter, N as MarkdownTableAlignment, i as MarkdownBulletMarker } from "../ast-CNfTgS0N.js";
|
|
2
2
|
import { t as HtmlBlockType } from "../html-bkz2QTuq.js";
|
|
3
3
|
//#region src/block/node.d.ts
|
|
4
|
-
type BlockNodeKind =
|
|
4
|
+
type BlockNodeKind = "document" | "paragraph" | "heading" | "blockquote" | "list" | "listItem" | "codeBlock" | "htmlBlock" | "thematicBreak" | "table" | "mathBlock" | "footnoteDefinition";
|
|
5
5
|
type BlockHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
6
6
|
interface ListMarkerData {
|
|
7
|
-
readonly type:
|
|
7
|
+
readonly type: "bullet" | "ordered";
|
|
8
8
|
readonly bulletChar?: MarkdownBulletMarker;
|
|
9
9
|
readonly delimiter?: MarkdownOrderedListDelimiter;
|
|
10
10
|
readonly start?: number;
|
|
@@ -23,7 +23,7 @@ declare class BlockNode {
|
|
|
23
23
|
level: BlockHeadingLevel;
|
|
24
24
|
setext: boolean;
|
|
25
25
|
fenced: boolean;
|
|
26
|
-
fenceChar:
|
|
26
|
+
fenceChar: "`" | "~";
|
|
27
27
|
fenceLength: number;
|
|
28
28
|
fenceOffset: number;
|
|
29
29
|
infoString: string;
|
package/dist/block/table.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as MarkdownTableAlignment } from "../ast-
|
|
1
|
+
import { N as MarkdownTableAlignment } from "../ast-CNfTgS0N.cjs";
|
|
2
2
|
//#region src/block/table.d.ts
|
|
3
3
|
declare function splitTableRow(line: string): string[];
|
|
4
4
|
declare function parseTableDelimiterRow(line: string): MarkdownTableAlignment[] | undefined;
|
package/dist/block/table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as MarkdownTableAlignment } from "../ast-
|
|
1
|
+
import { N as MarkdownTableAlignment } from "../ast-CNfTgS0N.js";
|
|
2
2
|
//#region src/block/table.d.ts
|
|
3
3
|
declare function splitTableRow(line: string): string[];
|
|
4
4
|
declare function parseTableDelimiterRow(line: string): MarkdownTableAlignment[] | undefined;
|
package/dist/codec.cjs
CHANGED
|
@@ -13,7 +13,7 @@ function isWellFormedUtf8Text(bytes) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
const MarkdownBytesSchema = zod.z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
|
|
16
|
-
const markdownCodec = zod.z.codec(MarkdownBytesSchema, document_schema_js.
|
|
16
|
+
const markdownCodec = zod.z.codec(MarkdownBytesSchema, document_schema_js.DocumentTreeSchema, {
|
|
17
17
|
decode: (bytes) => require_read.readMarkdown(new TextDecoder().decode(bytes)).documentPackage,
|
|
18
18
|
encode: (documentPackage) => new TextEncoder().encode(require_write.writeMarkdown(documentPackage))
|
|
19
19
|
});
|