markdown-codec 6.7.4 → 6.7.6

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 (72) hide show
  1. package/README.md +2 -1
  2. package/dist/block/block.cjs +19 -37
  3. package/dist/block/block.js +20 -38
  4. package/dist/block/definitions.cjs +1 -5
  5. package/dist/block/definitions.js +1 -5
  6. package/dist/block/line.cjs +2 -2
  7. package/dist/block/line.js +2 -2
  8. package/dist/block/list.cjs +7 -14
  9. package/dist/block/list.js +7 -14
  10. package/dist/block/node.cjs +3 -3
  11. package/dist/block/node.d.cts +2 -2
  12. package/dist/block/node.d.ts +2 -2
  13. package/dist/block/node.js +3 -3
  14. package/dist/block/table.cjs +3 -4
  15. package/dist/block/table.js +3 -4
  16. package/dist/codec.d.cts +36 -36
  17. package/dist/codec.d.ts +36 -36
  18. package/dist/emit/emit.cjs +58 -62
  19. package/dist/emit/emit.js +58 -62
  20. package/dist/emit/inline.cjs +18 -12
  21. package/dist/emit/inline.js +18 -12
  22. package/dist/emit/table.cjs +2 -2
  23. package/dist/emit/table.js +2 -2
  24. package/dist/html/html-table.cjs +14 -22
  25. package/dist/html/html-table.js +14 -22
  26. package/dist/html/html.cjs +0 -2
  27. package/dist/html/html.js +0 -2
  28. package/dist/html/render.cjs +3 -11
  29. package/dist/html/render.js +3 -11
  30. package/dist/image/image.cjs +8 -57
  31. package/dist/image/image.d.cts +2 -2
  32. package/dist/image/image.d.ts +2 -2
  33. package/dist/image/image.js +9 -56
  34. package/dist/{image-BtmTG4_a.d.cts → image-83yql5ES.d.cts} +1 -3
  35. package/dist/{image-BtmTG4_a.d.ts → image-83yql5ES.d.ts} +1 -3
  36. package/dist/{image-B5L0HpAJ.d.cts → image-B6p0Ovgy.d.cts} +1 -1
  37. package/dist/{image-C390OIB3.d.ts → image-gR1vISI0.d.ts} +1 -1
  38. package/dist/index.d.cts +1 -1
  39. package/dist/index.d.ts +1 -1
  40. package/dist/inline/chars.cjs +3 -6
  41. package/dist/inline/chars.js +3 -6
  42. package/dist/inline/delimiter.cjs +5 -16
  43. package/dist/inline/delimiter.d.cts +2 -2
  44. package/dist/inline/delimiter.d.ts +2 -2
  45. package/dist/inline/delimiter.js +5 -16
  46. package/dist/inline/entity.cjs +6 -10
  47. package/dist/inline/entity.js +6 -10
  48. package/dist/inline/gfm-autolink.cjs +20 -19
  49. package/dist/inline/gfm-autolink.js +20 -19
  50. package/dist/inline/inline.cjs +29 -39
  51. package/dist/inline/inline.js +30 -40
  52. package/dist/inline/link.cjs +4 -5
  53. package/dist/inline/link.js +4 -5
  54. package/dist/lower/front-matter.cjs +4 -8
  55. package/dist/lower/front-matter.js +4 -8
  56. package/dist/lower/image.cjs +3 -2
  57. package/dist/lower/image.d.cts +1 -1
  58. package/dist/lower/image.d.ts +1 -1
  59. package/dist/lower/image.js +2 -1
  60. package/dist/lower/inline.cjs +0 -2
  61. package/dist/lower/inline.js +0 -2
  62. package/dist/lower/lower.cjs +7 -10
  63. package/dist/lower/lower.js +7 -10
  64. package/dist/options/options.d.cts +1 -1
  65. package/dist/options/options.d.ts +1 -1
  66. package/dist/read.cjs +2 -2
  67. package/dist/read.js +2 -2
  68. package/dist/scan/scan.cjs +1 -3
  69. package/dist/scan/scan.js +1 -3
  70. package/dist/shared/list-id.cjs +1 -1
  71. package/dist/shared/list-id.js +1 -1
  72. package/package.json +2 -1
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";
633
632
  chart: "chart";
