markdown-codec 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 (56) 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/codec.d.cts +36 -36
  11. package/dist/codec.d.ts +36 -36
  12. package/dist/emit/emit.cjs +35 -37
  13. package/dist/emit/emit.js +35 -37
  14. package/dist/emit/table.cjs +2 -2
  15. package/dist/emit/table.js +2 -2
  16. package/dist/html/html.cjs +0 -2
  17. package/dist/html/html.js +0 -2
  18. package/dist/html/render.cjs +3 -11
  19. package/dist/html/render.js +3 -11
  20. package/dist/image/image.cjs +0 -49
  21. package/dist/image/image.d.cts +2 -2
  22. package/dist/image/image.d.ts +2 -2
  23. package/dist/image/image.js +1 -48
  24. package/dist/{image-BtmTG4_a.d.cts → image-83yql5ES.d.cts} +1 -3
  25. package/dist/{image-BtmTG4_a.d.ts → image-83yql5ES.d.ts} +1 -3
  26. package/dist/{image-B5L0HpAJ.d.cts → image-B6p0Ovgy.d.cts} +1 -1
  27. package/dist/{image-C390OIB3.d.ts → image-gR1vISI0.d.ts} +1 -1
  28. package/dist/index.d.cts +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/inline/chars.cjs +3 -6
  31. package/dist/inline/chars.js +3 -6
  32. package/dist/inline/delimiter.cjs +5 -12
  33. package/dist/inline/delimiter.d.cts +2 -1
  34. package/dist/inline/delimiter.d.ts +2 -1
  35. package/dist/inline/delimiter.js +5 -13
  36. package/dist/inline/entity.cjs +6 -10
  37. package/dist/inline/entity.js +6 -10
  38. package/dist/inline/link.cjs +4 -5
  39. package/dist/inline/link.js +4 -5
  40. package/dist/lower/front-matter.cjs +4 -8
  41. package/dist/lower/front-matter.js +4 -8
  42. package/dist/lower/image.cjs +3 -2
  43. package/dist/lower/image.d.cts +1 -1
  44. package/dist/lower/image.d.ts +1 -1
  45. package/dist/lower/image.js +2 -1
  46. package/dist/lower/inline.cjs +0 -2
  47. package/dist/lower/inline.js +0 -2
  48. package/dist/options/options.d.cts +1 -1
  49. package/dist/options/options.d.ts +1 -1
  50. package/dist/read.cjs +2 -2
  51. package/dist/read.js +2 -2
  52. package/dist/scan/scan.cjs +1 -3
  53. package/dist/scan/scan.js +1 -3
  54. package/dist/shared/list-id.cjs +1 -1
  55. package/dist/shared/list-id.js +1 -1
  56. package/package.json +3 -2
