mrkdwn.js 4.0.6 → 6.6.2

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.
Files changed (118) hide show
  1. package/README.md +85 -66
  2. package/dist/ast/ast.d.cts +1 -1
  3. package/dist/ast/ast.d.ts +1 -1
  4. package/dist/{ast-8XCbjRQT.d.cts → ast-CNfTgS0N.d.cts} +35 -35
  5. package/dist/{ast-8XCbjRQT.d.ts → ast-CNfTgS0N.d.ts} +35 -35
  6. package/dist/block/block.cjs +12 -4
  7. package/dist/block/block.d.cts +9 -5
  8. package/dist/block/block.d.ts +9 -5
  9. package/dist/block/block.js +8 -4
  10. package/dist/block/definitions.d.cts +2 -2
  11. package/dist/block/definitions.d.ts +2 -2
  12. package/dist/block/node.d.cts +4 -4
  13. package/dist/block/node.d.ts +4 -4
  14. package/dist/block/table.d.cts +1 -1
  15. package/dist/block/table.d.ts +1 -1
  16. package/dist/codec.cjs +1 -1
  17. package/dist/codec.d.cts +1631 -29
  18. package/dist/codec.d.ts +1631 -29
  19. package/dist/codec.js +2 -2
  20. package/dist/defaults/defaults.d.cts +1 -1
  21. package/dist/defaults/defaults.d.ts +1 -1
  22. package/dist/diagnostics/diagnostics.cjs +17 -7
  23. package/dist/diagnostics/diagnostics.d.cts +2 -2
  24. package/dist/diagnostics/diagnostics.d.ts +2 -2
  25. package/dist/diagnostics/diagnostics.js +17 -8
  26. package/dist/{diagnostics-BWK1iGy7.d.cts → diagnostics-CjfBoW4K.d.cts} +14 -10
  27. package/dist/{diagnostics-BWK1iGy7.d.ts → diagnostics-CjfBoW4K.d.ts} +14 -10
  28. package/dist/emit/emit.cjs +378 -42
  29. package/dist/emit/emit.js +381 -45
  30. package/dist/emit/front-matter.cjs +22 -5
  31. package/dist/emit/front-matter.js +22 -5
  32. package/dist/emit/html-table.cjs +104 -0
  33. package/dist/emit/html-table.d.cts +7 -0
  34. package/dist/emit/html-table.d.ts +7 -0
  35. package/dist/emit/html-table.js +102 -0
  36. package/dist/emit/inline.cjs +69 -26
  37. package/dist/emit/inline.d.cts +2 -12
  38. package/dist/emit/inline.d.ts +2 -12
  39. package/dist/emit/inline.js +68 -27
  40. package/dist/emit/table.cjs +18 -11
  41. package/dist/emit/table.d.cts +3 -2
  42. package/dist/emit/table.d.ts +3 -2
  43. package/dist/emit/table.js +18 -11
  44. package/dist/html/html-table.cjs +243 -0
  45. package/dist/html/html-table.d.cts +5 -0
  46. package/dist/html/html-table.d.ts +5 -0
  47. package/dist/html/html-table.js +242 -0
  48. package/dist/html/render.d.cts +1 -1
  49. package/dist/html/render.d.ts +1 -1
  50. package/dist/image/image.cjs +4 -4
  51. package/dist/image/image.d.cts +1 -1
  52. package/dist/image/image.d.ts +1 -1
  53. package/dist/image/image.js +4 -4
  54. package/dist/{image-C4KYmz_L.d.cts → image-B5L0HpAJ.d.cts} +1 -1
  55. package/dist/{image-DescdRgq.d.cts → image-BtmTG4_a.d.cts} +1 -1
  56. package/dist/{image-DescdRgq.d.ts → image-BtmTG4_a.d.ts} +1 -1
  57. package/dist/{image-Cm3hT5PS.d.ts → image-C390OIB3.d.ts} +1 -1
  58. package/dist/index.cjs +2 -2
  59. package/dist/index.d.cts +4 -4
  60. package/dist/index.d.ts +4 -4
  61. package/dist/index.js +3 -3
  62. package/dist/inline/delimiter.d.cts +2 -2
  63. package/dist/inline/delimiter.d.ts +2 -2
  64. package/dist/inline/inline.d.cts +1 -1
  65. package/dist/inline/inline.d.ts +1 -1
  66. package/dist/inline/link.d.cts +17 -1
  67. package/dist/inline/link.d.ts +17 -1
  68. package/dist/inline/node.d.cts +2 -2
  69. package/dist/inline/node.d.ts +2 -2
  70. package/dist/{inline-CXVQWQnW.d.cts → inline-CnO86zMw.d.cts} +2 -2
  71. package/dist/inline-DCIKQ83j.d.cts +14 -0
  72. package/dist/{inline-B_V7bs5j.d.ts → inline-DItZ-VVw.d.ts} +2 -2
  73. package/dist/inline-INoDAG37.d.ts +14 -0
  74. package/dist/lower/front-matter.cjs +73 -26
  75. package/dist/lower/front-matter.d.cts +2 -1
  76. package/dist/lower/front-matter.d.ts +2 -1
  77. package/dist/lower/front-matter.js +72 -25
  78. package/dist/lower/image.d.cts +1 -1
  79. package/dist/lower/image.d.ts +1 -1
  80. package/dist/lower/inline.cjs +87 -33
  81. package/dist/lower/inline.d.cts +9 -12
  82. package/dist/lower/inline.d.ts +9 -12
  83. package/dist/lower/inline.js +89 -34
  84. package/dist/lower/lower.cjs +143 -113
  85. package/dist/lower/lower.d.cts +8 -1
  86. package/dist/lower/lower.d.ts +8 -1
  87. package/dist/lower/lower.js +144 -115
  88. package/dist/lower/table.cjs +3 -2
  89. package/dist/lower/table.d.cts +1 -1
  90. package/dist/lower/table.d.ts +1 -1
  91. package/dist/lower/table.js +3 -2
  92. package/dist/options/options.d.cts +10 -10
  93. package/dist/options/options.d.ts +10 -10
  94. package/dist/read.cjs +45 -9
  95. package/dist/read.d.cts +3 -3
  96. package/dist/read.d.ts +3 -3
  97. package/dist/read.js +47 -11
  98. package/dist/scan/entity-table.cjs +2125 -2125
  99. package/dist/scan/entity-table.js +2125 -2125
  100. package/dist/shared/line-ending.cjs +7 -0
  101. package/dist/shared/line-ending.d.cts +5 -0
  102. package/dist/shared/line-ending.d.ts +5 -0
  103. package/dist/shared/line-ending.js +5 -0
  104. package/dist/shared/list-id.cjs +11 -3
  105. package/dist/shared/list-id.d.cts +7 -4
  106. package/dist/shared/list-id.d.ts +7 -4
  107. package/dist/shared/list-id.js +11 -4
  108. package/dist/shared/style-constants.cjs +0 -2
  109. package/dist/shared/style-constants.d.cts +1 -2
  110. package/dist/shared/style-constants.d.ts +1 -2
  111. package/dist/shared/style-constants.js +1 -2
  112. package/dist/write.cjs +33 -6
  113. package/dist/write.d.cts +2 -2
  114. package/dist/write.d.ts +2 -2
  115. package/dist/write.js +34 -7
  116. package/package.json +29 -30
  117. package/dist/link-Dv4kxVjk.d.cts +0 -18
  118. 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: 'document';