634
633
  diagram: "diagram";
635
634
  table: "table";
636
635
  image: "image";
637
636
  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";
848
847
  chart: "chart";
849
848
  diagram: "diagram";
850
849
  table: "table";
851
850
  image: "image";
852
851
  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";
997
996
  chart: "chart";
998
997
  diagram: "diagram";
999
998
  table: "table";
1000
999
  image: "image";
1001
1000
  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";
1030
1029
  chart: "chart";
1031
1030
  diagram: "diagram";
1032
1031
  table: "table";
1033
1032
  image: "image";
1034
1033
  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";
1193
1192
  chart: "chart";
1194
1193
  diagram: "diagram";
1195
1194
  table: "table";
1196
1195
  image: "image";
1197
1196
  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";
1222
1221
  chart: "chart";
1223
1222
  diagram: "diagram";
1224
1223
  table: "table";
1225
1224
  image: "image";
1226
1225
  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";
1302
1301
  chart: "chart";
1303
1302
  diagram: "diagram";
1304
1303
  table: "table";
1305
1304
  image: "image";
1306
1305
  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";
1601
1600
  chart: "chart";
1602
1601
  diagram: "diagram";
1603
1602
  table: "table";
1604
1603
  image: "image";
1605
1604
  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
  }>;
@@ -1816,11 +1816,11 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1816
1816
  endColumn: z.ZodNumber;
1817
1817
  }, z.core.$strip>>;
1818
1818
  type: z.ZodEnum<{
1819
- time: "time";
1820
1819
  date: "date";
1821
1820
  custom: "custom";
1822
1821
  decimal: "decimal";
1823
1822
  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
- num: "num";
2295
- min: "min";
2296
- max: "max";
2297
2294
  formula: "formula";
2298
2295
  percent: "percent";
2296
+ num: "num";
2297
+ max: "max";
2298
+ min: "min";
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
- num: "num";
2342
- min: "min";
2343
- max: "max";
2344
2341
  formula: "formula";
2345
2342
  percent: "percent";
2343
+ num: "num";
2344
+ max: "max";
2345
+ min: "min";
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
- num: "num";
2353
- min: "min";
2354
- max: "max";
2355
2352
  formula: "formula";
2356
2353
  percent: "percent";
2354
+ num: "num";
2355
+ max: "max";
2356
+ min: "min";
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
- num: "num";
2401
- min: "min";
2402
- max: "max";
2403
2400
  formula: "formula";
2404
2401
  percent: "percent";
2402
+ num: "num";
2403
+ max: "max";
2404
+ min: "min";
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";
2538
2537
  chart: "chart";
2539
2538
  diagram: "diagram";
2540
2539
  table: "table";
2541
2540
  image: "image";
2542
2541
  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";
2571
2570
  chart: "chart";
2572
2571
  diagram: "diagram";
2573
2572
  table: "table";
2574
2573
  image: "image";
2575
2574
  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";
2644
2643
  chart: "chart";
2645
2644
  diagram: "diagram";
2646
2645
  table: "table";
2647
2646
  image: "image";
2648
2647
  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";
2782
2781
  chart: "chart";
2783
2782
  diagram: "diagram";
2784
2783
  table: "table";
2785
2784
  image: "image";
2786
2785
  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";
2920
2919
  chart: "chart";
2921
2920
  diagram: "diagram";
2922
2921
  table: "table";
2923
2922
  image: "image";
2924
2923
  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";
3008
3007
  chart: "chart";
3009
3008
  diagram: "diagram";
3010
3009
  table: "table";
3011
3010
  image: "image";
3012
3011
  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";
3268
3267
  chart: "chart";
3269
3268
  diagram: "diagram";
3270
3269
  table: "table";
3271
3270
  image: "image";
3272
3271
  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,11 +23,19 @@ 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
  }
35
+ function renderAtxHeading(level, text) {
36
+ const collapsed = text.replace(require_shared_line_ending.ESCAPED_HARD_BREAK_PATTERN, " ").split(require_shared_line_ending.LINE_ENDING_PATTERN).join(" ");
37
+ return `${"#".repeat(level)} ${collapsed}`;
38
+ }
32
39
  const MIN_CODE_FENCE_LENGTH = 3;
