mrkdwn.js 6.7.3 → 6.7.5

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 (54) hide show
  1. package/README.md +2 -1
  2. package/dist/block/definitions.cjs +1 -5
  3. package/dist/block/definitions.js +1 -5
  4. package/dist/block/line.cjs +2 -2
  5. package/dist/block/line.js +2 -2
  6. package/dist/block/list.cjs +7 -14
  7. package/dist/block/list.js +7 -14
  8. package/dist/block/table.cjs +3 -4
  9. package/dist/block/table.js +3 -4
  10. package/dist/emit/emit.cjs +35 -37
  11. package/dist/emit/emit.js +35 -37
  12. package/dist/emit/table.cjs +2 -2
  13. package/dist/emit/table.js +2 -2
  14. package/dist/html/html.cjs +0 -2
  15. package/dist/html/html.js +0 -2
  16. package/dist/html/render.cjs +3 -11
  17. package/dist/html/render.js +3 -11
  18. package/dist/image/image.cjs +0 -49
  19. package/dist/image/image.d.cts +2 -2
  20. package/dist/image/image.d.ts +2 -2
  21. package/dist/image/image.js +1 -48
  22. package/dist/{image-BtmTG4_a.d.cts → image-83yql5ES.d.cts} +1 -3
  23. package/dist/{image-BtmTG4_a.d.ts → image-83yql5ES.d.ts} +1 -3
  24. package/dist/{image-B5L0HpAJ.d.cts → image-B6p0Ovgy.d.cts} +1 -1
  25. package/dist/{image-C390OIB3.d.ts → image-gR1vISI0.d.ts} +1 -1
  26. package/dist/index.d.cts +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/inline/chars.cjs +3 -6
  29. package/dist/inline/chars.js +3 -6
  30. package/dist/inline/delimiter.cjs +5 -12
  31. package/dist/inline/delimiter.d.cts +2 -1
  32. package/dist/inline/delimiter.d.ts +2 -1
  33. package/dist/inline/delimiter.js +5 -13
  34. package/dist/inline/entity.cjs +6 -10
  35. package/dist/inline/entity.js +6 -10
  36. package/dist/inline/link.cjs +4 -5
  37. package/dist/inline/link.js +4 -5
  38. package/dist/lower/front-matter.cjs +4 -8
  39. package/dist/lower/front-matter.js +4 -8
  40. package/dist/lower/image.cjs +3 -2
  41. package/dist/lower/image.d.cts +1 -1
  42. package/dist/lower/image.d.ts +1 -1
  43. package/dist/lower/image.js +2 -1
  44. package/dist/lower/inline.cjs +0 -2
  45. package/dist/lower/inline.js +0 -2
  46. package/dist/options/options.d.cts +1 -1
  47. package/dist/options/options.d.ts +1 -1
  48. package/dist/read.cjs +2 -2
  49. package/dist/read.js +2 -2
  50. package/dist/scan/scan.cjs +1 -3
  51. package/dist/scan/scan.js +1 -3
  52. package/dist/shared/list-id.cjs +1 -1
  53. package/dist/shared/list-id.js +1 -1
  54. package/package.json +3 -2
package/README.md CHANGED
@@ -25,6 +25,7 @@ graph TD
25
25
  schema --> mdcodec
26
26
  schema --> documents
27
27
  bytecodec --> pdfcodec
28
+ bytecodec --> mdcodec
28
29
  ooxml --> documents
29
30
  odf --> documents
30
31
  pdfcodec --> documents
@@ -143,7 +144,7 @@ Modelled on `pdf-codec`'s own layering, aimed at CommonMark+GFM instead of PDF:
143
144
  - **`src/block/`** — CommonMark block-structure algorithm (open-block stack, continuation matching): paragraphs, headings, code blocks, block quotes, lists (incl. GFM task-list-item), thematic breaks, link references, footnote definitions, GFM tables.
144
145
  - **`src/inline/`** — emphasis, code spans, links, autolinks, raw HTML, GFM strikethrough, footnote references, line breaks. `link.ts` and `footnote.ts` hold the label grammars the block phase shares.