11
+ readonly type: "document";
12
12
  readonly children: MarkdownBlockNode[];
13
13
  readonly position?: MarkdownPosition;
14
14
  }
15
15
  interface MarkdownParagraphNode {
16
- readonly type: 'paragraph';
16
+ readonly type: "paragraph";
17
17
  readonly children: MarkdownInlineNode[];
18
18
  readonly position?: MarkdownPosition;
19
19
  }
20
- type MarkdownHeadingStyle = 'atx' | 'setext';
20
+ type MarkdownHeadingStyle = "atx" | "setext";
21
21
  interface MarkdownHeadingNode {
22
- readonly type: 'heading';
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: 'blockquote';
29
+ readonly type: "blockquote";
30
30
  readonly children: MarkdownBlockNode[];
31
31
  readonly position?: MarkdownPosition;
32
32
  }
33
- type MarkdownListMarkerType = 'bullet' | 'ordered';
34
- type MarkdownBulletMarker = '-' | '*' | '+';
35
- type MarkdownOrderedListDelimiter = '.' | ')';
33
+ type MarkdownListMarkerType = "bullet" | "ordered";
34
+ type MarkdownBulletMarker = "-" | "*" | "+";
35
+ type MarkdownOrderedListDelimiter = "." | ")";
36
36
  interface MarkdownListNode {
37
- readonly type: 'list';
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: 'listItem';
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: 'codeBlock';
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: 'thematicBreak';
61
+ readonly type: "thematicBreak";
62
62
  readonly position?: MarkdownPosition;
63
63
  }
64
64
  interface MarkdownHtmlBlockNode {
65
- readonly type: 'htmlBlock';
65
+ readonly type: "htmlBlock";
66
66
  readonly literal: string;
67
67
  readonly position?: MarkdownPosition;
68
68
  }
69
- type MarkdownTableAlignment = 'left' | 'right' | 'center' | 'none';
69
+ type MarkdownTableAlignment = "left" | "right" | "center" | "none";
70
70
  interface MarkdownTableNode {
71
- readonly type: 'table';
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: 'tableRow';
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: 'tableCell';
83
+ readonly type: "tableCell";
84
84
  readonly children: MarkdownInlineNode[];
85
85
  readonly position?: MarkdownPosition;
86
86
  }
