markdown-codec 11.1.3 → 11.1.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.
package/dist/codec.d.cts 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<{
@@ -103,9 +103,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
103
103
  symbol: z.ZodString;
104
104
  name: z.ZodOptional<z.ZodString>;
105
105
  dimension: z.ZodRecord<z.ZodEnum<{
106
- time: "time";
107
106
  length: "length";
108
107
  mass: "mass";
108
+ time: "time";
109
109
  electricCurrent: "electricCurrent";
110
110
  thermodynamicTemperature: "thermodynamicTemperature";
111
111
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -258,9 +258,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
258
258
  symbol: z.ZodString;
259
259
  name: z.ZodOptional<z.ZodString>;
260
260
  dimension: z.ZodRecord<z.ZodEnum<{
261
- time: "time";
262
261
  length: "length";
263
262
  mass: "mass";
263
+ time: "time";
264
264
  electricCurrent: "electricCurrent";
265
265
  thermodynamicTemperature: "thermodynamicTemperature";
266
266
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -418,9 +418,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
418
418
  symbol: z.ZodString;
419
419
  name: z.ZodOptional<z.ZodString>;
420
420
  dimension: z.ZodRecord<z.ZodEnum<{
421
- time: "time";
422
421
  length: "length";
423
422
  mass: "mass";
423
+ time: "time";
424
424
  electricCurrent: "electricCurrent";
425
425
  thermodynamicTemperature: "thermodynamicTemperature";
426
426
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -573,9 +573,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
573
573
  symbol: z.ZodString;
574
574
  name: z.ZodOptional<z.ZodString>;
575
575
  dimension: z.ZodRecord<z.ZodEnum<{
576
- time: "time";
577
576
  length: "length";
578
577
  mass: "mass";
578
+ time: "time";
579
579
  electricCurrent: "electricCurrent";
580
580
  thermodynamicTemperature: "thermodynamicTemperature";
581
581
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -787,9 +787,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
787
787
  symbol: z.ZodString;
788
788
  name: z.ZodOptional<z.ZodString>;
789
789
  dimension: z.ZodRecord<z.ZodEnum<{
790
- time: "time";
791
790
  length: "length";
792
791
  mass: "mass";
792
+ time: "time";
793
793
  electricCurrent: "electricCurrent";
794
794
  thermodynamicTemperature: "thermodynamicTemperature";
795
795
  amountOfSubstance: "amountOfSubstance";
@@ -937,9 +937,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
937
937
  symbol: z.ZodString;
938
938
  name: z.ZodOptional<z.ZodString>;
939
939
  dimension: z.ZodRecord<z.ZodEnum<{
940
- time: "time";
941
940
  length: "length";
942
941
  mass: "mass";
942
+ time: "time";
943
943
  electricCurrent: "electricCurrent";
944
944
  thermodynamicTemperature: "thermodynamicTemperature";
945
945
  amountOfSubstance: "amountOfSubstance";
@@ -1133,9 +1133,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1133
1133
  symbol: z.ZodString;
1134
1134
  name: z.ZodOptional<z.ZodString>;
1135
1135
  dimension: z.ZodRecord<z.ZodEnum<{
1136
- time: "time";
1137
1136
  length: "length";
1138
1137
  mass: "mass";
1138
+ time: "time";
1139
1139
  electricCurrent: "electricCurrent";
1140
1140
  thermodynamicTemperature: "thermodynamicTemperature";
1141
1141
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -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
  }>;
@@ -2478,9 +2478,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2478
2478
  symbol: z.ZodString;
2479
2479
  name: z.ZodOptional<z.ZodString>;
2480
2480
  dimension: z.ZodRecord<z.ZodEnum<{
2481
- time: "time";
2482
2481
  length: "length";
2483
2482
  mass: "mass";
2483
+ time: "time";
2484
2484
  electricCurrent: "electricCurrent";
2485
2485
  thermodynamicTemperature: "thermodynamicTemperature";
2486
2486
  amountOfSubstance: "amountOfSubstance";
@@ -3208,9 +3208,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
3208
3208
  symbol: z.ZodString;
3209
3209
  name: z.ZodOptional<z.ZodString>;
3210
3210
  dimension: z.ZodRecord<z.ZodEnum<{
3211
- time: "time";
3212
3211
  length: "length";
3213
3212
  mass: "mass";
3213
+ time: "time";
3214
3214
  electricCurrent: "electricCurrent";
3215
3215
  thermodynamicTemperature: "thermodynamicTemperature";
3216
3216
  amountOfSubstance: "amountOfSubstance";
@@ -3336,9 +3336,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
3336
3336
  symbol: z.ZodString;
3337
3337
  name: z.ZodOptional<z.ZodString>;
3338
3338
  dimension: z.ZodRecord<z.ZodEnum<{
3339
- time: "time";
3340
3339
  length: "length";
3341
3340
  mass: "mass";
3341
+ time: "time";
3342
3342
  electricCurrent: "electricCurrent";
3343
3343
  thermodynamicTemperature: "thermodynamicTemperature";
3344
3344
  amountOfSubstance: "amountOfSubstance";
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<{
@@ -103,9 +103,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
103
103
  symbol: z.ZodString;
104
104
  name: z.ZodOptional<z.ZodString>;
105
105
  dimension: z.ZodRecord<z.ZodEnum<{
106
- time: "time";
107
106
  length: "length";
108
107
  mass: "mass";
108
+ time: "time";
109
109
  electricCurrent: "electricCurrent";
110
110
  thermodynamicTemperature: "thermodynamicTemperature";
111
111
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -258,9 +258,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
258
258
  symbol: z.ZodString;
259
259
  name: z.ZodOptional<z.ZodString>;
260
260
  dimension: z.ZodRecord<z.ZodEnum<{
261
- time: "time";
262
261
  length: "length";
263
262
  mass: "mass";
263
+ time: "time";
264
264
  electricCurrent: "electricCurrent";
265
265
  thermodynamicTemperature: "thermodynamicTemperature";
266
266
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -418,9 +418,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
418
418
  symbol: z.ZodString;
419
419
  name: z.ZodOptional<z.ZodString>;
420
420
  dimension: z.ZodRecord<z.ZodEnum<{
421
- time: "time";
422
421
  length: "length";
423
422
  mass: "mass";
423
+ time: "time";
424
424
  electricCurrent: "electricCurrent";
425
425
  thermodynamicTemperature: "thermodynamicTemperature";
426
426
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -573,9 +573,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
573
573
  symbol: z.ZodString;
574
574
  name: z.ZodOptional<z.ZodString>;
575
575
  dimension: z.ZodRecord<z.ZodEnum<{
576
- time: "time";
577
576
  length: "length";
578
577
  mass: "mass";
578
+ time: "time";
579
579
  electricCurrent: "electricCurrent";
580
580
  thermodynamicTemperature: "thermodynamicTemperature";
581
581
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -787,9 +787,9 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
787
787
  symbol: z.ZodString;
788
788
  name: z.ZodOptional<z.ZodString>;
789
789
  dimension: z.ZodRecord<z.ZodEnum<{
790
- time: "time";
791
790
  length: "length";
792
791
  mass: "mass";
792
+ time: "time";
793
793
  electricCurrent: "electricCurrent";
794
794
  thermodynamicTemperature: "thermodynamicTemperature";
795
795
  amountOfSubstance: "amountOfSubstance";
@@ -937,9 +937,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
937
937
  symbol: z.ZodString;
938
938
  name: z.ZodOptional<z.ZodString>;
939
939
  dimension: z.ZodRecord<z.ZodEnum<{
940
- time: "time";
941
940
  length: "length";
942
941
  mass: "mass";
942
+ time: "time";
943
943
  electricCurrent: "electricCurrent";
944
944
  thermodynamicTemperature: "thermodynamicTemperature";
945
945
  amountOfSubstance: "amountOfSubstance";
@@ -1133,9 +1133,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1133
1133
  symbol: z.ZodString;
1134
1134
  name: z.ZodOptional<z.ZodString>;
1135
1135
  dimension: z.ZodRecord<z.ZodEnum<{
1136
- time: "time";
1137
1136
  length: "length";
1138
1137
  mass: "mass";
1138
+ time: "time";
1139
1139
  electricCurrent: "electricCurrent";
1140
1140
  thermodynamicTemperature: "thermodynamicTemperature";
1141
1141
  amountOfSubstance: "amountOfSubstance";
@@ -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<{
@@ -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
  }>;
@@ -2478,9 +2478,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
2478
2478
  symbol: z.ZodString;
2479
2479
  name: z.ZodOptional<z.ZodString>;
2480
2480
  dimension: z.ZodRecord<z.ZodEnum<{
2481
- time: "time";
2482
2481
  length: "length";
2483
2482
  mass: "mass";
2483
+ time: "time";
2484
2484
  electricCurrent: "electricCurrent";
2485
2485
  thermodynamicTemperature: "thermodynamicTemperature";
2486
2486
  amountOfSubstance: "amountOfSubstance";
@@ -3208,9 +3208,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
3208
3208
  symbol: z.ZodString;
3209
3209
  name: z.ZodOptional<z.ZodString>;
3210
3210
  dimension: z.ZodRecord<z.ZodEnum<{
3211
- time: "time";
3212
3211
  length: "length";
3213
3212
  mass: "mass";
3213
+ time: "time";
3214
3214
  electricCurrent: "electricCurrent";
3215
3215
  thermodynamicTemperature: "thermodynamicTemperature";
3216
3216
  amountOfSubstance: "amountOfSubstance";
@@ -3336,9 +3336,9 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
3336
3336
  symbol: z.ZodString;
3337
3337
  name: z.ZodOptional<z.ZodString>;
3338
3338
  dimension: z.ZodRecord<z.ZodEnum<{
3339
- time: "time";
3340
3339
  length: "length";
3341
3340
  mass: "mass";
3341
+ time: "time";
3342
3342
  electricCurrent: "electricCurrent";
3343
3343
  thermodynamicTemperature: "thermodynamicTemperature";
3344
3344
  amountOfSubstance: "amountOfSubstance";
@@ -117,21 +117,22 @@ function applyTagStyle(style, tagName, attrs) {
117
117
  default: return style;
118
118
  }
119
119
  }
120
- function pushPlainRun(runs, text, style) {
120
+ function pushPlainRun(sink, text, style) {
121
121
  if (text.length === 0) return;
122
- runs.push({
122
+ sink.runs.push({
123
123
  text: unescapeHtml(text),
124
124
  ...style
125
125
  });
126
126
  }
127
127
  function parseInlineHtml(text, style) {
128
128
  const runs = [];
129
+ const sink = { runs };
129
130
  let pos = 0;
130
131
  for (;;) {
131
132
  const rest = text.slice(pos);
132
133
  const match = INLINE_TAG_PATTERN.exec(rest);
133
134
  if (match === null) {
134
- pushPlainRun(runs, rest, style);
135
+ pushPlainRun(sink, rest, style);
135
136
  return runs;
136
137
  }
137
138
  const tagName = match[1].toLowerCase();
@@ -139,10 +140,10 @@ function parseInlineHtml(text, style) {
139
140
  const openEnd = pos + match.index + match[0].length;
140
141
  const close = findBalancedClose(text, openEnd, [tagName]);
141
142
  if (close === void 0) {
142
- pushPlainRun(runs, rest, style);
143
+ pushPlainRun(sink, rest, style);
143
144
  return runs;
144
145
  }
145
- pushPlainRun(runs, rest.slice(0, match.index), style);
146
+ pushPlainRun(sink, rest.slice(0, match.index), style);
146
147
  runs.push(...parseInlineHtml(text.slice(openEnd, close.start), applyTagStyle(style, tagName, attrs)));
147
148
  pos = close.end;
148
149
  }
@@ -182,7 +183,7 @@ function parseCellBlocks(inner, contentWidthPt) {
182
183
  }
183
184
  function applyTextAlign(blocks, alignment) {
184
185
  const first = blocks[0];
185
- if (alignment === void 0 || first?.kind !== "paragraph") return blocks;
186
+ if (alignment === void 0 || first?.kind !== "paragraph") return [...blocks];
186
187
  return [{
187
188
  ...first,
188
189
  alignment
@@ -222,10 +223,11 @@ function parseTableRows(inner, contentWidthPt) {
222
223
  }
223
224
  function buildContentTable(rows, contentWidthPt) {
224
225
  const columnCount = rows[0].cells.length;
226
+ const columns = Array.from({ length: columnCount }, () => ({ widthPt: contentWidthPt / columnCount }));
225
227
  return {
226
228
  kind: "table",
227
- rows,
228
- columns: Array.from({ length: columnCount }, () => ({ widthPt: contentWidthPt / columnCount }))
229
+ rows: [...rows],
230
+ columns
229
231
  };
230
232
  }
231
233
  function parseWholeTable(text, contentWidthPt) {
@@ -116,21 +116,22 @@ function applyTagStyle(style, tagName, attrs) {
116
116
  default: return style;
117
117
  }
118
118
  }
119
- function pushPlainRun(runs, text, style) {
119
+ function pushPlainRun(sink, text, style) {
120
120
  if (text.length === 0) return;
121
- runs.push({
121
+ sink.runs.push({
122
122
  text: unescapeHtml(text),
123
123
  ...style
124
124
  });
125
125
  }
126
126
  function parseInlineHtml(text, style) {
127
127
  const runs = [];
128
+ const sink = { runs };
128
129
  let pos = 0;
129
130
  for (;;) {
130
131
  const rest = text.slice(pos);
131
132
  const match = INLINE_TAG_PATTERN.exec(rest);
132
133
  if (match === null) {
133
- pushPlainRun(runs, rest, style);
134
+ pushPlainRun(sink, rest, style);
134
135
  return runs;
135
136
  }
136
137
  const tagName = match[1].toLowerCase();
@@ -138,10 +139,10 @@ function parseInlineHtml(text, style) {
138
139
  const openEnd = pos + match.index + match[0].length;
139
140
  const close = findBalancedClose(text, openEnd, [tagName]);
140
141
  if (close === void 0) {
141
- pushPlainRun(runs, rest, style);
142
+ pushPlainRun(sink, rest, style);
142
143
  return runs;
143
144
  }
144
- pushPlainRun(runs, rest.slice(0, match.index), style);
145
+ pushPlainRun(sink, rest.slice(0, match.index), style);
145
146
  runs.push(...parseInlineHtml(text.slice(openEnd, close.start), applyTagStyle(style, tagName, attrs)));
146
147
  pos = close.end;
147
148
  }
@@ -181,7 +182,7 @@ function parseCellBlocks(inner, contentWidthPt) {
181
182
  }
182
183
  function applyTextAlign(blocks, alignment) {
183
184
  const first = blocks[0];
184
- if (alignment === void 0 || first?.kind !== "paragraph") return blocks;
185
+ if (alignment === void 0 || first?.kind !== "paragraph") return [...blocks];
185
186
  return [{
186
187
  ...first,
187
188
  alignment
@@ -221,10 +222,11 @@ function parseTableRows(inner, contentWidthPt) {
221
222
  }
222
223
  function buildContentTable(rows, contentWidthPt) {
223
224
  const columnCount = rows[0].cells.length;
225
+ const columns = Array.from({ length: columnCount }, () => ({ widthPt: contentWidthPt / columnCount }));
224
226
  return {
225
227
  kind: "table",
226
- rows,
227
- columns: Array.from({ length: columnCount }, () => ({ widthPt: contentWidthPt / columnCount }))
228
+ rows: [...rows],
229
+ columns
228
230
  };
229
231
  }
230
232
  function parseWholeTable(text, contentWidthPt) {
@@ -12,7 +12,7 @@ function buildRun(text, style, fontFamily) {
12
12
  ...fontFamily !== void 0 ? { fontFamily } : {}
13
13
  };
14
14
  }
15
- function lowerNestedEmphasisLike(kind, node, style, context, runs, extents) {
15
+ function lowerNestedEmphasisLike(kind, node, style, context, acc) {
16
16
  if (style[kind] === true) context.sink({
17
17
  code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.NESTED_EMPHASIS_FLATTENED,
18
18
  severity: "info",
@@ -22,16 +22,16 @@ function lowerNestedEmphasisLike(kind, node, style, context, runs, extents) {
22
22
  ...style,
23
23
  [kind]: true
24
24
  };
25
- lowerNodesInto(node.children, childStyle, context, runs, extents);
25
+ lowerNodesInto(node.children, childStyle, context, acc);
26
26
  }
27
- function lowerInlineNodeInto(node, style, context, runs, extents) {
27
+ function lowerInlineNodeInto(node, style, context, acc) {
28
28
  switch (node.type) {
29
29
  case "text":
30
30
  case "entity":
31
- if (node.value.length > 0) runs.push(buildRun(node.value, style));
31
+ if (node.value.length > 0) acc.runs.push(buildRun(node.value, style));
32
32
  return;
33
33
  case "softBreak":
34
- runs.push({
34
+ acc.runs.push({
35
35
  ...buildRun(" ", style),
36
36
  source: {
37
37
  format: "markdown",
@@ -40,10 +40,10 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
40
40
  });
41
41
  return;
42
42
  case "hardBreak":
43
- runs.push(buildRun("\n", style));
43
+ acc.runs.push(buildRun("\n", style));
44
44
  return;
45
45
  case "codeSpan":
46
- runs.push(buildRun(node.literal, style, require_shared_style_constants.MONOSPACE_FONT_FAMILY));
46
+ acc.runs.push(buildRun(node.literal, style, require_shared_style_constants.MONOSPACE_FONT_FAMILY));
47
47
  return;
48
48
  case "rawHtml":
49
49
  if (context.rawHtml === "drop") {
@@ -59,7 +59,7 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
59
59
  severity: "info",
60
60
  message: "inline raw HTML was preserved as literal text; it will not be rendered as HTML by any consumer of the resulting ContentDocument, and its verbatim original rides the run's own markdown residue for this package's writer to re-emit as-is"
61
61
  });
62
- if (node.literal.length > 0) runs.push({
62
+ if (node.literal.length > 0) acc.runs.push({
63
63
  ...buildRun(node.literal, style),
64
64
  source: {
65
65
  format: "markdown",
@@ -73,23 +73,23 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
73
73
  severity: "info",
74
74
  message: "inline math (\\( \\)) was preserved as literal raw LaTeX text; it is not parsed as LaTeX or converted to MathML by this package"
75
75
  });
76
- runs.push(buildRun(node.literal, style, require_shared_style_constants.MATH_INLINE_FONT_MARKER));
76
+ acc.runs.push(buildRun(node.literal, style, require_shared_style_constants.MATH_INLINE_FONT_MARKER));
77
77
  return;
78
78
  case "footnoteReference":
79
- runs.push(buildRun(`[^${node.label}]`, style));
80
- extents.push({
79
+ acc.runs.push(buildRun(`[^${node.label}]`, style));
80
+ acc.extents.push({
81
81
  descriptor: {
82
82
  kind: "anchor",
83
83
  anchorType: "footnote",
84
84
  name: node.label
85
85
  },
86
- startRun: runs.length - 1,
87
- endRun: runs.length - 1
86
+ startRun: acc.runs.length - 1,
87
+ endRun: acc.runs.length - 1
88
88
  });
89
89
  return;
90
90
  case "autolink": {
91
91
  const destination = node.email ? `mailto:${node.destination}` : node.destination;
92
- runs.push(buildRun(node.destination, {
92
+ acc.runs.push(buildRun(node.destination, {
93
93
  ...style,
94
94
  hyperlink: destination
95
95
  }));
@@ -100,10 +100,10 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
100
100
  ...style,
101
101
  hyperlink: node.destination
102
102
  };
103
- const startRun = runs.length;
104
- lowerNodesInto(node.children, childStyle, context, runs, extents);
105
- if (runs.length === startRun) runs.push(buildRun("", childStyle));
106
- if (node.title !== void 0) extents.push({
103
+ const startRun = acc.runs.length;
104
+ lowerNodesInto(node.children, childStyle, context, acc);
105
+ if (acc.runs.length === startRun) acc.runs.push(buildRun("", childStyle));
106
+ if (node.title !== void 0) acc.extents.push({
107
107
  descriptor: {
108
108
  kind: "link",
109
109
  target: {
@@ -113,7 +113,7 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
113
113
  title: node.title
114
114
  },
115
115
  startRun,
116
- endRun: runs.length
116
+ endRun: acc.runs.length
117
117
  });
118
118
  return;
119
119
  }
@@ -123,32 +123,34 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
123
123
  severity: "info",
124
124
  message: `image title "${node.title}" has no ContentRun equivalent and was dropped`
125
125
  });
126
- runs.push(buildRun(node.alt, {
126
+ acc.runs.push(buildRun(node.alt, {
127
127
  ...style,
128
128
  hyperlink: node.destination
129
129
  }));
130
130
  return;
131
131
  case "emphasis":
132
- lowerNestedEmphasisLike("italic", node, style, context, runs, extents);
132
+ lowerNestedEmphasisLike("italic", node, style, context, acc);
133
133
  return;
134
134
  case "strong":
135
- lowerNestedEmphasisLike("bold", node, style, context, runs, extents);
135
+ lowerNestedEmphasisLike("bold", node, style, context, acc);
136
136
  return;
137
137
  case "strikethrough":
138
- lowerNestedEmphasisLike("strike", node, style, context, runs, extents);
138
+ lowerNestedEmphasisLike("strike", node, style, context, acc);
139
139
  return;
140
140
  }
141
141
  }
142
- function lowerNodesInto(nodes, style, context, runs, extents) {
143
- for (const node of nodes) lowerInlineNodeInto(node, style, context, runs, extents);
142
+ function lowerNodesInto(nodes, style, context, acc) {
143
+ for (const node of nodes) lowerInlineNodeInto(node, style, context, acc);
144
144
  }
145
145
  function lowerInlineNodes(nodes, context) {
146
- const runs = [];
147
- const extents = [];
148
- lowerNodesInto(nodes, {}, context, runs, extents);
146
+ const acc = {
147
+ runs: [],
148
+ extents: []
149
+ };
150
+ lowerNodesInto(nodes, {}, context, acc);
149
151
  return {
150
- runs,
151
- runConstructExtents: extents
152
+ runs: acc.runs,
153
+ runConstructExtents: acc.extents
152
154
  };
153
155
  }
154
156
  function lowerCodeBlockRun(literal) {
@@ -11,7 +11,7 @@ function buildRun(text, style, fontFamily) {
11
11
  ...fontFamily !== void 0 ? { fontFamily } : {}
12
12
  };
13
13
  }
14
- function lowerNestedEmphasisLike(kind, node, style, context, runs, extents) {
14
+ function lowerNestedEmphasisLike(kind, node, style, context, acc) {
15
15
  if (style[kind] === true) context.sink({
16
16
  code: MarkdownDiagnosticCodes.NESTED_EMPHASIS_FLATTENED,
17
17
  severity: "info",
@@ -21,16 +21,16 @@ function lowerNestedEmphasisLike(kind, node, style, context, runs, extents) {
21
21
  ...style,
22
22
  [kind]: true
23
23
  };
24
- lowerNodesInto(node.children, childStyle, context, runs, extents);
24
+ lowerNodesInto(node.children, childStyle, context, acc);
25
25
  }
26
- function lowerInlineNodeInto(node, style, context, runs, extents) {
26
+ function lowerInlineNodeInto(node, style, context, acc) {
27
27
  switch (node.type) {
28
28
  case "text":
29
29
  case "entity":
30
- if (node.value.length > 0) runs.push(buildRun(node.value, style));
30
+ if (node.value.length > 0) acc.runs.push(buildRun(node.value, style));
31
31
  return;
32
32
  case "softBreak":
33
- runs.push({
33
+ acc.runs.push({
34
34
  ...buildRun(" ", style),
35
35
  source: {
36
36
  format: "markdown",
@@ -39,10 +39,10 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
39
39
  });
40
40
  return;
41
41
  case "hardBreak":
42
- runs.push(buildRun("\n", style));
42
+ acc.runs.push(buildRun("\n", style));
43
43
  return;
44
44
  case "codeSpan":
45
- runs.push(buildRun(node.literal, style, MONOSPACE_FONT_FAMILY));
45
+ acc.runs.push(buildRun(node.literal, style, MONOSPACE_FONT_FAMILY));
46
46
  return;
47
47
  case "rawHtml":
48
48
  if (context.rawHtml === "drop") {
@@ -58,7 +58,7 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
58
58
  severity: "info",
59
59
  message: "inline raw HTML was preserved as literal text; it will not be rendered as HTML by any consumer of the resulting ContentDocument, and its verbatim original rides the run's own markdown residue for this package's writer to re-emit as-is"
60
60
  });
61
- if (node.literal.length > 0) runs.push({
61
+ if (node.literal.length > 0) acc.runs.push({
62
62
  ...buildRun(node.literal, style),
63
63
  source: {
64
64
  format: "markdown",
@@ -72,23 +72,23 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
72
72
  severity: "info",
73
73
  message: "inline math (\\( \\)) was preserved as literal raw LaTeX text; it is not parsed as LaTeX or converted to MathML by this package"
74
74
  });
75
- runs.push(buildRun(node.literal, style, MATH_INLINE_FONT_MARKER));
75
+ acc.runs.push(buildRun(node.literal, style, MATH_INLINE_FONT_MARKER));
76
76
  return;
77
77
  case "footnoteReference":
78
- runs.push(buildRun(`[^${node.label}]`, style));
79
- extents.push({
78
+ acc.runs.push(buildRun(`[^${node.label}]`, style));
79
+ acc.extents.push({
80
80
  descriptor: {
81
81
  kind: "anchor",
82
82
  anchorType: "footnote",
83
83
  name: node.label
84
84
  },
85
- startRun: runs.length - 1,
86
- endRun: runs.length - 1
85
+ startRun: acc.runs.length - 1,
86
+ endRun: acc.runs.length - 1
87
87
  });
88
88
  return;
89
89
  case "autolink": {
90
90
  const destination = node.email ? `mailto:${node.destination}` : node.destination;
91
- runs.push(buildRun(node.destination, {
91
+ acc.runs.push(buildRun(node.destination, {
92
92
  ...style,
93
93
  hyperlink: destination
94
94
  }));
@@ -99,10 +99,10 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
99
99
  ...style,
100
100
  hyperlink: node.destination
101
101
  };
102
- const startRun = runs.length;
103
- lowerNodesInto(node.children, childStyle, context, runs, extents);
104
- if (runs.length === startRun) runs.push(buildRun("", childStyle));
105
- if (node.title !== void 0) extents.push({
102
+ const startRun = acc.runs.length;
103
+ lowerNodesInto(node.children, childStyle, context, acc);
104
+ if (acc.runs.length === startRun) acc.runs.push(buildRun("", childStyle));
105
+ if (node.title !== void 0) acc.extents.push({
106
106
  descriptor: {
107
107
  kind: "link",
108
108
  target: {
@@ -112,7 +112,7 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
112
112
  title: node.title
113
113
  },
114
114
  startRun,
115
- endRun: runs.length
115
+ endRun: acc.runs.length
116
116
  });
117
117
  return;
118
118
  }
@@ -122,32 +122,34 @@ function lowerInlineNodeInto(node, style, context, runs, extents) {
122
122
  severity: "info",
123
123
  message: `image title "${node.title}" has no ContentRun equivalent and was dropped`
124
124
  });
125
- runs.push(buildRun(node.alt, {
125
+ acc.runs.push(buildRun(node.alt, {
126
126
  ...style,
127
127
  hyperlink: node.destination
128
128
  }));
129
129
  return;
130
130
  case "emphasis":
131
- lowerNestedEmphasisLike("italic", node, style, context, runs, extents);
131
+ lowerNestedEmphasisLike("italic", node, style, context, acc);
132
132
  return;
133
133
  case "strong":
134
- lowerNestedEmphasisLike("bold", node, style, context, runs, extents);
134
+ lowerNestedEmphasisLike("bold", node, style, context, acc);
135
135
  return;
136
136
  case "strikethrough":
137
- lowerNestedEmphasisLike("strike", node, style, context, runs, extents);
137
+ lowerNestedEmphasisLike("strike", node, style, context, acc);
138
138
  return;
139
139
  }
140
140
  }
141
- function lowerNodesInto(nodes, style, context, runs, extents) {
142
- for (const node of nodes) lowerInlineNodeInto(node, style, context, runs, extents);
141
+ function lowerNodesInto(nodes, style, context, acc) {
142
+ for (const node of nodes) lowerInlineNodeInto(node, style, context, acc);
143
143
  }
144
144
  function lowerInlineNodes(nodes, context) {
145
- const runs = [];
146
- const extents = [];
147
- lowerNodesInto(nodes, {}, context, runs, extents);
145
+ const acc = {
146
+ runs: [],
147
+ extents: []
148
+ };
149
+ lowerNodesInto(nodes, {}, context, acc);
148
150
  return {
149
- runs,
150
- runConstructExtents: extents
151
+ runs: acc.runs,
152
+ runConstructExtents: acc.extents
151
153
  };
152
154
  }
153
155
  function lowerCodeBlockRun(literal) {
@@ -32,7 +32,7 @@ function decorateParagraph(paragraph, context) {
32
32
  }
33
33
  function paragraphWithConstructs(runs, runConstructExtents) {
34
34
  return {
35
- runs,
35
+ runs: [...runs],
36
36
  ...runConstructExtents.length > 0 ? { constructs: [...runConstructExtents] } : {}
37
37
  };
38
38
  }
@@ -31,7 +31,7 @@ function decorateParagraph(paragraph, context) {
31
31
  }
32
32
  function paragraphWithConstructs(runs, runConstructExtents) {
33
33
  return {
34
- runs,
34
+ runs: [...runs],
35
35
  ...runConstructExtents.length > 0 ? { constructs: [...runConstructExtents] } : {}
36
36
  };
37
37
  }
@@ -3,11 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const NUMID_PATTERN = /^md(\d+):(bullet|ordered)(?:@(\d+))?(\+task)?(\+loose)?(?:\+owner=(md-i\d+))?$/;
4
4
  const DEFAULT_ORDERED_START = 1;
5
5
  function createNumIdMintState() {
6
- return { next: 1 };
6
+ return { counter: { next: 1 } };
7
7
  }
8
8
  function mintListNumId(state, options) {
9
- const id = state.next;
10
- state.next += 1;
9
+ const id = state.counter.next;
10
+ state.counter.next += 1;
11
11
  const startSuffix = options.type === "ordered" && options.start !== void 0 && options.start !== DEFAULT_ORDERED_START ? `@${String(options.start)}` : "";
12
12
  const taskSuffix = options.task ? "+task" : "";
13
13
  const looseSuffix = options.loose ? "+loose" : "";
@@ -32,8 +32,8 @@ function mintedListType(numId) {
32
32
  return parseListNumId(numId)?.type;
33
33
  }
34
34
  function mintListItemId(state) {
35
- const id = state.next;
36
- state.next += 1;
35
+ const id = state.counter.next;
36
+ state.counter.next += 1;
37
37
  return `md-i${String(id)}`;
38
38
  }
39
39
  //#endregion
@@ -13,9 +13,12 @@ interface ListNumIdMintOptions {
13
13
  readonly loose: boolean;
14
14
  readonly ownerItemId?: string;
15
15
  }
16
- interface NumIdMintState {
16
+ interface MintCounter {
17
17
  next: number;
18
18
  }
19
+ interface NumIdMintState {
20
+ readonly counter: MintCounter;
21
+ }
19
22
  declare function createNumIdMintState(): NumIdMintState;
20
23
  declare function mintListNumId(state: NumIdMintState, options: ListNumIdMintOptions): string;
21
24
  declare function parseListNumId(numId: string): ListNumIdInfo | undefined;
@@ -13,9 +13,12 @@ interface ListNumIdMintOptions {
13
13
  readonly loose: boolean;
14
14
  readonly ownerItemId?: string;
15
15
  }
16
- interface NumIdMintState {
16
+ interface MintCounter {
17
17
  next: number;
18
18
  }
19
+ interface NumIdMintState {
20
+ readonly counter: MintCounter;
21
+ }
19
22
  declare function createNumIdMintState(): NumIdMintState;
20
23
  declare function mintListNumId(state: NumIdMintState, options: ListNumIdMintOptions): string;
21
24
  declare function parseListNumId(numId: string): ListNumIdInfo | undefined;
@@ -2,11 +2,11 @@
2
2
  const NUMID_PATTERN = /^md(\d+):(bullet|ordered)(?:@(\d+))?(\+task)?(\+loose)?(?:\+owner=(md-i\d+))?$/;
3
3
  const DEFAULT_ORDERED_START = 1;
4
4
  function createNumIdMintState() {
5
- return { next: 1 };
5
+ return { counter: { next: 1 } };
6
6
  }
7
7
  function mintListNumId(state, options) {
8
- const id = state.next;
9
- state.next += 1;
8
+ const id = state.counter.next;
9
+ state.counter.next += 1;
10
10
  const startSuffix = options.type === "ordered" && options.start !== void 0 && options.start !== DEFAULT_ORDERED_START ? `@${String(options.start)}` : "";
11
11
  const taskSuffix = options.task ? "+task" : "";
12
12
  const looseSuffix = options.loose ? "+loose" : "";
@@ -31,8 +31,8 @@ function mintedListType(numId) {
31
31
  return parseListNumId(numId)?.type;
32
32
  }
33
33
  function mintListItemId(state) {
34
- const id = state.next;
35
- state.next += 1;
34
+ const id = state.counter.next;
35
+ state.counter.next += 1;
36
36
  return `md-i${String(id)}`;
37
37
  }
38
38
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-codec",
3
- "version": "11.1.3",
3
+ "version": "11.1.5",
4
4
  "description": "Hand-written CommonMark+GFM <-> DocumentTree codec, built on document-schema.js",
5
5
  "type": "module",
6
6
  "repository": {
@@ -83,8 +83,8 @@
83
83
  "license": "MIT",
84
84
  "packageManager": "pnpm@12.4.1+sha512.2e81e399d73fe8390dab25e06aa788ab7a5908248d2f5a370f82b481147a6a7a367bf8048f9a6fdb6460f21a66f0542dedb8b94ca2c8723596741920b1656d4c",
85
85
  "dependencies": {
86
- "byte-codec": "1.10.1",
87
- "document-schema.js": "7.15.0",
86
+ "byte-codec": "2.0.0",
87
+ "document-schema.js": "7.15.1",
88
88
  "zod": "4.4.3"
89
89
  },
90
90
  "devDependencies": {