145
146
  - **`src/html/`** — raw HTML recognition (bounded rules, not a general parser) plus `render.ts` (conformance oracle; internal only). `html-table.ts` is the one exception to "never parsed as markup": a block-level HTML that is, in full, one well-formed `<table>` recognises straight to a real `ContentTable` instead of opaque text — see [HTML-table fallback](#html-table-fallback).
146
- - **`src/image/`** — PNG/JPEG dimension reader and base64 codec, shared by `src/lower/` and `src/emit/`.
147
+ - **`src/image/`** — PNG/JPEG dimension reader, shared by `src/lower/` and `src/emit/`. The base64 those paths encode and decode a `data:` URI's payload with comes from `byte-codec`.
147
148
  - **`src/shared/`** — string-shape conventions `src/lower`/`src/emit` agree on (`style-constants.ts`, `list-id.ts`'s opaque `numId`). Re-exported so `documents.js`'s `MarkdownEditor` reuses the identical grammar.
148
149
  - **`src/lower/`** — AST → `ContentDocument` lowering (thin adapter, not a second parser); top-of-file table maps each construct to its diagnostic gap.
149
150
  - **`src/emit/`** — `ContentDocument` → markdown text emission, the structural inverse of `src/lower`. `html-table.ts` is `src/html/html-table.ts`'s own write-side counterpart.
@@ -2,10 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_diagnostics_diagnostics = require("../diagnostics/diagnostics.cjs");
3
3
  const require_inline_link = require("../inline/link.cjs");
4
4
  //#region src/block/definitions.ts
5
- const MIN_DEFINITION_LABEL_LENGTH = 3;
6
5
  function parseDefinition(content, start) {
7
6
  const labelLength = require_inline_link.matchLinkLabel(content, start);
8
- if (labelLength < MIN_DEFINITION_LABEL_LENGTH) return;
9
7
  const label = require_inline_link.normalizeLinkLabel(content.slice(start, start + labelLength));
10
8
  if (label.length === 0) return;
11
9
  let cursor = start + labelLength;
@@ -51,9 +49,7 @@ function extractDefinitions(content, references, sink = require_diagnostics_diag
51
49
  }
52
50
  }
53
51
  function countNewlines(content, upTo) {
54
- let count = 0;
55
- for (let index = 0; index < upTo && index < content.length; index += 1) if (content.charAt(index) === "\n") count += 1;
56
- return count;
52
+ return content.slice(0, upTo).split("\n").length - 1;
57
53
  }
58
54
  //#endregion
59
55
  exports.extractDefinitions = extractDefinitions;
@@ -1,10 +1,8 @@
1
1
  import { MarkdownDiagnosticCodes, NOOP_MARKDOWN_DIAGNOSTIC_SINK } from "../diagnostics/diagnostics.js";
2
2
  import { isBlankRemainderOfLine, matchLinkLabel, normalizeLinkLabel, parseLinkDestination, parseLinkTitle, skipInlineWhitespace } from "../inline/link.js";
3
3
  //#region src/block/definitions.ts
4
- const MIN_DEFINITION_LABEL_LENGTH = 3;
5
4
  function parseDefinition(content, start) {
6
5
  const labelLength = matchLinkLabel(content, start);
7
- if (labelLength < MIN_DEFINITION_LABEL_LENGTH) return;
8
6
  const label = normalizeLinkLabel(content.slice(start, start + labelLength));
9
7
  if (label.length === 0) return;
10
8
  let cursor = start + labelLength;
@@ -50,9 +48,7 @@ function extractDefinitions(content, references, sink = NOOP_MARKDOWN_DIAGNOSTIC
50
48
  }
51
49
  }
52
50
  function countNewlines(content, upTo) {
53
- let count = 0;
54
- for (let index = 0; index < upTo && index < content.length; index += 1) if (content.charAt(index) === "\n") count += 1;
55
- return count;
51
+ return content.slice(0, upTo).split("\n").length - 1;
56
52
  }
57
53
  //#endregion
58
54
  export { extractDefinitions };
@@ -7,7 +7,7 @@ var LineCursor = class {
7
7
  cursor;
8
8
  nextNonspaceMark;
9
9
  nextNonspaceColumn = 0;
10
- lineIsBlank = false;
10
+ lineIsBlank;
11
11
  constructor(text) {
12
12
  this.text = text;
13
13
  this.cursor = new require_scan_scan.MarkdownScanCursor(text);
@@ -51,7 +51,7 @@ var LineCursor = class {
51
51
  this.cursor.reset(this.nextNonspaceMark);
52
52
  }
53
53
  advance(columns) {
54
- for (let remaining = columns; remaining > 0; remaining -= 1) if (this.cursor.next() === void 0) return;
54
+ for (let remaining = columns; remaining > 0; remaining -= 1) this.cursor.next();
55
55
  }
56
56
  advanceToEndOfLine() {
57
57
  while (this.cursor.next() !== void 0);
@@ -6,7 +6,7 @@ var LineCursor = class {
6
6
  cursor;
7
7
  nextNonspaceMark;
8
8
  nextNonspaceColumn = 0;
9
- lineIsBlank = false;
9
+ lineIsBlank;
10
10
  constructor(text) {
11
11
  this.text = text;
12
12
  this.cursor = new MarkdownScanCursor(text);
@@ -50,7 +50,7 @@ var LineCursor = class {
50
50
  this.cursor.reset(this.nextNonspaceMark);
51
51
  }
52
52
  advance(columns) {
53
- for (let remaining = columns; remaining > 0; remaining -= 1) if (this.cursor.next() === void 0) return;
53
+ for (let remaining = columns; remaining > 0; remaining -= 1) this.cursor.next();
54
54
  }
55
55
  advanceToEndOfLine() {
56
56
  while (this.cursor.next() !== void 0);
@@ -5,17 +5,10 @@ const BULLET_MARKER_PATTERN = /^[*+-]/;
5
5
  const ORDERED_MARKER_PATTERN = /^(\d{1,9})([.)])/;
6
6
  const NON_SPACE_PATTERN = /[^ \t\f\v\r\n]/;
7
7
  const INTERRUPTING_ORDERED_START = 1;
8
- function isBulletMarker(char) {
9
- return char === "-" || char === "*" || char === "+";
10
- }
11
- function isOrderedDelimiter(char) {
12
- return char === "." || char === ")";
13
- }
14
8
  function matchMarker(rest, indent, containerIsParagraph) {
15
9
  const bullet = BULLET_MARKER_PATTERN.exec(rest);
16
10
  if (bullet !== null) {
17
11
  const char = bullet[0];
18
- if (!isBulletMarker(char)) return;
19
12
  return {
20
13
  length: bullet[0].length,
21
14
  data: {
@@ -26,9 +19,9 @@ function matchMarker(rest, indent, containerIsParagraph) {
26
19
  };
27
20
  }
28
21
  const ordered = ORDERED_MARKER_PATTERN.exec(rest);
29
- const digits = ordered?.[1];
30
- const delimiter = ordered?.[2];
31
- if (ordered === null || digits === void 0 || delimiter === void 0 || !isOrderedDelimiter(delimiter)) return;
22
+ if (ordered === null) return;
23
+ const digits = ordered[1];
24
+ const delimiter = ordered[2];
32
25
  const start = Number.parseInt(digits, 10);
33
26
  if (containerIsParagraph && start !== INTERRUPTING_ORDERED_START) return;
34
27
  return {
@@ -55,12 +48,12 @@ function parseListMarker(line, containerIsParagraph) {
55
48
  const afterMarkerColumn = line.column;
56
49
  do
57
50
  line.advance(1);
58
- while (line.column - afterMarkerColumn <= 4 && line.peek() === " ");
51
+ while (line.peek() === " ");
59
52
  const followingSpaces = line.column - afterMarkerColumn;
60
53
  const startsBlank = line.atEnd;
61
- if (followingSpaces > 4 || followingSpaces < 1 || startsBlank) {
54
+ if (followingSpaces > 4 || startsBlank) {
62
55
  line.reset(afterMarkerMark);
63
- if (line.peek() === " ") line.advance(1);
56
+ line.advance(1);
64
57
  return {
65
58
  ...match.data,
66
59
  padding: match.length + 1
@@ -72,7 +65,7 @@ function parseListMarker(line, containerIsParagraph) {
72
65
  };
73
66
  }
74
67
  function listsMatch(a, b) {
75
- return a.type === b.type && a.delimiter === b.delimiter && a.bulletChar === b.bulletChar;
68
+ return a.delimiter === b.delimiter && a.bulletChar === b.bulletChar;
76
69
  }
77
70
  function endsWithBlankLine(block) {
78
71
  let current = block;
@@ -4,17 +4,10 @@ const BULLET_MARKER_PATTERN = /^[*+-]/;
4
4
  const ORDERED_MARKER_PATTERN = /^(\d{1,9})([.)])/;
5
5
  const NON_SPACE_PATTERN = /[^ \t\f\v\r\n]/;
6
6
  const INTERRUPTING_ORDERED_START = 1;
7
- function isBulletMarker(char) {
8
- return char === "-" || char === "*" || char === "+";
9
- }
10
- function isOrderedDelimiter(char) {
11
- return char === "." || char === ")";
12
- }
13
7
  function matchMarker(rest, indent, containerIsParagraph) {
14
8
  const bullet = BULLET_MARKER_PATTERN.exec(rest);
15
9
  if (bullet !== null) {
16
10
  const char = bullet[0];
17
- if (!isBulletMarker(char)) return;
18
11
  return {
19
12
  length: bullet[0].length,
20
13
  data: {
@@ -25,9 +18,9 @@ function matchMarker(rest, indent, containerIsParagraph) {
25
18
  };
26
19
  }
27
20
  const ordered = ORDERED_MARKER_PATTERN.exec(rest);
28
- const digits = ordered?.[1];
29
- const delimiter = ordered?.[2];
30
- if (ordered === null || digits === void 0 || delimiter === void 0 || !isOrderedDelimiter(delimiter)) return;
21
+ if (ordered === null) return;
22
+ const digits = ordered[1];
23
+ const delimiter = ordered[2];
31
24
  const start = Number.parseInt(digits, 10);
32
25
  if (containerIsParagraph && start !== INTERRUPTING_ORDERED_START) return;
33
26
  return {
@@ -54,12 +47,12 @@ function parseListMarker(line, containerIsParagraph) {
54
47
  const afterMarkerColumn = line.column;
55
48
  do
56
49
  line.advance(1);
57
- while (line.column - afterMarkerColumn <= 4 && line.peek() === " ");
50
+ while (line.peek() === " ");
58
51
  const followingSpaces = line.column - afterMarkerColumn;
59
52
  const startsBlank = line.atEnd;
60
- if (followingSpaces > 4 || followingSpaces < 1 || startsBlank) {
53
+ if (followingSpaces > 4 || startsBlank) {
61
54
  line.reset(afterMarkerMark);
62
- if (line.peek() === " ") line.advance(1);
55
+ line.advance(1);
63
56
  return {
64
57
  ...match.data,
65
58
  padding: match.length + 1
@@ -71,7 +64,7 @@ function parseListMarker(line, containerIsParagraph) {
71
64
  };
72
65
  }
73
66
  function listsMatch(a, b) {
74
- return a.type === b.type && a.delimiter === b.delimiter && a.bulletChar === b.bulletChar;
67
+ return a.delimiter === b.delimiter && a.bulletChar === b.bulletChar;
75
68
  }
76
69
  function endsWithBlankLine(block) {
77
70
  let current = block;
@@ -8,9 +8,9 @@ function splitTableRow(line) {
8
8
  const cells = [];
9
9
  let current = "";
10
10
  let index = 0;
11
- while (index < text.length) {
11
+ while (text.charAt(index) !== "") {
12
12
  const char = text.charAt(index);
13
- if (char === "\\" && index + 1 < text.length) {
13
+ if (char === "\\") {
14
14
  const escaped = text.charAt(index + 1);
15
15
  current += escaped === "|" ? escaped : char + escaped;
16
16
  index += 2;
@@ -31,7 +31,7 @@ function splitTableRow(line) {
31
31
  function endsWithUnescapedPipe(text) {
32
32
  if (!text.endsWith("|")) return false;
33
33
  let backslashes = 0;
34
- while (backslashes + 1 < text.length && text.charAt(text.length - 2 - backslashes) === "\\") backslashes += 1;
34
+ while (text.charAt(text.length - 2 - backslashes) === "\\") backslashes += 1;
35
35
  return backslashes % 2 === 0;
36
36
  }
37
37
  function alignmentOf(cell) {
@@ -45,7 +45,6 @@ function alignmentOf(cell) {
45
45
  function parseTableDelimiterRow(line) {
46
46
  if (!line.includes("|")) return;
47
47
  const cells = splitTableRow(line);
48
- if (cells.length === 0) return;
49
48
  const alignments = [];
50
49
  for (const cell of cells) {
51
50
  if (!DELIMITER_CELL_PATTERN.test(cell)) return;
@@ -7,9 +7,9 @@ function splitTableRow(line) {
7
7
  const cells = [];
8
8
  let current = "";
9
9
  let index = 0;
10
- while (index < text.length) {
10
+ while (text.charAt(index) !== "") {
11
11
  const char = text.charAt(index);
12
- if (char === "\\" && index + 1 < text.length) {
12
+ if (char === "\\") {
13
13
  const escaped = text.charAt(index + 1);
14
14
  current += escaped === "|" ? escaped : char + escaped;
15
15
  index += 2;
@@ -30,7 +30,7 @@ function splitTableRow(line) {
30
30
  function endsWithUnescapedPipe(text) {
31
31
  if (!text.endsWith("|")) return false;
32
32
  let backslashes = 0;
33
- while (backslashes + 1 < text.length && text.charAt(text.length - 2 - backslashes) === "\\") backslashes += 1;
33
+ while (text.charAt(text.length - 2 - backslashes) === "\\") backslashes += 1;
34
34
  return backslashes % 2 === 0;
35
35
  }
36
36
  function alignmentOf(cell) {
@@ -44,7 +44,6 @@ function alignmentOf(cell) {
44
44
  function parseTableDelimiterRow(line) {
45
45
  if (!line.includes("|")) return;
46
46
  const cells = splitTableRow(line);
47
- if (cells.length === 0) return;
48
47
  const alignments = [];
49
48
  for (const cell of cells) {
50
49
  if (!DELIMITER_CELL_PATTERN.test(cell)) return;
@@ -4,7 +4,6 @@ require("../defaults/defaults.cjs");
4
4
  const require_diagnostics_diagnostics = require("../diagnostics/diagnostics.cjs");
5
5
  const require_html_html = require("../html/html.cjs");
6
6
  const require_shared_line_ending = require("../shared/line-ending.cjs");
7
- require("../scan/scan.cjs");
8
7
  const require_block_line = require("../block/line.cjs");
9
8
  const require_block_list = require("../block/list.cjs");
10
9
  const require_block_table = require("../block/table.cjs");
@@ -24,9 +23,13 @@ const MAX_SETEXT_LEVEL = 2;
24
23
  const SETEXT_LEVEL_1_CHAR = "=";
25
24
  const SETEXT_LEVEL_2_CHAR = "-";
26
25
  const MIN_SETEXT_UNDERLINE_LENGTH = 1;
26
+ function splitLines(text, pattern) {
27
+ const [first, ...rest] = text.split(pattern);
28
+ return [first, ...rest];
29
+ }
27
30
  function renderSetextHeading(level, text) {
28
31
  const underlineChar = level === 1 ? SETEXT_LEVEL_1_CHAR : SETEXT_LEVEL_2_CHAR;
29
- const firstLine = text.split(require_shared_line_ending.LINE_ENDING_PATTERN)[0] ?? "";
32
+ const [firstLine] = splitLines(text, require_shared_line_ending.LINE_ENDING_PATTERN);
30
33
  return `${text}\n${underlineChar.repeat(Math.max(MIN_SETEXT_UNDERLINE_LENGTH, firstLine.length))}`;
31
34
  }
32
35
  const MIN_CODE_FENCE_LENGTH = 3;
@@ -54,19 +57,17 @@ function isQuotableStyle(styleId) {
54
57
  return QUOTABLE_STYLE_IDS.has(styleId) || require_shared_style_constants.parseHeadingStyleId(styleId) !== void 0;
55
58
  }
56
59
  function terminatesCleanly(styleId) {
57
- if (styleId === void 0 || styleId === "Quote" || styleId === "HTMLPreformatted") return false;
58
- return styleId === "CodeBlock" || styleId === "MathBlock" || styleId === "HorizontalRule" || require_shared_style_constants.parseHeadingStyleId(styleId) !== void 0;
60
+ return styleId === "CodeBlock" || styleId === "MathBlock" || styleId === "HorizontalRule" || styleId !== void 0 && require_shared_style_constants.parseHeadingStyleId(styleId) !== void 0;
59
61
  }
60
62
  const BLANK_OR_WHITESPACE_ONLY_LINE = /^[ \t]*$/;
61
63
  function firstContentLineIndex(text) {
62
64
  return text.split(require_shared_line_ending.LINE_ENDING_PATTERN).findIndex((line) => !BLANK_OR_WHITESPACE_ONLY_LINE.test(line));
63
65
  }
64
- function leadingIndentColumns(line) {
66
+ function leadingIndentReachesCodeThreshold(line) {
65
67
  let column = 0;
66
- for (const char of line) if (char === " ") column += 1;
67
- else if (char === " ") column += 4 - column % 4;
68
- else break;
69
- return column;
68
+ while (column < line.length && line[column] === " ") column += 1;
69
+ if (column >= 4) return true;
70
+ return line[column] === " ";
70
71
  }
71
72
  const MAX_LEADING_BLANK_LINES_FOR_SETEXT = 1;
72
73
  function interruptsSetextParagraph(line, atBlockStart) {
@@ -95,7 +96,7 @@ function unsafeSetextBreakReason(text) {
95
96
  continue;
96
97
  }
97
98
  sawContentLine = true;
98
- if (leadingIndentColumns(line) >= 4) return "leading-indentation";
99
+ if (leadingIndentReachesCodeThreshold(line)) return "leading-indentation";
99
100
  if (interruptsSetextParagraph(line, true)) return "interrupting-line";
100
101
  precedingLine = line;
101
102
  continue;
@@ -124,7 +125,7 @@ function willRenderAsSetext(paragraph, level, context) {
124
125
  }
125
126
  function canInterruptOpenParagraph(paragraph, context) {
126
127
  const styleId = paragraph.styleId;
127
- if (styleId === void 0 || styleId === "Quote" || styleId === "HTMLPreformatted") return false;
128
+ if (styleId === void 0) return false;
128
129
  if (styleId === "CodeBlock" || styleId === "MathBlock") return true;
129
130
  if (styleId === "HorizontalRule") return context.thematicBreakChar !== SETEXT_LEVEL_2_CHAR;
130
131
  const headingLevel = require_shared_style_constants.parseHeadingStyleId(styleId);
@@ -264,24 +265,24 @@ function toEmitItem(item) {
264
265
  function firstBlockCheckbox(first, taskNumId) {
265
266
  if (first.list.checked !== void 0) return {
266
267
  checkboxText: first.list.checked ? "[x] " : "[ ] ",
267
- stripGlyph: false
268
+ strippedFirstBlock: void 0
268
269
  };
269
270
  if (!taskNumId || first.kind !== "paragraph") return {
270
271
  checkboxText: "",
271
- stripGlyph: false
272
+ strippedFirstBlock: void 0
272
273
  };
273
274
  const leading = first.block.runs[0]?.text ?? "";
274
275
  if (leading.startsWith(`☒ `)) return {
275
276
  checkboxText: "[x] ",
276
- stripGlyph: true
277
+ strippedFirstBlock: stripCheckboxRun(first.block)
277
278
  };
278
279
  if (leading.startsWith(`☐ `)) return {
279
280
  checkboxText: "[ ] ",
280
- stripGlyph: true
281
+ strippedFirstBlock: stripCheckboxRun(first.block)
281
282
  };
282
283
  return {
283
284
  checkboxText: "",
284
- stripGlyph: false
285
+ strippedFirstBlock: void 0
285
286
  };
286
287
  }
287
288
  function renderListItemMarker(numId, info, glyph, checkboxText, context) {
@@ -316,7 +317,7 @@ function resolveListGlyph(numId, type, previousSibling, context) {
316
317
  }
317
318
  function consumeSameItemRun(items, from, level, itemId) {
318
319
  let end = from;
319
- while (end < items.length) {
320
+ for (;;) {
320
321
  const candidate = items[end];
321
322
  if (candidate?.list.level !== level || candidate.list.itemId !== itemId) break;
322
323
  end += 1;
@@ -334,7 +335,7 @@ function collectListItem(items, start, level, itemId) {
334
335
  index = ownEnd;
335
336
  for (;;) {
336
337
  let nestedEnd = index;
337
- while (nestedEnd < items.length) {
338
+ for (;;) {
338
339
  const candidateLevel = items[nestedEnd]?.list.level;
339
340
  if (candidateLevel === void 0 || candidateLevel <= level) break;
340
341
  nestedEnd += 1;
@@ -347,7 +348,6 @@ function collectListItem(items, start, level, itemId) {
347
348
  index = nestedEnd;
348
349
  if (itemId === void 0) break;
349
350
  const resumedEnd = consumeSameItemRun(items, index, level, itemId);
350
- if (resumedEnd === index) break;
351
351
  segments.push({
352
352
  kind: "own",
353
353
  blocks: items.slice(index, resumedEnd)
@@ -378,8 +378,8 @@ function regionItemCanInterrupt(item, context) {
378
378
  function lastStyleIdOfRegionItem(item) {
379
379
  return lastStyleIdOf(toEmitItem(item));
380
380
  }
381
- function listRegionItemBody(item, context, stripGlyph) {
382
- if (item.kind === "paragraph") return renderParagraphBody(stripGlyph ? stripCheckboxRun(item.block) : item.block, context);
381
+ function listRegionItemBody(item, context, overrideParagraph) {
382
+ if (item.kind === "paragraph") return renderParagraphBody(overrideParagraph ?? item.block, context);
383
383
  const previousEnclosingItemId = context.enclosingItemId;
384
384
  context.enclosingItemId = item.list.itemId;
385
385
  const body = renderConstruct(item.item, context);
@@ -394,14 +394,14 @@ function renderListRegion(items, context) {
394
394
  const parts = [];
395
395
  let index = 0;
396
396
  let previousSibling;
397
- while (index < items.length) {
397
+ for (;;) {
398
398
  const item = items[index];
399
399
  if (item === void 0) break;
400
400
  const { numId, level, itemId } = item.list;
401
401
  const info = listInfoFor(numId, context);
402
402
  const loose = info?.loose === true;
403
403
  const type = info?.type ?? "bullet";
404
- const glyph = numId === void 0 ? type === "ordered" ? context.orderedDelimiter : context.bulletMarker : resolveListGlyph(numId, type, previousSibling, context);
404
+ const glyph = numId === void 0 ? context.bulletMarker : resolveListGlyph(numId, type, previousSibling, context);
405
405
  if (numId !== void 0) previousSibling = {
406
406
  numId,
407
407
  type,
@@ -410,7 +410,7 @@ function renderListRegion(items, context) {
410
410
  const { segments, next } = collectListItem(items, index, level, itemId);
411
411
  const first = segments[0]?.blocks[0];
412
412
  if (first === void 0) break;
413
- const { checkboxText, stripGlyph } = firstBlockCheckbox(first, info?.task === true);
413
+ const { checkboxText, strippedFirstBlock } = firstBlockCheckbox(first, info?.task === true);
414
414
  const marker = renderListItemMarker(numId, info, glyph, checkboxText, context);
415
415
  const indent = " ".repeat(marker.bareLength);
416
416
  let text = "";
@@ -426,13 +426,13 @@ function renderListRegion(items, context) {
426
426
  }
427
427
  for (const block of segment.blocks) {
428
428
  if (!renderedFirstLine) {
429
- const [firstLine = "", ...restLines] = listRegionItemBody(block, context, stripGlyph).split("\n");
429
+ const [firstLine, ...restLines] = splitLines(listRegionItemBody(block, context, strippedFirstBlock), "\n");
430
430
  text = [`${marker.full}${firstLine}`, ...restLines.map((line) => `${indent}${line}`)].join("\n");
431
431
  renderedFirstLine = true;
432
432
  previousStyleId = lastStyleIdOfRegionItem(block);
433
433
  continue;
434
434
  }
435
- const rendered = listRegionItemBody(block, context, false).split("\n").map((line) => line.length === 0 ? line : `${indent}${line}`).join("\n");
435
+ const rendered = listRegionItemBody(block, context, void 0).split("\n").map((line) => line.length === 0 ? line : `${indent}${line}`).join("\n");
436
436
  const blank = loose || requiresBlankLineBefore(block, previousStyleId, context);
437
437
  text += blank ? `\n\n${rendered}` : `\n${rendered}`;
438
438
  previousStyleId = lastStyleIdOfRegionItem(block);
@@ -468,7 +468,7 @@ function isMaterialisedDivision(item) {
468
468
  function groupConstructItems(blocks, start) {
469
469
  const items = [];
470
470
  let index = start;
471
- while (index < blocks.length) {
471
+ for (;;) {
472
472
  const block = blocks[index];
473
473
  if (block === void 0) break;
474
474
  index += 1;
@@ -497,7 +497,7 @@ function renderFootnoteDefinition(name, body) {
497
497
  const marker = `[^${name}]:`;
498
498
  if (body.length === 0) return marker;
499
499
  const indent = " ".repeat(FOOTNOTE_CONTINUATION_INDENT);
500
- const [firstLine = "", ...restLines] = body.split("\n");
500
+ const [firstLine, ...restLines] = splitLines(body, "\n");
501
501
  return [`${marker} ${firstLine}`, ...restLines.map((line) => line.length === 0 ? line : `${indent}${line}`)].join("\n");
502
502
  }
503
503
  function renderConstruct(item, context) {
@@ -512,13 +512,11 @@ function renderConstruct(item, context) {
512
512
  });
513
513
  return body;
514
514
  }
515
- if (descriptor.kind === "division") {
516
- if (isMaterialisedDivision(item)) {
517
- context.divisionDepth += 1;
518
- const body = renderItems(item.children, context);
519
- context.divisionDepth -= 1;
520
- return body.split("\n").map((line) => line.length === 0 ? ">" : `> ${line}`).join("\n");
521
- }
515
+ if (isMaterialisedDivision(item)) {
516
+ context.divisionDepth += 1;
517
+ const body = renderItems(item.children, context);
518
+ context.divisionDepth -= 1;
519
+ return body.split("\n").map((line) => line.length === 0 ? ">" : `> ${line}`).join("\n");
522
520
  }
523
521
  if (descriptor.kind === "link" && descriptor.target.kind === "external") {
524
522
  const onlyChild = item.children.length === 1 && !isConstructItem(item.children[0]) ? item.children[0].block : void 0;
@@ -549,7 +547,7 @@ function isInheritedListMembership(list, context) {
549
547
  function renderItems(items, context) {
550
548
  const parts = [];
551
549
  let index = 0;
552
- while (index < items.length) {
550
+ for (;;) {
553
551
  const item = items[index];
554
552
  if (item === void 0) break;
555
553
  if (isConstructItem(item)) {
@@ -612,7 +610,7 @@ function emitBlocks(blocks, context) {
612
610
  }
613
611
  function validateRunConstructExtents(blocks) {
614
612
  for (const block of blocks) {
615
- if (block.kind === "paragraph" && block.constructs !== void 0) {
613
+ if (block.kind === "paragraph") {
616
614
  const fault = (0, document_schema_js.findRunConstructFault)(block);
617
615
  if (fault !== void 0) throw new require_diagnostics_diagnostics.MarkdownInvalidRunConstructExtentError(fault.kind, fault.index);
618
616
  }