package/dist/codec.d.ts CHANGED
@@ -17,8 +17,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
17
17
  paragraph: z.ZodOptional<z.ZodObject<{
18
18
  alignment: z.ZodOptional<z.ZodEnum<{
19
19
  left: "left";
20
- center: "center";
21
20
  right: "right";
21
+ center: "center";
22
22
  justify: "justify";
23
23
  }>>;
24
24
  list: z.ZodOptional<z.ZodObject<{
@@ -172,8 +172,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
172
172
  paragraph: z.ZodOptional<z.ZodObject<{
173
173
  alignment: z.ZodOptional<z.ZodEnum<{
174
174
  left: "left";
175
- center: "center";
176
175
  right: "right";
176
+ center: "center";
177
177
  justify: "justify";
178
178
  }>>;
179
179
  list: z.ZodOptional<z.ZodObject<{
@@ -332,8 +332,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
332
332
  paragraph: z.ZodOptional<z.ZodObject<{
333
333
  alignment: z.ZodOptional<z.ZodEnum<{
334
334
  left: "left";
335
- center: "center";
336
335
  right: "right";
336
+ center: "center";
337
337
  justify: "justify";
338
338
  }>>;
339
339
  list: z.ZodOptional<z.ZodObject<{
@@ -487,8 +487,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
487
487
  paragraph: z.ZodOptional<z.ZodObject<{
488
488
  alignment: z.ZodOptional<z.ZodEnum<{
489
489
  left: "left";
490
- center: "center";
491
490
  right: "right";
491
+ center: "center";
492
492
  justify: "justify";
493
493
  }>>;
494
494
  list: z.ZodOptional<z.ZodObject<{
@@ -629,12 +629,12 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
629
629
  }, z.core.$strip>, z.ZodObject<{
630
630
  children: z.ZodArray<z.ZodObject<{
631
631
  origin: z.ZodOptional<z.ZodEnum<{
632
+ body: "body";
632
633
  chart: "chart";
633
634
  diagram: "diagram";
634
635
  table: "table";
635
636
  image: "image";
636
637
  notes: "notes";
637
- body: "body";
638
638
  }>>;
639
639
  interpretation: z.ZodOptional<z.ZodObject<{
640
640
  transcript: z.ZodOptional<z.ZodObject<{
@@ -701,8 +701,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
701
701
  paragraph: z.ZodOptional<z.ZodObject<{
702
702
  alignment: z.ZodOptional<z.ZodEnum<{
703
703
  left: "left";
704
- center: "center";
705
704
  right: "right";
705
+ center: "center";
706
706
  justify: "justify";
707
707
  }>>;
708
708
  list: z.ZodOptional<z.ZodObject<{
@@ -844,12 +844,12 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
844
844
  declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodDiscriminatedUnion<[z.ZodObject<{
845
845
  sections: z.ZodArray<z.ZodObject<{
846
846
  origin: z.ZodOptional<z.ZodEnum<{
847
+ body: "body";
847
848
  chart: "chart";
848
849
  diagram: "diagram";
849
850
  table: "table";
850
851
  image: "image";
851
852
  notes: "notes";
852
- body: "body";
853
853
  }>>;
854
854
  interpretation: z.ZodOptional<z.ZodObject<{
855
855
  transcript: z.ZodOptional<z.ZodObject<{
@@ -993,12 +993,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
993
993
  }, z.core.$strip>, z.ZodObject<{
994
994
  slides: z.ZodArray<z.ZodObject<{
995
995
  origin: z.ZodOptional<z.ZodEnum<{
996
+ body: "body";
996
997
  chart: "chart";
997
998
  diagram: "diagram";
998
999
  table: "table";
999
1000
  image: "image";
1000
1001
  notes: "notes";
1001
- body: "body";
1002
1002
  }>>;
1003
1003
  interpretation: z.ZodOptional<z.ZodObject<{
1004
1004
  transcript: z.ZodOptional<z.ZodObject<{
@@ -1026,12 +1026,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1026
1026
  shapes: z.ZodArray<z.ZodObject<{
1027
1027
  blocks: z.ZodLazy<z.ZodArray<z.ZodType<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock, z.core.$ZodTypeInternals<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock>>>>;
1028
1028
  origin: z.ZodOptional<z.ZodEnum<{
1029
+ body: "body";
1029
1030
  chart: "chart";
1030
1031
  diagram: "diagram";
1031
1032
  table: "table";
1032
1033
  image: "image";
1033
1034
  notes: "notes";
1034
- body: "body";
1035
1035
  }>>;
1036
1036
  interpretation: z.ZodOptional<z.ZodObject<{
1037
1037
  transcript: z.ZodOptional<z.ZodObject<{
@@ -1189,12 +1189,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1189
1189
  }, z.core.$strip>, z.ZodObject<{
1190
1190
  sheets: z.ZodArray<z.ZodObject<{
1191
1191
  origin: z.ZodOptional<z.ZodEnum<{
1192
+ body: "body";
1192
1193
  chart: "chart";
1193
1194
  diagram: "diagram";
1194
1195
  table: "table";
1195
1196
  image: "image";
1196
1197
  notes: "notes";
1197
- body: "body";
1198
1198
  }>>;
1199
1199
  interpretation: z.ZodOptional<z.ZodObject<{
1200
1200
  transcript: z.ZodOptional<z.ZodObject<{
@@ -1218,12 +1218,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1218
1218
  name: z.ZodString;
1219
1219
  cells: z.ZodArray<z.ZodObject<{
1220
1220
  origin: z.ZodOptional<z.ZodEnum<{
1221
+ body: "body";
1221
1222
  chart: "chart";
1222
1223
  diagram: "diagram";
1223
1224
  table: "table";
1224
1225
  image: "image";
1225
1226
  notes: "notes";
1226
- body: "body";
1227
1227
  }>>;
1228
1228
  interpretation: z.ZodOptional<z.ZodObject<{
1229
1229
  transcript: z.ZodOptional<z.ZodObject<{
@@ -1298,12 +1298,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1298
1298
  }, z.core.$strip>>;
1299
1299
  runs: z.ZodOptional<z.ZodArray<z.ZodObject<{
1300
1300
  origin: z.ZodOptional<z.ZodEnum<{
1301
+ body: "body";
1301
1302
  chart: "chart";
1302
1303
  diagram: "diagram";
1303
1304
  table: "table";
1304
1305
  image: "image";
1305
1306
  notes: "notes";
1306
- body: "body";
1307
1307
  }>>;
1308
1308
  interpretation: z.ZodOptional<z.ZodObject<{
1309
1309
  transcript: z.ZodOptional<z.ZodObject<{
@@ -1538,8 +1538,8 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1538
1538
  }, z.core.$strip>>;
1539
1539
  alignment: z.ZodOptional<z.ZodEnum<{
1540
1540
  left: "left";
1541
- center: "center";
1542
1541
  right: "right";
1542
+ center: "center";
1543
1543
  justify: "justify";
1544
1544
  }>>;
1545
1545
  verticalAlignment: z.ZodOptional<z.ZodEnum<{
@@ -1597,12 +1597,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1597
1597
  }, z.core.$strip>>;
1598
1598
  images: z.ZodArray<z.ZodObject<{
1599
1599
  origin: z.ZodOptional<z.ZodEnum<{
1600
+ body: "body";
1600
1601
  chart: "chart";
1601
1602
  diagram: "diagram";
1602
1603
  table: "table";
1603
1604
  image: "image";
1604
1605
  notes: "notes";
1605
- body: "body";
1606
1606
  }>>;
1607
1607
  interpretation: z.ZodOptional<z.ZodObject<{
1608
1608
  transcript: z.ZodOptional<z.ZodObject<{
@@ -1681,10 +1681,10 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1681
1681
  }>;
1682
1682
  align: z.ZodEnum<{
1683
1683
  left: "left";
1684
- center: "center";
1685
1684
  right: "right";
1686
1685
  top: "top";
1687
1686
  bottom: "bottom";
1687
+ center: "center";
1688
1688
  inside: "inside";
1689
1689
  outside: "outside";
1690
1690
  }>;
@@ -1724,10 +1724,10 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1724
1724
  }>;
1725
1725
  align: z.ZodEnum<{
1726
1726
  left: "left";
1727
- center: "center";
1728
1727
  right: "right";
1729
1728
  top: "top";
1730
1729
  bottom: "bottom";
1730
+ center: "center";
1731
1731
  inside: "inside";
1732
1732
  outside: "outside";
1733
1733
  }>;
@@ -1818,9 +1818,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1818
1818
  type: z.ZodEnum<{
1819
1819
  date: "date";
1820
1820
  custom: "custom";
1821
+ time: "time";
1821
1822
  decimal: "decimal";
1822
1823
  list: "list";
1823
- time: "time";
1824
1824
  whole: "whole";
1825
1825
  textLength: "textLength";
1826
1826
  }>;
@@ -2291,11 +2291,11 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2291
2291
  stops: z.ZodArray<z.ZodObject<{
2292
2292
  value: z.ZodObject<{
2293
2293
  type: z.ZodEnum<{
2294
- formula: "formula";
2295
- percent: "percent";
2296
2294
  num: "num";
2297
- max: "max";
2298
2295
  min: "min";
2296
+ max: "max";
2297
+ formula: "formula";
2298
+ percent: "percent";
2299
2299
  percentile: "percentile";
2300
2300
  }>;
2301
2301
  value: z.ZodOptional<z.ZodString>;
@@ -2338,22 +2338,22 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2338
2338
  }, z.core.$strip>, z.ZodObject<{
2339
2339
  min: z.ZodObject<{
2340
2340
  type: z.ZodEnum<{
2341
- formula: "formula";
2342
- percent: "percent";
2343
2341
  num: "num";
2344
- max: "max";
2345
2342
  min: "min";
2343
+ max: "max";
2344
+ formula: "formula";
2345
+ percent: "percent";
2346
2346
  percentile: "percentile";
2347
2347
  }>;
2348
2348
  value: z.ZodOptional<z.ZodString>;
2349
2349
  }, z.core.$strip>;
2350
2350
  max: z.ZodObject<{
2351
2351
  type: z.ZodEnum<{
2352
- formula: "formula";
2353
- percent: "percent";
2354
2352
  num: "num";
2355
- max: "max";
2356
2353
  min: "min";
2354
+ max: "max";
2355
+ formula: "formula";
2356
+ percent: "percent";
2357
2357
  percentile: "percentile";
2358
2358
  }>;
2359
2359
  value: z.ZodOptional<z.ZodString>;
@@ -2397,11 +2397,11 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2397
2397
  iconSetType: z.ZodString;
2398
2398
  thresholds: z.ZodArray<z.ZodObject<{
2399
2399
  type: z.ZodEnum<{
2400
- formula: "formula";
2401
- percent: "percent";
2402
2400
  num: "num";
2403
- max: "max";
2404
2401
  min: "min";
2402
+ max: "max";
2403
+ formula: "formula";
2404
+ percent: "percent";
2405
2405
  percentile: "percentile";
2406
2406
  }>;
2407
2407
  value: z.ZodOptional<z.ZodString>;
@@ -2534,12 +2534,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2534
2534
  }, z.core.$strip>, z.ZodObject<{
2535
2535
  pages: z.ZodArray<z.ZodObject<{
2536
2536
  origin: z.ZodOptional<z.ZodEnum<{
2537
+ body: "body";
2537
2538
  chart: "chart";
2538
2539
  diagram: "diagram";
2539
2540
  table: "table";
2540
2541
  image: "image";
2541
2542
  notes: "notes";
2542
- body: "body";
2543
2543
  }>>;
2544
2544
  interpretation: z.ZodOptional<z.ZodObject<{
2545
2545
  transcript: z.ZodOptional<z.ZodObject<{
@@ -2567,12 +2567,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2567
2567
  shapes: z.ZodArray<z.ZodObject<{
2568
2568
  blocks: z.ZodLazy<z.ZodArray<z.ZodType<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock, z.core.$ZodTypeInternals<import("document-schema.js").ContentBlock, import("document-schema.js").ContentBlock>>>>;
2569
2569
  origin: z.ZodOptional<z.ZodEnum<{
2570
+ body: "body";
2570
2571
  chart: "chart";
2571
2572
  diagram: "diagram";
2572
2573
  table: "table";
2573
2574
  image: "image";
2574
2575
  notes: "notes";
2575
- body: "body";
2576
2576
  }>>;
2577
2577
  interpretation: z.ZodOptional<z.ZodObject<{
2578
2578
  transcript: z.ZodOptional<z.ZodObject<{
@@ -2640,12 +2640,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2640
2640
  }, z.core.$strip>>;
2641
2641
  vectors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2642
2642
  origin: z.ZodOptional<z.ZodEnum<{
2643
+ body: "body";
2643
2644
  chart: "chart";
2644
2645
  diagram: "diagram";
2645
2646
  table: "table";
2646
2647
  image: "image";
2647
2648
  notes: "notes";
2648
- body: "body";
2649
2649
  }>>;
2650
2650
  interpretation: z.ZodOptional<z.ZodObject<{
2651
2651
  transcript: z.ZodOptional<z.ZodObject<{
@@ -2778,12 +2778,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2778
2778
  }, z.core.$strip>>>;
2779
2779
  }, z.core.$strip>, z.ZodObject<{
2780
2780
  origin: z.ZodOptional<z.ZodEnum<{
2781
+ body: "body";
2781
2782
  chart: "chart";
2782
2783
  diagram: "diagram";
2783
2784
  table: "table";
2784
2785
  image: "image";
2785
2786
  notes: "notes";
2786
- body: "body";
2787
2787
  }>>;
2788
2788
  interpretation: z.ZodOptional<z.ZodObject<{
2789
2789
  transcript: z.ZodOptional<z.ZodObject<{
@@ -2916,12 +2916,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2916
2916
  }, z.core.$strip>>>;
2917
2917
  }, z.core.$strip>, z.ZodObject<{
2918
2918
  origin: z.ZodOptional<z.ZodEnum<{
2919
+ body: "body";
2919
2920
  chart: "chart";
2920
2921
  diagram: "diagram";
2921
2922
  table: "table";
2922
2923
  image: "image";
2923
2924
  notes: "notes";
2924
- body: "body";
2925
2925
  }>>;
2926
2926
  interpretation: z.ZodOptional<z.ZodObject<{
2927
2927
  transcript: z.ZodOptional<z.ZodObject<{
@@ -3004,12 +3004,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
3004
3004
  }, z.core.$strip>>>;
3005
3005
  }, z.core.$strip>, z.ZodObject<{
3006
3006
  origin: z.ZodOptional<z.ZodEnum<{
3007
+ body: "body";
3007
3008
  chart: "chart";
3008
3009
  diagram: "diagram";
3009
3010
  table: "table";
3010
3011
  image: "image";
3011
3012
  notes: "notes";
3012
- body: "body";
3013
3013
  }>>;
3014
3014
  interpretation: z.ZodOptional<z.ZodObject<{
3015
3015
  transcript: z.ZodOptional<z.ZodObject<{
@@ -3264,12 +3264,12 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
3264
3264
  }, z.core.$strip>, z.ZodObject<{
3265
3265
  formula: z.ZodObject<{
3266
3266
  origin: z.ZodOptional<z.ZodEnum<{
3267
+ body: "body";
3267
3268
  chart: "chart";
3268
3269
  diagram: "diagram";
3269
3270
  table: "table";
3270
3271
  image: "image";
3271
3272
  notes: "notes";
3272
- body: "body";
3273
3273
  }>>;
3274
3274
  interpretation: z.ZodOptional<z.ZodObject<{
3275
3275
  transcript: z.ZodOptional<z.ZodObject<{
@@ -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
  }