87
87
  interface MarkdownMathBlockNode {
88
- readonly type: 'mathBlock';
88
+ readonly type: "mathBlock";
89
89
  readonly literal: string;
90
90
  readonly position?: MarkdownPosition;
91
91
  }
92
92
  interface MarkdownFootnoteDefinitionNode {
93
- readonly type: 'footnoteDefinition';
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: 'text';
101
+ readonly type: "text";
102
102
  readonly value: string;
103
103
  readonly position?: MarkdownPosition;
104
104
  }
105
105
  interface MarkdownEmphasisNode {
106
- readonly type: 'emphasis';
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: 'strong';
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: 'strikethrough';
118
+ readonly type: "strikethrough";
119
119
  readonly children: MarkdownInlineNode[];
120
120
  readonly position?: MarkdownPosition;
121
121
  }
122
122
  interface MarkdownCodeSpanNode {
123
- readonly type: 'codeSpan';
123
+ readonly type: "codeSpan";
124
124
  readonly literal: string;
125
125
  readonly position?: MarkdownPosition;
126
126
  }
127
127
  interface MarkdownLinkNode {
128
- readonly type: 'link';
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: 'image';
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: 'autolink';
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: 'hardBreak';
150
+ readonly type: "hardBreak";
151
151
  readonly position?: MarkdownPosition;
152
152
  }
153
153
  interface MarkdownSoftBreakNode {
154
- readonly type: 'softBreak';
154
+ readonly type: "softBreak";
155
155
  readonly position?: MarkdownPosition;
156
156
  }
157
157
  interface MarkdownRawHtmlNode {
158
- readonly type: 'rawHtml';
158
+ readonly type: "rawHtml";
159
159
  readonly literal: string;
160
160
  readonly position?: MarkdownPosition;
161
161
  }
162
162
  interface MarkdownEntityNode {
163
- readonly type: 'entity';
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: 'mathInline';
169
+ readonly type: "mathInline";
170
170
  readonly literal: string;
171
171
  readonly position?: MarkdownPosition;
172
172
  }
173
173
  interface MarkdownFootnoteReferenceNode {
174
- readonly type: 'footnoteReference';
174
+ readonly type: "footnoteReference";
175
175
  readonly label: string;
176
176
  readonly position?: MarkdownPosition;
177
177
  }
@@ -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.trim(), context.references, context.footnotes, context.options);
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;
@@ -1,9 +1,13 @@
1
- import { s as MarkdownDocumentNode } from "../ast-8XCbjRQT.cjs";
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-BWK1iGy7.cjs";
4
- import { n as LinkReferenceMap } from "../link-Dv4kxVjk.cjs";
5
- import { t as InlineParseOptions } from "../inline-CXVQWQnW.cjs";
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 };
@@ -1,9 +1,13 @@
1
- import { s as MarkdownDocumentNode } from "../ast-8XCbjRQT.js";
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-BWK1iGy7.js";
4
- import { n as LinkReferenceMap } from "../link-Dv4kxVjk.js";
5
- import { t as InlineParseOptions } from "../inline-B_V7bs5j.js";
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 };
@@ -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.trim(), context.references, context.footnotes, context.options);
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-BWK1iGy7.cjs";
2
- import { t as LinkReferenceDefinition } from "../link-Dv4kxVjk.cjs";
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-BWK1iGy7.js";
2
- import { t as LinkReferenceDefinition } from "../link-Dv4kxVjk.js";
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
@@ -1,10 +1,10 @@
1
- import { E as MarkdownOrderedListDelimiter, N as MarkdownTableAlignment, i as MarkdownBulletMarker } from "../ast-8XCbjRQT.cjs";
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 = 'document' | 'paragraph' | 'heading' | 'blockquote' | 'list' | 'listItem' | 'codeBlock' | 'htmlBlock' | 'thematicBreak' | 'table' | 'mathBlock' | 'footnoteDefinition';
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: 'bullet' | 'ordered';
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;
@@ -1,10 +1,10 @@
1
- import { E as MarkdownOrderedListDelimiter, N as MarkdownTableAlignment, i as MarkdownBulletMarker } from "../ast-8XCbjRQT.js";
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 = 'document' | 'paragraph' | 'heading' | 'blockquote' | 'list' | 'listItem' | 'codeBlock' | 'htmlBlock' | 'thematicBreak' | 'table' | 'mathBlock' | 'footnoteDefinition';
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: 'bullet' | 'ordered';
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;
@@ -1,4 +1,4 @@
1
- import { N as MarkdownTableAlignment } from "../ast-8XCbjRQT.cjs";
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;
@@ -1,4 +1,4 @@
1
- import { N as MarkdownTableAlignment } from "../ast-8XCbjRQT.js";
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.DocumentPackageSchema, {
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
  });