33
40
  function longestRunLength(text, char) {
34
41
  let longest = 0;
@@ -54,19 +61,17 @@ function isQuotableStyle(styleId) {
54
61
  return QUOTABLE_STYLE_IDS.has(styleId) || require_shared_style_constants.parseHeadingStyleId(styleId) !== void 0;
55
62
  }
56
63
  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;
64
+ return styleId === "CodeBlock" || styleId === "MathBlock" || styleId === "HorizontalRule" || styleId !== void 0 && require_shared_style_constants.parseHeadingStyleId(styleId) !== void 0;
59
65
  }
60
66
  const BLANK_OR_WHITESPACE_ONLY_LINE = /^[ \t]*$/;
61
67
  function firstContentLineIndex(text) {
62
68
  return text.split(require_shared_line_ending.LINE_ENDING_PATTERN).findIndex((line) => !BLANK_OR_WHITESPACE_ONLY_LINE.test(line));
63
69
  }
64
- function leadingIndentColumns(line) {
70
+ function leadingIndentReachesCodeThreshold(line) {
65
71
  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;
72
+ while (line[column] === " ") column += 1;
73
+ if (column >= 4) return true;
74
+ return line[column] === " ";
70
75
  }
71
76
  const MAX_LEADING_BLANK_LINES_FOR_SETEXT = 1;
72
77
  function interruptsSetextParagraph(line, atBlockStart) {
@@ -83,19 +88,17 @@ function tableDelimiterRowPromotesPrecedingLine(line, precedingLine) {
83
88
  return require_block_table.parseTableDelimiterRow(cursor.restFromNextNonspace())?.length === require_block_table.splitTableRow(precedingLine).length;
84
89
  }
85
90
  function unsafeSetextBreakReason(text) {
86
- let sawContentLine = false;
87
91
  let leadingBlankLines = 0;
88
- let precedingLine = "";
92
+ let precedingLine;
89
93
  for (const line of text.split(require_shared_line_ending.LINE_ENDING_PATTERN)) {
90
94
  const isBlank = BLANK_OR_WHITESPACE_ONLY_LINE.test(line);
91
- if (!sawContentLine) {
95
+ if (precedingLine === void 0) {
92
96
  if (isBlank) {
93
97
  leadingBlankLines += 1;
94
98
  if (leadingBlankLines > MAX_LEADING_BLANK_LINES_FOR_SETEXT) return "blank-line";
95
99
  continue;
96
100
  }
97
- sawContentLine = true;
98
- if (leadingIndentColumns(line) >= 4) return "leading-indentation";
101
+ if (leadingIndentReachesCodeThreshold(line)) return "leading-indentation";
99
102
  if (interruptsSetextParagraph(line, true)) return "interrupting-line";
100
103
  precedingLine = line;
101
104
  continue;
@@ -104,7 +107,7 @@ function unsafeSetextBreakReason(text) {
104
107
  if (interruptsSetextParagraph(line, false) || tableDelimiterRowPromotesPrecedingLine(line, precedingLine)) return "interrupting-line";
105
108
  precedingLine = line;
106
109
  }
107
- return sawContentLine ? void 0 : "blank-line";
110
+ return precedingLine === void 0 ? "blank-line" : void 0;
108
111
  }
109
112
  function embedsUnsafeBreakForSetext(text) {
110
113
  return unsafeSetextBreakReason(text) !== void 0;
@@ -124,7 +127,7 @@ function willRenderAsSetext(paragraph, level, context) {
124
127
  }
125
128
  function canInterruptOpenParagraph(paragraph, context) {
126
129
  const styleId = paragraph.styleId;
127
- if (styleId === void 0 || styleId === "Quote" || styleId === "HTMLPreformatted") return false;
130
+ if (styleId === void 0) return false;
128
131
  if (styleId === "CodeBlock" || styleId === "MathBlock") return true;
129
132
  if (styleId === "HorizontalRule") return context.thematicBreakChar !== SETEXT_LEVEL_2_CHAR;
130
133
  const headingLevel = require_shared_style_constants.parseHeadingStyleId(styleId);
@@ -177,18 +180,14 @@ function renderParagraphBody(paragraph, context) {
177
180
  severity: "info",
178
181
  message: unsafeSetextDiagnosticMessage(level, unsafeSetextReason, embedsLineBreak)
179
182
  });
180
- if (embedsLineBreak) return `${"#".repeat(level)} ${text.replace(require_shared_line_ending.ESCAPED_HARD_BREAK_PATTERN, " ").split(require_shared_line_ending.LINE_ENDING_PATTERN).join(" ")}`;
181
- return `${"#".repeat(level)} ${text}`;
182
- }
183
- if (embedsLineBreak) {
184
- context.sink({
185
- code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.HEADING_LINE_BREAK_COLLAPSED,
186
- severity: "info",
187
- message: `a level ${String(level)} heading's own content contains a line break; only setext's own level-1/2 grammar can hold one, so ATX collapses it to a single space`
188
- });
189
- return `${"#".repeat(level)} ${text.replace(require_shared_line_ending.ESCAPED_HARD_BREAK_PATTERN, " ").split(require_shared_line_ending.LINE_ENDING_PATTERN).join(" ")}`;
183
+ return renderAtxHeading(level, text);
190
184
  }
191
- return `${"#".repeat(level)} ${text}`;
185
+ if (embedsLineBreak) context.sink({
186
+ code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.HEADING_LINE_BREAK_COLLAPSED,
187
+ severity: "info",
188
+ message: `a level ${String(level)} heading's own content contains a line break; only setext's own level-1/2 grammar can hold one, so ATX collapses it to a single space`
189
+ });
190
+ return renderAtxHeading(level, text);
192
191
  }
193
192
  return require_emit_inline.emitRuns(paragraph.runs, context, paragraph.constructs);
194
193
  }
@@ -264,24 +263,24 @@ function toEmitItem(item) {
264
263
  function firstBlockCheckbox(first, taskNumId) {
265
264
  if (first.list.checked !== void 0) return {
266
265
  checkboxText: first.list.checked ? "[x] " : "[ ] ",
267
- stripGlyph: false
266
+ strippedFirstBlock: void 0
268
267
  };
269
268
  if (!taskNumId || first.kind !== "paragraph") return {
270
269
  checkboxText: "",
271
- stripGlyph: false
270
+ strippedFirstBlock: void 0
272
271
  };
273
- const leading = first.block.runs[0]?.text ?? "";
274
- if (leading.startsWith(`☒ `)) return {
272
+ const leading = first.block.runs[0]?.text;
273
+ if (leading?.startsWith(`☒ `) === true) return {
275
274
  checkboxText: "[x] ",
276
- stripGlyph: true
275
+ strippedFirstBlock: stripCheckboxRun(first.block)
277
276
  };
278
- if (leading.startsWith(`☐ `)) return {
277
+ if (leading?.startsWith(`☐ `) === true) return {
279
278
  checkboxText: "[ ] ",
280
- stripGlyph: true
279
+ strippedFirstBlock: stripCheckboxRun(first.block)
281
280
  };
282
281
  return {
283
282
  checkboxText: "",
284
- stripGlyph: false
283
+ strippedFirstBlock: void 0
285
284
  };
286
285
  }
287
286
  function renderListItemMarker(numId, info, glyph, checkboxText, context) {
@@ -316,7 +315,7 @@ function resolveListGlyph(numId, type, previousSibling, context) {
316
315
  }
317
316
  function consumeSameItemRun(items, from, level, itemId) {
318
317
  let end = from;
319
- while (end < items.length) {
318
+ for (;;) {
320
319
  const candidate = items[end];
321
320
  if (candidate?.list.level !== level || candidate.list.itemId !== itemId) break;
322
321
  end += 1;
@@ -334,7 +333,7 @@ function collectListItem(items, start, level, itemId) {
334
333
  index = ownEnd;
335
334
  for (;;) {
336
335
  let nestedEnd = index;
337
- while (nestedEnd < items.length) {
336
+ for (;;) {
338
337
  const candidateLevel = items[nestedEnd]?.list.level;
339
338
  if (candidateLevel === void 0 || candidateLevel <= level) break;
340
339
  nestedEnd += 1;
@@ -347,7 +346,6 @@ function collectListItem(items, start, level, itemId) {
347
346
  index = nestedEnd;
348
347
  if (itemId === void 0) break;
349
348
  const resumedEnd = consumeSameItemRun(items, index, level, itemId);
350
- if (resumedEnd === index) break;
351
349
  segments.push({
352
350
  kind: "own",
353
351
  blocks: items.slice(index, resumedEnd)
@@ -378,8 +376,8 @@ function regionItemCanInterrupt(item, context) {
378
376
  function lastStyleIdOfRegionItem(item) {
379
377
  return lastStyleIdOf(toEmitItem(item));
380
378
  }
381
- function listRegionItemBody(item, context, stripGlyph) {
382
- if (item.kind === "paragraph") return renderParagraphBody(stripGlyph ? stripCheckboxRun(item.block) : item.block, context);
379
+ function listRegionItemBody(item, context, overrideParagraph) {
380
+ if (item.kind === "paragraph") return renderParagraphBody(overrideParagraph ?? item.block, context);
383
381
  const previousEnclosingItemId = context.enclosingItemId;
384
382
  context.enclosingItemId = item.list.itemId;
385
383
  const body = renderConstruct(item.item, context);
@@ -394,14 +392,14 @@ function renderListRegion(items, context) {
394
392
  const parts = [];
395
393
  let index = 0;
396
394
  let previousSibling;
397
- while (index < items.length) {
395
+ for (;;) {
398
396
  const item = items[index];
399
397
  if (item === void 0) break;
400
398
  const { numId, level, itemId } = item.list;
401
399
  const info = listInfoFor(numId, context);
402
400
  const loose = info?.loose === true;
403
401
  const type = info?.type ?? "bullet";
404
- const glyph = numId === void 0 ? type === "ordered" ? context.orderedDelimiter : context.bulletMarker : resolveListGlyph(numId, type, previousSibling, context);
402
+ const glyph = numId === void 0 ? context.bulletMarker : resolveListGlyph(numId, type, previousSibling, context);
405
403
  if (numId !== void 0) previousSibling = {
406
404
  numId,
407
405
  type,
@@ -410,10 +408,10 @@ function renderListRegion(items, context) {
410
408
  const { segments, next } = collectListItem(items, index, level, itemId);
411
409
  const first = segments[0]?.blocks[0];
412
410
  if (first === void 0) break;
413
- const { checkboxText, stripGlyph } = firstBlockCheckbox(first, info?.task === true);
411
+ const { checkboxText, strippedFirstBlock } = firstBlockCheckbox(first, info?.task === true);
414
412
  const marker = renderListItemMarker(numId, info, glyph, checkboxText, context);
415
413
  const indent = " ".repeat(marker.bareLength);
416
- let text = "";
414
+ let text = marker.full;
417
415
  let renderedFirstLine = false;
418
416
  let previousStyleId;
419
417
  for (const segment of segments) {
@@ -426,13 +424,13 @@ function renderListRegion(items, context) {
426
424
  }
427
425
  for (const block of segment.blocks) {
428
426
  if (!renderedFirstLine) {
429
- const [firstLine = "", ...restLines] = listRegionItemBody(block, context, stripGlyph).split("\n");
430
- text = [`${marker.full}${firstLine}`, ...restLines.map((line) => `${indent}${line}`)].join("\n");
427
+ const [firstLine, ...restLines] = splitLines(listRegionItemBody(block, context, strippedFirstBlock), "\n");
428
+ text += [firstLine, ...restLines.map((line) => `${indent}${line}`)].join("\n");
431
429
  renderedFirstLine = true;
432
430
  previousStyleId = lastStyleIdOfRegionItem(block);
433
431
  continue;
434
432
  }
435
- const rendered = listRegionItemBody(block, context, false).split("\n").map((line) => line.length === 0 ? line : `${indent}${line}`).join("\n");
433
+ const rendered = listRegionItemBody(block, context, void 0).split("\n").map((line) => line.length === 0 ? line : `${indent}${line}`).join("\n");
436
434
  const blank = loose || requiresBlankLineBefore(block, previousStyleId, context);
437
435
  text += blank ? `\n\n${rendered}` : `\n${rendered}`;
438
436
  previousStyleId = lastStyleIdOfRegionItem(block);
@@ -448,9 +446,8 @@ function renderListRegion(items, context) {
448
446
  for (const [partIndex, part] of parts.entries()) {
449
447
  if (partIndex > 0) {
450
448
  const previous = parts[partIndex - 1];
451
- const sameList = previous.numId === part.numId;
452
- const loose = sameList && previous.numId !== void 0 && (require_shared_list_id.parseListNumId(previous.numId)?.loose ?? false);
453
- out += sameList && !loose ? "\n" : "\n\n";
449
+ const continuesTightly = previous.numId === part.numId && (previous.numId === void 0 || require_shared_list_id.parseListNumId(previous.numId)?.loose !== true);
450
+ out += continuesTightly ? "\n" : "\n\n";
454
451
  }
455
452
  out += part.text;
456
453
  }
@@ -459,16 +456,17 @@ function renderListRegion(items, context) {
459
456
  function isConstructItem(item) {
460
457
  return "descriptor" in item;
461
458
  }
459
+ const UNINDENTED_PT = 0;
462
460
  function isMaterialisedDivision(item) {
463
461
  return item.descriptor.kind === "division" && item.children.every((child) => {
464
462
  if (isConstructItem(child)) return true;
465
- return child.block.kind !== "paragraph" || child.block.indentLeftPt !== void 0 && child.block.indentLeftPt >= 36;
463
+ return child.block.kind !== "paragraph" || (child.block.indentLeftPt ?? UNINDENTED_PT) >= 36;
466
464
  });
467
465
  }
468
466
  function groupConstructItems(blocks, start) {
469
467
  const items = [];
470
468
  let index = start;
471
- while (index < blocks.length) {
469
+ for (;;) {
472
470
  const block = blocks[index];
473
471
  if (block === void 0) break;
474
472
  index += 1;
@@ -497,7 +495,7 @@ function renderFootnoteDefinition(name, body) {
497
495
  const marker = `[^${name}]:`;
498
496
  if (body.length === 0) return marker;
499
497
  const indent = " ".repeat(FOOTNOTE_CONTINUATION_INDENT);
500
- const [firstLine = "", ...restLines] = body.split("\n");
498
+ const [firstLine, ...restLines] = splitLines(body, "\n");
501
499
  return [`${marker} ${firstLine}`, ...restLines.map((line) => line.length === 0 ? line : `${indent}${line}`)].join("\n");
502
500
  }
503
501
  function renderConstruct(item, context) {
@@ -512,13 +510,11 @@ function renderConstruct(item, context) {
512
510
  });
513
511
  return body;
514
512
  }
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
- }
513
+ if (isMaterialisedDivision(item)) {
514
+ context.divisionDepth += 1;
515
+ const body = renderItems(item.children, context);
516
+ context.divisionDepth -= 1;
517
+ return body.split("\n").map((line) => line.length === 0 ? ">" : `> ${line}`).join("\n");
522
518
  }
523
519
  if (descriptor.kind === "link" && descriptor.target.kind === "external") {
524
520
  const onlyChild = item.children.length === 1 && !isConstructItem(item.children[0]) ? item.children[0].block : void 0;
@@ -549,7 +545,7 @@ function isInheritedListMembership(list, context) {
549
545
  function renderItems(items, context) {
550
546
  const parts = [];
551
547
  let index = 0;
552
- while (index < items.length) {
548
+ for (;;) {
553
549
  const item = items[index];
554
550
  if (item === void 0) break;
555
551
  if (isConstructItem(item)) {
@@ -612,7 +608,7 @@ function emitBlocks(blocks, context) {
612
608
  }
613
609
  function validateRunConstructExtents(blocks) {
614
610
  for (const block of blocks) {
615
- if (block.kind === "paragraph" && block.constructs !== void 0) {
611
+ if (block.kind === "paragraph") {
616
612
  const fault = (0, document_schema_js.findRunConstructFault)(block);
617
613
  if (fault !== void 0) throw new require_diagnostics_diagnostics.MarkdownInvalidRunConstructExtentError(fault.kind, fault.index);
618
614
  }