markdown-codec 11.1.4 → 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 +8 -8
- package/dist/codec.d.ts +8 -8
- package/dist/html/html-table.cjs +10 -8
- package/dist/html/html-table.js +10 -8
- package/dist/lower/inline.cjs +32 -30
- package/dist/lower/inline.js +32 -30
- package/dist/lower/lower.cjs +1 -1
- package/dist/lower/lower.js +1 -1
- package/dist/shared/list-id.cjs +5 -5
- package/dist/shared/list-id.d.cts +4 -1
- package/dist/shared/list-id.d.ts +4 -1
- package/dist/shared/list-id.js +5 -5
- package/package.json +2 -2
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<{
|
|
@@ -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<{
|
|
@@ -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<{
|
|
@@ -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
|
}>;
|
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<{
|
|
@@ -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<{
|
|
@@ -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
|
}>;
|
package/dist/html/html-table.cjs
CHANGED
|
@@ -117,21 +117,22 @@ function applyTagStyle(style, tagName, attrs) {
|
|
|
117
117
|
default: return style;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
function pushPlainRun(
|
|
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(
|
|
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(
|
|
143
|
+
pushPlainRun(sink, rest, style);
|
|
143
144
|
return runs;
|
|
144
145
|
}
|
|
145
|
-
pushPlainRun(
|
|
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
|
|
229
|
+
rows: [...rows],
|
|
230
|
+
columns
|
|
229
231
|
};
|
|
230
232
|
}
|
|
231
233
|
function parseWholeTable(text, contentWidthPt) {
|
package/dist/html/html-table.js
CHANGED
|
@@ -116,21 +116,22 @@ function applyTagStyle(style, tagName, attrs) {
|
|
|
116
116
|
default: return style;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
function pushPlainRun(
|
|
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(
|
|
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(
|
|
142
|
+
pushPlainRun(sink, rest, style);
|
|
142
143
|
return runs;
|
|
143
144
|
}
|
|
144
|
-
pushPlainRun(
|
|
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
|
|
228
|
+
rows: [...rows],
|
|
229
|
+
columns
|
|
228
230
|
};
|
|
229
231
|
}
|
|
230
232
|
function parseWholeTable(text, contentWidthPt) {
|
package/dist/lower/inline.cjs
CHANGED
|
@@ -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,
|
|
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,
|
|
25
|
+
lowerNodesInto(node.children, childStyle, context, acc);
|
|
26
26
|
}
|
|
27
|
-
function lowerInlineNodeInto(node, style, context,
|
|
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,
|
|
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,
|
|
132
|
+
lowerNestedEmphasisLike("italic", node, style, context, acc);
|
|
133
133
|
return;
|
|
134
134
|
case "strong":
|
|
135
|
-
lowerNestedEmphasisLike("bold", node, style, context,
|
|
135
|
+
lowerNestedEmphasisLike("bold", node, style, context, acc);
|
|
136
136
|
return;
|
|
137
137
|
case "strikethrough":
|
|
138
|
-
lowerNestedEmphasisLike("strike", node, style, context,
|
|
138
|
+
lowerNestedEmphasisLike("strike", node, style, context, acc);
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
function lowerNodesInto(nodes, style, context,
|
|
143
|
-
for (const node of nodes) lowerInlineNodeInto(node, style, context,
|
|
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
|
|
147
|
-
|
|
148
|
-
|
|
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) {
|
package/dist/lower/inline.js
CHANGED
|
@@ -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,
|
|
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,
|
|
24
|
+
lowerNodesInto(node.children, childStyle, context, acc);
|
|
25
25
|
}
|
|
26
|
-
function lowerInlineNodeInto(node, style, context,
|
|
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,
|
|
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,
|
|
131
|
+
lowerNestedEmphasisLike("italic", node, style, context, acc);
|
|
132
132
|
return;
|
|
133
133
|
case "strong":
|
|
134
|
-
lowerNestedEmphasisLike("bold", node, style, context,
|
|
134
|
+
lowerNestedEmphasisLike("bold", node, style, context, acc);
|
|
135
135
|
return;
|
|
136
136
|
case "strikethrough":
|
|
137
|
-
lowerNestedEmphasisLike("strike", node, style, context,
|
|
137
|
+
lowerNestedEmphasisLike("strike", node, style, context, acc);
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function lowerNodesInto(nodes, style, context,
|
|
142
|
-
for (const node of nodes) lowerInlineNodeInto(node, style, context,
|
|
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
|
|
146
|
-
|
|
147
|
-
|
|
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) {
|
package/dist/lower/lower.cjs
CHANGED
package/dist/lower/lower.js
CHANGED
package/dist/shared/list-id.cjs
CHANGED
|
@@ -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
|
|
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;
|
package/dist/shared/list-id.d.ts
CHANGED
|
@@ -13,9 +13,12 @@ interface ListNumIdMintOptions {
|
|
|
13
13
|
readonly loose: boolean;
|
|
14
14
|
readonly ownerItemId?: string;
|
|
15
15
|
}
|
|
16
|
-
interface
|
|
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;
|
package/dist/shared/list-id.js
CHANGED
|
@@ -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
|
+
"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": {
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"packageManager": "pnpm@12.4.1+sha512.2e81e399d73fe8390dab25e06aa788ab7a5908248d2f5a370f82b481147a6a7a367bf8048f9a6fdb6460f21a66f0542dedb8b94ca2c8723596741920b1656d4c",
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"byte-codec": "2.0.0",
|
|
87
|
-
"document-schema.js": "7.15.
|
|
87
|
+
"document-schema.js": "7.15.1",
|
|
88
88
|
"zod": "4.4.3"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|