markdown-codec 11.1.13 → 11.1.15
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/block/block.cjs +23 -612
- package/dist/block/block.d.cts +22 -3
- package/dist/block/block.d.ts +22 -3
- package/dist/block/block.js +2 -607
- package/dist/block/definitions.d.cts +1 -1
- package/dist/block/definitions.d.ts +1 -1
- package/dist/block/list.d.cts +1 -1
- package/dist/block/list.d.ts +1 -1
- package/dist/block/node.d.cts +1 -45
- package/dist/block/node.d.ts +1 -45
- package/dist/block/parser.cjs +3 -0
- package/dist/block/parser.d.cts +57 -0
- package/dist/block/parser.d.ts +57 -0
- package/dist/block/parser.js +2 -0
- package/dist/block-C3ftt8qO.js +610 -0
- package/dist/block-DsxTiUms.cjs +747 -0
- package/dist/codec.d.cts +18 -18
- package/dist/codec.d.ts +18 -18
- package/dist/defaults/defaults.d.cts +1 -1
- package/dist/defaults/defaults.d.ts +1 -1
- package/dist/emit/emit.cjs +7 -647
- package/dist/emit/emit.d.cts +22 -3
- package/dist/emit/emit.d.ts +22 -3
- package/dist/emit/emit.js +2 -646
- package/dist/emit/html-table.d.cts +1 -1
- package/dist/emit/html-table.d.ts +1 -1
- package/dist/emit/inline.cjs +1 -1
- package/dist/emit/inline.js +1 -1
- package/dist/emit/list-render.cjs +29 -0
- package/dist/emit/list-render.d.cts +81 -0
- package/dist/emit/list-render.d.ts +81 -0
- package/dist/emit/list-render.js +2 -0
- package/dist/emit/setext.cjs +143 -0
- package/dist/emit/setext.d.cts +30 -0
- package/dist/emit/setext.d.ts +30 -0
- package/dist/emit/setext.js +119 -0
- package/dist/emit/table.d.cts +1 -11
- package/dist/emit/table.d.ts +1 -11
- package/dist/emit-CCOoudJW.cjs +734 -0
- package/dist/emit-Do1KMQHB.js +537 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/inline/entity.cjs +1 -1
- package/dist/inline/entity.js +1 -1
- package/dist/inline/inline.cjs +2 -2
- package/dist/inline/inline.d.cts +1 -1
- package/dist/inline/inline.d.ts +1 -1
- package/dist/inline/inline.js +2 -2
- package/dist/{inline-CArcArOD.d.ts → inline-BG6ge5m2.d.ts} +1 -1
- package/dist/{inline-GzD5QtFh.d.cts → inline-BxX0iOy6.d.cts} +1 -1
- package/dist/lower/lower.cjs +3 -3
- package/dist/lower/lower.d.cts +1 -1
- package/dist/lower/lower.d.ts +1 -1
- package/dist/lower/lower.js +2 -2
- package/dist/node-DcxnTjF0.d.cts +46 -0
- package/dist/node-w8dVfAUD.d.ts +46 -0
- package/dist/options/options.d.cts +1 -43
- package/dist/options/options.d.ts +1 -43
- package/dist/options-CZoMEGL8.d.ts +44 -0
- package/dist/options-ZnZOMG3X.d.cts +44 -0
- package/dist/read.d.cts +1 -1
- package/dist/read.d.ts +1 -1
- package/dist/scan/entity-table-n-z.cjs +207 -0
- package/dist/scan/entity-table-n-z.d.cts +4 -0
- package/dist/scan/entity-table-n-z.d.ts +4 -0
- package/dist/scan/entity-table-n-z.js +206 -0
- package/dist/scan/entity-table-t-z.cjs +28 -0
- package/dist/scan/entity-table-t-z.d.cts +4 -0
- package/dist/scan/entity-table-t-z.d.ts +4 -0
- package/dist/scan/entity-table-t-z.js +27 -0
- package/dist/scan/entity-table-u-z.cjs +59 -0
- package/dist/scan/entity-table-u-z.d.cts +4 -0
- package/dist/scan/entity-table-u-z.d.ts +4 -0
- package/dist/scan/entity-table-u-z.js +58 -0
- package/dist/scan/entity-table-w-z.cjs +11 -0
- package/dist/scan/entity-table-w-z.d.cts +4 -0
- package/dist/scan/entity-table-w-z.d.ts +4 -0
- package/dist/scan/entity-table-w-z.js +10 -0
- package/dist/scan/entity-table-x-z.cjs +10 -0
- package/dist/scan/entity-table-x-z.d.cts +4 -0
- package/dist/scan/entity-table-x-z.d.ts +4 -0
- package/dist/scan/entity-table-x-z.js +9 -0
- package/dist/scan/entity-table-y-z-2.cjs +780 -0
- package/dist/scan/entity-table-y-z-2.d.cts +4 -0
- package/dist/scan/entity-table-y-z-2.d.ts +4 -0
- package/dist/scan/entity-table-y-z-2.js +779 -0
- package/dist/scan/entity-table-y-z.cjs +779 -0
- package/dist/scan/entity-table-y-z.d.cts +4 -0
- package/dist/scan/entity-table-y-z.d.ts +4 -0
- package/dist/scan/entity-table-y-z.js +778 -0
- package/dist/scan/entity-table.cjs +20 -1834
- package/dist/scan/entity-table.d.cts +2 -1
- package/dist/scan/entity-table.d.ts +2 -1
- package/dist/scan/entity-table.js +20 -1835
- package/dist/table-BFbOhm0R.d.ts +12 -0
- package/dist/table-PtkYEYdL.d.cts +12 -0
- package/dist/write.cjs +2 -2
- package/dist/write.d.cts +1 -1
- package/dist/write.d.ts +1 -1
- package/dist/write.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import { MarkdownDiagnosticCodes, MarkdownInvalidRunConstructExtentError, MarkdownUnbalancedConstructMarkersError, MarkdownUnsupportedDocumentKindError, NOOP_MARKDOWN_DIAGNOSTIC_SINK } from "./diagnostics/diagnostics.js";
|
|
2
|
+
import { isValidFootnoteLabel } from "./inline/footnote.js";
|
|
3
|
+
import { LINE_ENDING_PATTERN } from "./shared/line-ending.js";
|
|
4
|
+
import "./defaults/defaults.js";
|
|
5
|
+
import { parseHeadingStyleId } from "./shared/style-constants.js";
|
|
6
|
+
import { parseListNumId } from "./shared/list-id.js";
|
|
7
|
+
import { emitFrontMatter } from "./emit/front-matter.js";
|
|
8
|
+
import { emitRuns, escapeLinkDestination, escapeMarkdownText, renderLinkTitle } from "./emit/inline.js";
|
|
9
|
+
import { emitImage } from "./emit/image.js";
|
|
10
|
+
import { emitTable } from "./emit/table.js";
|
|
11
|
+
import { codeFenceFor, firstContentLineIndex, isQuotableStyle, renderAtxHeading, renderSetextHeading, splitLines, terminatesCleanly, unsafeSetextBreakReason, unsafeSetextDiagnosticMessage, willRenderAsSetext } from "./emit/setext.js";
|
|
12
|
+
import { clampHeadingLevel, findConstructMarkerImbalance, findRunConstructFault } from "document-schema.js";
|
|
13
|
+
//#region src/emit/list-render.ts
|
|
14
|
+
function listInfoFor(numId, context) {
|
|
15
|
+
if (numId === void 0) {
|
|
16
|
+
if (!context.reportedAbsentNumIdFallback) {
|
|
17
|
+
context.reportedAbsentNumIdFallback = true;
|
|
18
|
+
context.sink({
|
|
19
|
+
code: MarkdownDiagnosticCodes.LIST_NUMID_FALLBACK,
|
|
20
|
+
severity: "info",
|
|
21
|
+
message: "a list membership with no numId of its own (a depth-only ContentListMembership) has no marker type, task-ness, or loose-ness to recover and falls back to an ordinary, tight, non-task bullet list"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const info = parseListNumId(numId);
|
|
27
|
+
if (info === void 0 && !context.reportedFallbackNumIds.has(numId)) {
|
|
28
|
+
context.reportedFallbackNumIds.add(numId);
|
|
29
|
+
context.sink({
|
|
30
|
+
code: MarkdownDiagnosticCodes.LIST_NUMID_FALLBACK,
|
|
31
|
+
severity: "info",
|
|
32
|
+
message: `numId "${numId}" was not minted by this package's own src/lower and falls back to an ordinary, tight, non-task bullet list`
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return info;
|
|
36
|
+
}
|
|
37
|
+
function stripCheckboxRun(item) {
|
|
38
|
+
const first = item.runs[0];
|
|
39
|
+
const glyphPrefix = first?.text.startsWith(`☒ `) === true ? `☒ ` : `☐ `;
|
|
40
|
+
if (first?.text.startsWith(glyphPrefix) !== true) return item;
|
|
41
|
+
const strippedText = first.text.slice(glyphPrefix.length);
|
|
42
|
+
const runs = strippedText.length === 0 ? item.runs.slice(1) : [{
|
|
43
|
+
...first,
|
|
44
|
+
text: strippedText
|
|
45
|
+
}, ...item.runs.slice(1)];
|
|
46
|
+
return {
|
|
47
|
+
...item,
|
|
48
|
+
runs
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function toEmitItem(item) {
|
|
52
|
+
return item.kind === "paragraph" ? { block: item.block } : item.item;
|
|
53
|
+
}
|
|
54
|
+
function firstBlockCheckbox(first, taskNumId) {
|
|
55
|
+
if (first.list.checked !== void 0) return {
|
|
56
|
+
checkboxText: first.list.checked ? "[x] " : "[ ] ",
|
|
57
|
+
strippedFirstBlock: void 0
|
|
58
|
+
};
|
|
59
|
+
if (!taskNumId || first.kind !== "paragraph") return {
|
|
60
|
+
checkboxText: "",
|
|
61
|
+
strippedFirstBlock: void 0
|
|
62
|
+
};
|
|
63
|
+
const leading = first.block.runs[0]?.text;
|
|
64
|
+
if (leading?.startsWith(`☒ `) === true) return {
|
|
65
|
+
checkboxText: "[x] ",
|
|
66
|
+
strippedFirstBlock: stripCheckboxRun(first.block)
|
|
67
|
+
};
|
|
68
|
+
if (leading?.startsWith(`☐ `) === true) return {
|
|
69
|
+
checkboxText: "[ ] ",
|
|
70
|
+
strippedFirstBlock: stripCheckboxRun(first.block)
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
checkboxText: "",
|
|
74
|
+
strippedFirstBlock: void 0
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function renderListItemMarker(numId, info, glyph, checkboxText, context) {
|
|
78
|
+
if (info?.type === "ordered" && numId !== void 0) {
|
|
79
|
+
const next = context.orderedCounters.get(numId) ?? info.start ?? 1;
|
|
80
|
+
context.orderedCounters.set(numId, next + 1);
|
|
81
|
+
const bare = `${String(next)}${glyph} `;
|
|
82
|
+
return {
|
|
83
|
+
full: `${bare}${checkboxText}`,
|
|
84
|
+
bareLength: bare.length
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const bare = `${glyph} `;
|
|
88
|
+
return {
|
|
89
|
+
full: `${bare}${checkboxText}`,
|
|
90
|
+
bareLength: bare.length
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const BULLET_GLYPH_CANDIDATES = [
|
|
94
|
+
"-",
|
|
95
|
+
"+",
|
|
96
|
+
"*"
|
|
97
|
+
];
|
|
98
|
+
const ORDERED_GLYPH_CANDIDATES = [".", ")"];
|
|
99
|
+
function resolveListGlyph(numId, type, previousSibling, context) {
|
|
100
|
+
const cached = context.resolvedListGlyphs.get(numId);
|
|
101
|
+
if (cached !== void 0) return cached;
|
|
102
|
+
const defaultGlyph = type === "ordered" ? context.orderedDelimiter : context.bulletMarker;
|
|
103
|
+
const glyph = previousSibling?.type === type && previousSibling.glyph === defaultGlyph ? (type === "ordered" ? ORDERED_GLYPH_CANDIDATES : BULLET_GLYPH_CANDIDATES).find((candidate) => candidate !== defaultGlyph) ?? defaultGlyph : defaultGlyph;
|
|
104
|
+
context.resolvedListGlyphs.set(numId, glyph);
|
|
105
|
+
return glyph;
|
|
106
|
+
}
|
|
107
|
+
function consumeSameItemRun(items, from, level, itemId) {
|
|
108
|
+
let end = from;
|
|
109
|
+
for (;;) {
|
|
110
|
+
const candidate = items[end];
|
|
111
|
+
if (candidate?.list.level !== level || candidate.list.itemId !== itemId) break;
|
|
112
|
+
end += 1;
|
|
113
|
+
}
|
|
114
|
+
return end;
|
|
115
|
+
}
|
|
116
|
+
function collectListItem(items, start, level, itemId) {
|
|
117
|
+
const segments = [];
|
|
118
|
+
let index = start;
|
|
119
|
+
const ownEnd = itemId === void 0 ? index + 1 : consumeSameItemRun(items, index, level, itemId);
|
|
120
|
+
segments.push({
|
|
121
|
+
kind: "own",
|
|
122
|
+
blocks: items.slice(index, ownEnd)
|
|
123
|
+
});
|
|
124
|
+
index = ownEnd;
|
|
125
|
+
for (;;) {
|
|
126
|
+
let nestedEnd = index;
|
|
127
|
+
for (;;) {
|
|
128
|
+
const candidateLevel = items[nestedEnd]?.list.level;
|
|
129
|
+
if (candidateLevel === void 0 || candidateLevel <= level) break;
|
|
130
|
+
nestedEnd += 1;
|
|
131
|
+
}
|
|
132
|
+
if (nestedEnd === index) break;
|
|
133
|
+
segments.push({
|
|
134
|
+
kind: "nested",
|
|
135
|
+
blocks: items.slice(index, nestedEnd)
|
|
136
|
+
});
|
|
137
|
+
index = nestedEnd;
|
|
138
|
+
if (itemId === void 0) break;
|
|
139
|
+
const resumedEnd = consumeSameItemRun(items, index, level, itemId);
|
|
140
|
+
segments.push({
|
|
141
|
+
kind: "own",
|
|
142
|
+
blocks: items.slice(index, resumedEnd)
|
|
143
|
+
});
|
|
144
|
+
index = resumedEnd;
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
segments,
|
|
148
|
+
next: index
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function emitItemCanInterrupt(item, context) {
|
|
152
|
+
if (!isConstructItem(item)) return item.block.kind === "paragraph" ? canInterruptOpenParagraph(item.block, context) : true;
|
|
153
|
+
if (isMaterialisedDivision(item)) return true;
|
|
154
|
+
const first = item.children[0];
|
|
155
|
+
return first === void 0 ? true : emitItemCanInterrupt(first, context);
|
|
156
|
+
}
|
|
157
|
+
function lastStyleIdOf(item) {
|
|
158
|
+
if (isConstructItem(item)) {
|
|
159
|
+
const last = item.children[item.children.length - 1];
|
|
160
|
+
return last === void 0 ? void 0 : lastStyleIdOf(last);
|
|
161
|
+
}
|
|
162
|
+
return item.block.kind === "paragraph" ? item.block.styleId : void 0;
|
|
163
|
+
}
|
|
164
|
+
function regionItemCanInterrupt(item, context) {
|
|
165
|
+
return emitItemCanInterrupt(toEmitItem(item), context);
|
|
166
|
+
}
|
|
167
|
+
function lastStyleIdOfRegionItem(item) {
|
|
168
|
+
return lastStyleIdOf(toEmitItem(item));
|
|
169
|
+
}
|
|
170
|
+
function listRegionItemBody(item, context, overrideParagraph) {
|
|
171
|
+
if (item.kind === "paragraph") return renderParagraphBody(overrideParagraph ?? item.block, context);
|
|
172
|
+
const previousEnclosingItemId = context.enclosingItemId;
|
|
173
|
+
context.enclosingItemId = item.list.itemId;
|
|
174
|
+
const body = renderConstruct(item.item, context);
|
|
175
|
+
context.enclosingItemId = previousEnclosingItemId;
|
|
176
|
+
return body;
|
|
177
|
+
}
|
|
178
|
+
function requiresBlankLineBefore(next, previousStyleId, context) {
|
|
179
|
+
if (previousStyleId === "HTMLPreformatted") return true;
|
|
180
|
+
return !terminatesCleanly(previousStyleId) && !regionItemCanInterrupt(next, context);
|
|
181
|
+
}
|
|
182
|
+
function renderListRegion(items, context) {
|
|
183
|
+
const parts = [];
|
|
184
|
+
let index = 0;
|
|
185
|
+
let previousSibling;
|
|
186
|
+
for (;;) {
|
|
187
|
+
const item = items[index];
|
|
188
|
+
if (item === void 0) break;
|
|
189
|
+
const { numId, level, itemId } = item.list;
|
|
190
|
+
const info = listInfoFor(numId, context);
|
|
191
|
+
const loose = info?.loose === true;
|
|
192
|
+
const type = info?.type ?? "bullet";
|
|
193
|
+
const glyph = numId === void 0 ? context.bulletMarker : resolveListGlyph(numId, type, previousSibling, context);
|
|
194
|
+
if (numId !== void 0) previousSibling = {
|
|
195
|
+
numId,
|
|
196
|
+
type,
|
|
197
|
+
glyph
|
|
198
|
+
};
|
|
199
|
+
const { segments, next } = collectListItem(items, index, level, itemId);
|
|
200
|
+
const first = segments[0]?.blocks[0];
|
|
201
|
+
if (first === void 0) break;
|
|
202
|
+
const { checkboxText, strippedFirstBlock } = firstBlockCheckbox(first, info?.task === true);
|
|
203
|
+
const marker = renderListItemMarker(numId, info, glyph, checkboxText, context);
|
|
204
|
+
const indent = " ".repeat(marker.bareLength);
|
|
205
|
+
let text = marker.full;
|
|
206
|
+
let renderedFirstLine = false;
|
|
207
|
+
let previousStyleId;
|
|
208
|
+
for (const segment of segments) {
|
|
209
|
+
if (segment.kind === "nested") {
|
|
210
|
+
const nested = renderListRegion(segment.blocks, context).split("\n").map((line) => line.length === 0 ? line : `${indent}${line}`).join("\n");
|
|
211
|
+
text += `\n${nested}`;
|
|
212
|
+
const lastNested = segment.blocks[segment.blocks.length - 1];
|
|
213
|
+
previousStyleId = lastNested === void 0 ? void 0 : lastStyleIdOfRegionItem(lastNested);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
for (const block of segment.blocks) {
|
|
217
|
+
if (!renderedFirstLine) {
|
|
218
|
+
const [firstLine, ...restLines] = splitLines(listRegionItemBody(block, context, strippedFirstBlock), "\n");
|
|
219
|
+
text += [firstLine, ...restLines.map((line) => `${indent}${line}`)].join("\n");
|
|
220
|
+
renderedFirstLine = true;
|
|
221
|
+
previousStyleId = lastStyleIdOfRegionItem(block);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const rendered = listRegionItemBody(block, context, void 0).split("\n").map((line) => line.length === 0 ? line : `${indent}${line}`).join("\n");
|
|
225
|
+
const blank = loose || requiresBlankLineBefore(block, previousStyleId, context);
|
|
226
|
+
text += blank ? `\n\n${rendered}` : `\n${rendered}`;
|
|
227
|
+
previousStyleId = lastStyleIdOfRegionItem(block);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
parts.push({
|
|
231
|
+
numId,
|
|
232
|
+
text
|
|
233
|
+
});
|
|
234
|
+
index = next;
|
|
235
|
+
}
|
|
236
|
+
let out = "";
|
|
237
|
+
for (const [partIndex, part] of parts.entries()) {
|
|
238
|
+
if (partIndex > 0) {
|
|
239
|
+
const previous = parts[partIndex - 1];
|
|
240
|
+
const continuesTightly = previous.numId === part.numId && (previous.numId === void 0 || parseListNumId(previous.numId)?.loose !== true);
|
|
241
|
+
out += continuesTightly ? "\n" : "\n\n";
|
|
242
|
+
}
|
|
243
|
+
out += part.text;
|
|
244
|
+
}
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
function isConstructItem(item) {
|
|
248
|
+
return "descriptor" in item;
|
|
249
|
+
}
|
|
250
|
+
const UNINDENTED_PT = 0;
|
|
251
|
+
function isMaterialisedDivision(item) {
|
|
252
|
+
return item.descriptor.kind === "division" && item.children.every((child) => {
|
|
253
|
+
if (isConstructItem(child)) return true;
|
|
254
|
+
return child.block.kind !== "paragraph" || (child.block.indentLeftPt ?? 0) >= 36;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function groupConstructItems(blocks, start) {
|
|
258
|
+
const items = [];
|
|
259
|
+
let index = start;
|
|
260
|
+
for (;;) {
|
|
261
|
+
const block = blocks[index];
|
|
262
|
+
if (block === void 0) break;
|
|
263
|
+
index += 1;
|
|
264
|
+
if (block.kind === "constructEnd") return {
|
|
265
|
+
items,
|
|
266
|
+
next: index
|
|
267
|
+
};
|
|
268
|
+
if (block.kind === "constructStart") {
|
|
269
|
+
const nested = groupConstructItems(blocks, index);
|
|
270
|
+
items.push({
|
|
271
|
+
descriptor: block.descriptor,
|
|
272
|
+
children: nested.items
|
|
273
|
+
});
|
|
274
|
+
index = nested.next;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
items.push({ block });
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
items,
|
|
281
|
+
next: index
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
const FOOTNOTE_CONTINUATION_INDENT = 4;
|
|
285
|
+
function renderFootnoteDefinition(name, body) {
|
|
286
|
+
const marker = `[^${name}]:`;
|
|
287
|
+
if (body.length === 0) return marker;
|
|
288
|
+
const indent = " ".repeat(4);
|
|
289
|
+
const [firstLine, ...restLines] = splitLines(body, "\n");
|
|
290
|
+
return [`${marker} ${firstLine}`, ...restLines.map((line) => line.length === 0 ? line : `${indent}${line}`)].join("\n");
|
|
291
|
+
}
|
|
292
|
+
function renderConstruct(item, context) {
|
|
293
|
+
const { descriptor } = item;
|
|
294
|
+
if (descriptor.kind === "anchor" && descriptor.anchorType === "footnote") {
|
|
295
|
+
const body = renderItems(item.children, context);
|
|
296
|
+
if (isValidFootnoteLabel(descriptor.name)) return renderFootnoteDefinition(descriptor.name, body);
|
|
297
|
+
context.sink({
|
|
298
|
+
code: MarkdownDiagnosticCodes.CONSTRUCT_UNREPRESENTED,
|
|
299
|
+
severity: "info",
|
|
300
|
+
message: `a footnote anchor's own name "${descriptor.name}" cannot be spelled as a "[^label]:" marker (whitespace or "]" would reparse as something else); its own extent still renders in place, but the construct itself is not represented`
|
|
301
|
+
});
|
|
302
|
+
return body;
|
|
303
|
+
}
|
|
304
|
+
if (isMaterialisedDivision(item)) {
|
|
305
|
+
context.divisionDepth += 1;
|
|
306
|
+
const body = renderItems(item.children, context);
|
|
307
|
+
context.divisionDepth -= 1;
|
|
308
|
+
return body.split("\n").map((line) => line.length === 0 ? ">" : `> ${line}`).join("\n");
|
|
309
|
+
}
|
|
310
|
+
if (descriptor.kind === "link" && descriptor.target.kind === "external") {
|
|
311
|
+
const onlyChild = item.children.length === 1 && !isConstructItem(item.children[0]) ? item.children[0].block : void 0;
|
|
312
|
+
if (onlyChild?.kind === "image" && !isDataUri(descriptor.target.uri)) return `}${descriptor.title === void 0 ? "" : ` "${renderLinkTitle(descriptor.title)}"`})`;
|
|
313
|
+
if (onlyChild?.kind === "image" && isDataUri(descriptor.target.uri) && !context.embedImages) return emitImage(onlyChild, false);
|
|
314
|
+
}
|
|
315
|
+
const body = renderItems(item.children, context);
|
|
316
|
+
const detail = descriptor.kind === "anchor" ? `${descriptor.kind} (${descriptor.anchorType})` : descriptor.kind;
|
|
317
|
+
context.sink({
|
|
318
|
+
code: MarkdownDiagnosticCodes.CONSTRUCT_UNREPRESENTED,
|
|
319
|
+
severity: "info",
|
|
320
|
+
message: `a "${detail}" construct has no markdown syntax; its own extent still renders in place, but the construct itself is not represented`
|
|
321
|
+
});
|
|
322
|
+
return body;
|
|
323
|
+
}
|
|
324
|
+
function constructCarriesListItemId(item, itemId) {
|
|
325
|
+
return item.children.some((child) => {
|
|
326
|
+
if (isConstructItem(child)) return constructCarriesListItemId(child, itemId);
|
|
327
|
+
if (child.block.kind !== "paragraph") return false;
|
|
328
|
+
const list = child.block.list;
|
|
329
|
+
if (list?.itemId === itemId) return true;
|
|
330
|
+
return list?.numId !== void 0 && parseListNumId(list.numId)?.ownerItemId === itemId;
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function isInheritedListMembership(list, context) {
|
|
334
|
+
return list.itemId !== void 0 && list.itemId === context.enclosingItemId;
|
|
335
|
+
}
|
|
336
|
+
function renderItems(items, context) {
|
|
337
|
+
const parts = [];
|
|
338
|
+
let index = 0;
|
|
339
|
+
for (;;) {
|
|
340
|
+
const item = items[index];
|
|
341
|
+
if (item === void 0) break;
|
|
342
|
+
if (isConstructItem(item)) {
|
|
343
|
+
const rendered = renderConstruct(item, context);
|
|
344
|
+
if (rendered.length > 0) parts.push(rendered);
|
|
345
|
+
index += 1;
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (item.block.kind === "paragraph" && item.block.list !== void 0 && !isInheritedListMembership(item.block.list, context)) {
|
|
349
|
+
const region = [];
|
|
350
|
+
let end = index;
|
|
351
|
+
const openMemberships = [];
|
|
352
|
+
for (;;) {
|
|
353
|
+
const candidate = items[end];
|
|
354
|
+
if (candidate === void 0) break;
|
|
355
|
+
if (isConstructItem(candidate)) {
|
|
356
|
+
let matched;
|
|
357
|
+
for (let i = openMemberships.length - 1; i >= 0; i -= 1) {
|
|
358
|
+
const membership = openMemberships[i];
|
|
359
|
+
if (membership.itemId !== void 0 && constructCarriesListItemId(candidate, membership.itemId)) {
|
|
360
|
+
matched = membership;
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (matched === void 0) break;
|
|
365
|
+
region.push({
|
|
366
|
+
kind: "construct",
|
|
367
|
+
item: candidate,
|
|
368
|
+
list: matched
|
|
369
|
+
});
|
|
370
|
+
end += 1;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (candidate.block.kind !== "paragraph" || candidate.block.list === void 0 || isInheritedListMembership(candidate.block.list, context)) break;
|
|
374
|
+
const list = candidate.block.list;
|
|
375
|
+
while (openMemberships.length > 0 && openMemberships[openMemberships.length - 1].level >= list.level) openMemberships.pop();
|
|
376
|
+
openMemberships.push(list);
|
|
377
|
+
region.push({
|
|
378
|
+
kind: "paragraph",
|
|
379
|
+
block: candidate.block,
|
|
380
|
+
list
|
|
381
|
+
});
|
|
382
|
+
end += 1;
|
|
383
|
+
}
|
|
384
|
+
parts.push(renderListRegion(region, context));
|
|
385
|
+
index = end;
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
const rendered = renderTopLevelBlock(item.block, context);
|
|
389
|
+
if (rendered.length > 0) parts.push(rendered);
|
|
390
|
+
index += 1;
|
|
391
|
+
}
|
|
392
|
+
return parts.join("\n\n");
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/emit/emit.ts
|
|
396
|
+
function isDataUri(destination) {
|
|
397
|
+
return destination.startsWith("data:");
|
|
398
|
+
}
|
|
399
|
+
function canInterruptOpenParagraph(paragraph, context) {
|
|
400
|
+
const styleId = paragraph.styleId;
|
|
401
|
+
if (styleId === void 0) return false;
|
|
402
|
+
if (styleId === "CodeBlock" || styleId === "MathBlock") return true;
|
|
403
|
+
if (styleId === "HorizontalRule") return context.thematicBreakChar !== "-";
|
|
404
|
+
const headingLevel = parseHeadingStyleId(styleId);
|
|
405
|
+
if (headingLevel !== void 0) return !willRenderAsSetext(paragraph, clampHeadingLevel(headingLevel), context);
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
function quoteDepthOf(paragraph) {
|
|
409
|
+
if (paragraph.indentLeftPt === void 0 || paragraph.indentLeftPt <= 0) return 0;
|
|
410
|
+
return Math.max(1, Math.round(paragraph.indentLeftPt / 36));
|
|
411
|
+
}
|
|
412
|
+
function renderParagraphBody(paragraph, context) {
|
|
413
|
+
if (paragraph.styleId === "HorizontalRule") return context.thematicBreakChar.repeat(3);
|
|
414
|
+
if (paragraph.styleId === "CodeBlock") {
|
|
415
|
+
const literal = paragraph.runs.map((run) => run.text).join("");
|
|
416
|
+
const fence = codeFenceFor(literal, context.codeFenceChar);
|
|
417
|
+
const remainder = paragraph.source?.format === "markdown" ? paragraph.source.xml : void 0;
|
|
418
|
+
const info = [paragraph.codeLanguage, remainder].filter((part) => part !== void 0 && part.length > 0).join(" ");
|
|
419
|
+
const opening = info.length > 0 ? `${fence} ${info}` : fence;
|
|
420
|
+
return literal.length === 0 ? `${opening}\n${fence}` : `${opening}\n${literal}\n${fence}`;
|
|
421
|
+
}
|
|
422
|
+
if (paragraph.styleId === "HTMLPreformatted") return paragraph.source?.format === "markdown" ? paragraph.source.xml : paragraph.runs.map((run) => run.text).join("");
|
|
423
|
+
if (paragraph.styleId === "MathBlock") return `$$\n${paragraph.runs.map((run) => run.text).join("")}\n$$`;
|
|
424
|
+
const headingLevel = paragraph.styleId === void 0 ? void 0 : parseHeadingStyleId(paragraph.styleId);
|
|
425
|
+
if (headingLevel !== void 0) {
|
|
426
|
+
const level = clampHeadingLevel(headingLevel);
|
|
427
|
+
if (level !== headingLevel) context.sink({
|
|
428
|
+
code: MarkdownDiagnosticCodes.HEADING_LEVEL_CLAMPED,
|
|
429
|
+
severity: "info",
|
|
430
|
+
message: `heading level ${String(headingLevel)} exceeds ATX's own six-"#" ceiling and is clamped to ${String(level)}`
|
|
431
|
+
});
|
|
432
|
+
const text = emitRuns(paragraph.runs, context, paragraph.constructs);
|
|
433
|
+
const embedsLineBreak = LINE_ENDING_PATTERN.test(text);
|
|
434
|
+
const unsafeSetextReason = unsafeSetextBreakReason(text);
|
|
435
|
+
const unsafeForSetext = unsafeSetextReason !== void 0;
|
|
436
|
+
const setextRequested = context.headingStyle === "setext" || embedsLineBreak;
|
|
437
|
+
if (setextRequested && level <= 2 && !unsafeForSetext) {
|
|
438
|
+
if (context.headingStyle !== "setext") {
|
|
439
|
+
const leadingBreakAbsorbed = firstContentLineIndex(text) > 0;
|
|
440
|
+
context.sink({
|
|
441
|
+
code: MarkdownDiagnosticCodes.HEADING_STYLE_OVERRIDDEN_FOR_LINE_BREAK,
|
|
442
|
+
severity: "info",
|
|
443
|
+
message: leadingBreakAbsorbed ? `the effective WriteMarkdownOptions.headingStyle is 'atx' (its own default, or an explicit caller choice), but this level ${String(level)} heading's own content contains a line break ATX has no way to hold — rendered as setext instead, though the heading's own leading blank line is absorbed as ordinary space ahead of it on read-back rather than reproduced inside it` : `the effective WriteMarkdownOptions.headingStyle is 'atx' (its own default, or an explicit caller choice), but this level ${String(level)} heading's own content contains a line break ATX has no way to hold — rendered as setext instead so the break survives`
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
return renderSetextHeading(level, text);
|
|
447
|
+
}
|
|
448
|
+
if (setextRequested && level <= 2 && unsafeForSetext) {
|
|
449
|
+
context.sink({
|
|
450
|
+
code: MarkdownDiagnosticCodes.HEADING_LINE_BREAK_UNSAFE_FOR_SETEXT,
|
|
451
|
+
severity: "info",
|
|
452
|
+
message: unsafeSetextDiagnosticMessage(level, unsafeSetextReason, embedsLineBreak)
|
|
453
|
+
});
|
|
454
|
+
return renderAtxHeading(level, text);
|
|
455
|
+
}
|
|
456
|
+
if (embedsLineBreak) context.sink({
|
|
457
|
+
code: MarkdownDiagnosticCodes.HEADING_LINE_BREAK_COLLAPSED,
|
|
458
|
+
severity: "info",
|
|
459
|
+
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`
|
|
460
|
+
});
|
|
461
|
+
return renderAtxHeading(level, text);
|
|
462
|
+
}
|
|
463
|
+
return emitRuns(paragraph.runs, context, paragraph.constructs);
|
|
464
|
+
}
|
|
465
|
+
function renderParagraph(paragraph, context) {
|
|
466
|
+
const body = renderParagraphBody(paragraph, context);
|
|
467
|
+
const depth = context.divisionDepth > 0 ? 0 : quoteDepthOf(paragraph);
|
|
468
|
+
if (depth === 0) return body;
|
|
469
|
+
if (!isQuotableStyle(paragraph.styleId)) {
|
|
470
|
+
context.sink({
|
|
471
|
+
code: MarkdownDiagnosticCodes.PARAGRAPH_INDENT_DROPPED,
|
|
472
|
+
severity: "info",
|
|
473
|
+
message: `paragraph carries indentLeftPt (${String(paragraph.indentLeftPt)}pt) with no styleId this package recognises as quotable; the indent has no other markdown representation and is dropped`
|
|
474
|
+
});
|
|
475
|
+
return body;
|
|
476
|
+
}
|
|
477
|
+
const prefix = "> ".repeat(depth);
|
|
478
|
+
return body.split("\n").map((line) => `${prefix}${line}`).join("\n");
|
|
479
|
+
}
|
|
480
|
+
function renderTopLevelBlock(block, context) {
|
|
481
|
+
switch (block.kind) {
|
|
482
|
+
case "paragraph": return renderParagraph(block, context);
|
|
483
|
+
case "table": return emitTable(block, context);
|
|
484
|
+
case "image": return emitImage(block, context.embedImages);
|
|
485
|
+
case "embeddedObject":
|
|
486
|
+
if (block.objectKind === "formula" && block.document.kind === "formula" && block.document.formula.presentation !== void 0) {
|
|
487
|
+
const latex = block.document.formula.presentation.latex;
|
|
488
|
+
return latex.length === 0 ? "$$\n$$" : `$$\n${latex}\n$$`;
|
|
489
|
+
}
|
|
490
|
+
return "";
|
|
491
|
+
case "pageBreak": return "";
|
|
492
|
+
}
|
|
493
|
+
return assertNeverRenderableBlock(block);
|
|
494
|
+
}
|
|
495
|
+
function emitBlocks(blocks, context) {
|
|
496
|
+
const imbalance = findConstructMarkerImbalance(blocks);
|
|
497
|
+
if (imbalance !== void 0) throw new MarkdownUnbalancedConstructMarkersError(imbalance.kind, imbalance.index);
|
|
498
|
+
validateRunConstructExtents(blocks);
|
|
499
|
+
return renderItems(groupConstructItems(blocks, 0).items, context);
|
|
500
|
+
}
|
|
501
|
+
function validateRunConstructExtents(blocks) {
|
|
502
|
+
for (const block of blocks) {
|
|
503
|
+
if (block.kind === "paragraph") {
|
|
504
|
+
const fault = findRunConstructFault(block);
|
|
505
|
+
if (fault !== void 0) throw new MarkdownInvalidRunConstructExtentError(fault.kind, fault.index);
|
|
506
|
+
}
|
|
507
|
+
if (block.kind === "table") for (const row of block.rows) for (const cell of row.cells) validateRunConstructExtents(cell.blocks);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
function emitMarkdown(document, options = {}) {
|
|
511
|
+
if (document.kind !== "wordprocessing") throw new MarkdownUnsupportedDocumentKindError(document.kind);
|
|
512
|
+
const context = {
|
|
513
|
+
sink: options.sink ?? NOOP_MARKDOWN_DIAGNOSTIC_SINK,
|
|
514
|
+
emphasisMarker: options.emphasisMarker ?? "_",
|
|
515
|
+
bulletMarker: options.bulletListMarker ?? "-",
|
|
516
|
+
orderedDelimiter: options.orderedListDelimiter ?? ".",
|
|
517
|
+
codeFenceChar: options.codeFenceChar ?? "`",
|
|
518
|
+
thematicBreakChar: options.thematicBreakChar ?? "-",
|
|
519
|
+
headingStyle: options.headingStyle ?? "atx",
|
|
520
|
+
embedImages: options.images ?? true,
|
|
521
|
+
orderedCounters: /* @__PURE__ */ new Map(),
|
|
522
|
+
resolvedListGlyphs: /* @__PURE__ */ new Map(),
|
|
523
|
+
reportedFallbackNumIds: /* @__PURE__ */ new Set(),
|
|
524
|
+
reportedAbsentNumIdFallback: false,
|
|
525
|
+
divisionDepth: 0,
|
|
526
|
+
enclosingItemId: void 0
|
|
527
|
+
};
|
|
528
|
+
const body = document.sections.map((section) => emitBlocks(section.blocks, context)).join("\n\n");
|
|
529
|
+
const frontMatter = options.frontMatter === true ? emitFrontMatter(document.metadata) : void 0;
|
|
530
|
+
const text = frontMatter === void 0 ? body : `${frontMatter}\n\n${body}`;
|
|
531
|
+
return (options.lineEnding ?? "lf") === "crlf" ? text.replaceAll("\n", "\r\n") : text;
|
|
532
|
+
}
|
|
533
|
+
function assertNeverRenderableBlock(block) {
|
|
534
|
+
throw new Error(`markdown-codec: unhandled renderable block ${JSON.stringify(block)}`);
|
|
535
|
+
}
|
|
536
|
+
//#endregion
|
|
537
|
+
export { requiresBlankLineBefore as A, listRegionItemBody as C, renderItems as D, renderFootnoteDefinition as E, stripCheckboxRun as M, toEmitItem as N, renderListItemMarker as O, listInfoFor as S, renderConstruct as T, isConstructItem as _, renderParagraphBody as a, lastStyleIdOf as b, FOOTNOTE_CONTINUATION_INDENT as c, collectListItem as d, constructCarriesListItemId as f, groupConstructItems as g, firstBlockCheckbox as h, isDataUri as i, resolveListGlyph as j, renderListRegion as k, ORDERED_GLYPH_CANDIDATES as l, emitItemCanInterrupt as m, canInterruptOpenParagraph as n, renderTopLevelBlock as o, consumeSameItemRun as p, emitMarkdown as r, BULLET_GLYPH_CANDIDATES as s, assertNeverRenderableBlock as t, UNINDENTED_PT as u, isInheritedListMembership as v, regionItemCanInterrupt as w, lastStyleIdOfRegionItem as x, isMaterialisedDivision as y };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as MarkdownInputTooLargeError, d as MarkdownUnbalancedConstructMarkersError, f as MarkdownUndecodableTextError, h as NOOP_MARKDOWN_DIAGNOSTIC_SINK, i as MarkdownDiagnosticSink, l as MarkdownParseError, m as MarkdownWriteError, n as MarkdownDiagnosticCodes, o as MarkdownInvalidRunConstructExtentError, p as MarkdownUnsupportedDocumentKindError, r as MarkdownDiagnosticSeverity, s as MarkdownNestingLimitExceededError, t as MarkdownDiagnostic, u as MarkdownTableGridFaultError } from "./diagnostics-D3UiC9HL.cjs";
|
|
2
2
|
import { MarkdownBytesSchema, markdownCodec, markdownContentCodec } from "./codec.cjs";
|
|
3
3
|
import { n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "./image-B6p0Ovgy.cjs";
|
|
4
|
-
import {
|
|
4
|
+
import { a as MarkdownLineEnding, c as ReadMarkdownOptions, i as MarkdownHeadingStyle, l as WriteMarkdownOptions, n as MarkdownCodeFenceChar, o as MarkdownOrderedListDelimiter, r as MarkdownEmphasisMarker, s as MarkdownThematicBreakChar, t as MarkdownBulletListMarker, u as WriteMarkdownStyleOptions } from "./options-ZnZOMG3X.cjs";
|
|
5
|
+
import { ListNumIdInfo, ListNumIdMintOptions, NumIdMintState, createNumIdMintState, mintListNumId, mintedListType, parseListNumId } from "./shared/list-id.cjs";
|
|
5
6
|
import { ReadMarkdownContentResult, ReadMarkdownResult, readMarkdown, readMarkdownContent } from "./read.cjs";
|
|
6
7
|
import { writeMarkdown, writeMarkdownContent } from "./write.cjs";
|
|
7
|
-
import { ListNumIdInfo, ListNumIdMintOptions, NumIdMintState, createNumIdMintState, mintListNumId, mintedListType, parseListNumId } from "./shared/list-id.cjs";
|
|
8
8
|
import { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID, headingStyleId, parseHeadingStyleId } from "./shared/style-constants.cjs";
|
|
9
9
|
export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, type ListNumIdInfo, type ListNumIdMintOptions, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, type MarkdownBulletListMarker, MarkdownBytesSchema, type MarkdownCodeFenceChar, type MarkdownDiagnostic, MarkdownDiagnosticCodes, type MarkdownDiagnosticSeverity, type MarkdownDiagnosticSink, type MarkdownEmphasisMarker, type MarkdownHeadingStyle, type MarkdownImageResolveContext, type MarkdownImageResolver, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, type MarkdownLineEnding, MarkdownNestingLimitExceededError, type MarkdownOrderedListDelimiter, MarkdownParseError, type MarkdownResolvedImageBytes, MarkdownTableGridFaultError, type MarkdownThematicBreakChar, MarkdownUnbalancedConstructMarkersError, MarkdownUndecodableTextError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK, type NumIdMintState, QUOTE_INDENT_PT, QUOTE_STYLE_ID, type ReadMarkdownContentResult, type ReadMarkdownOptions, type ReadMarkdownResult, type WriteMarkdownOptions, type WriteMarkdownStyleOptions, createNumIdMintState, headingStyleId, markdownCodec, markdownContentCodec, mintListNumId, mintedListType, parseHeadingStyleId, parseListNumId, readMarkdown, readMarkdownContent, writeMarkdown, writeMarkdownContent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as MarkdownInputTooLargeError, d as MarkdownUnbalancedConstructMarkersError, f as MarkdownUndecodableTextError, h as NOOP_MARKDOWN_DIAGNOSTIC_SINK, i as MarkdownDiagnosticSink, l as MarkdownParseError, m as MarkdownWriteError, n as MarkdownDiagnosticCodes, o as MarkdownInvalidRunConstructExtentError, p as MarkdownUnsupportedDocumentKindError, r as MarkdownDiagnosticSeverity, s as MarkdownNestingLimitExceededError, t as MarkdownDiagnostic, u as MarkdownTableGridFaultError } from "./diagnostics-D3UiC9HL.js";
|
|
2
2
|
import { MarkdownBytesSchema, markdownCodec, markdownContentCodec } from "./codec.js";
|
|
3
3
|
import { n as MarkdownImageResolver, r as MarkdownResolvedImageBytes, t as MarkdownImageResolveContext } from "./image-gR1vISI0.js";
|
|
4
|
-
import {
|
|
4
|
+
import { a as MarkdownLineEnding, c as ReadMarkdownOptions, i as MarkdownHeadingStyle, l as WriteMarkdownOptions, n as MarkdownCodeFenceChar, o as MarkdownOrderedListDelimiter, r as MarkdownEmphasisMarker, s as MarkdownThematicBreakChar, t as MarkdownBulletListMarker, u as WriteMarkdownStyleOptions } from "./options-CZoMEGL8.js";
|
|
5
|
+
import { ListNumIdInfo, ListNumIdMintOptions, NumIdMintState, createNumIdMintState, mintListNumId, mintedListType, parseListNumId } from "./shared/list-id.js";
|
|
5
6
|
import { ReadMarkdownContentResult, ReadMarkdownResult, readMarkdown, readMarkdownContent } from "./read.js";
|
|
6
7
|
import { writeMarkdown, writeMarkdownContent } from "./write.js";
|
|
7
|
-
import { ListNumIdInfo, ListNumIdMintOptions, NumIdMintState, createNumIdMintState, mintListNumId, mintedListType, parseListNumId } from "./shared/list-id.js";
|
|
8
8
|
import { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID, headingStyleId, parseHeadingStyleId } from "./shared/style-constants.js";
|
|
9
9
|
export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, type ListNumIdInfo, type ListNumIdMintOptions, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, type MarkdownBulletListMarker, MarkdownBytesSchema, type MarkdownCodeFenceChar, type MarkdownDiagnostic, MarkdownDiagnosticCodes, type MarkdownDiagnosticSeverity, type MarkdownDiagnosticSink, type MarkdownEmphasisMarker, type MarkdownHeadingStyle, type MarkdownImageResolveContext, type MarkdownImageResolver, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, type MarkdownLineEnding, MarkdownNestingLimitExceededError, type MarkdownOrderedListDelimiter, MarkdownParseError, type MarkdownResolvedImageBytes, MarkdownTableGridFaultError, type MarkdownThematicBreakChar, MarkdownUnbalancedConstructMarkersError, MarkdownUndecodableTextError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK, type NumIdMintState, QUOTE_INDENT_PT, QUOTE_STYLE_ID, type ReadMarkdownContentResult, type ReadMarkdownOptions, type ReadMarkdownResult, type WriteMarkdownOptions, type WriteMarkdownStyleOptions, createNumIdMintState, headingStyleId, markdownCodec, markdownContentCodec, mintListNumId, mintedListType, parseHeadingStyleId, parseListNumId, readMarkdown, readMarkdownContent, writeMarkdown, writeMarkdownContent };
|
package/dist/inline/entity.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_scan_entity_table = require("../scan/entity-table.cjs");
|
|
3
2
|
const require_inline_chars = require("./chars.cjs");
|
|
3
|
+
const require_scan_entity_table = require("../scan/entity-table.cjs");
|
|
4
4
|
//#region src/inline/entity.ts
|
|
5
5
|
const REPLACEMENT_CHARACTER = "�";
|
|
6
6
|
const MAX_CODEPOINT = 1114111;
|
package/dist/inline/entity.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HTML_ENTITY_TABLE } from "../scan/entity-table.js";
|
|
2
1
|
import { isAsciiPunctuation } from "./chars.js";
|
|
2
|
+
import { HTML_ENTITY_TABLE } from "../scan/entity-table.js";
|
|
3
3
|
//#region src/inline/entity.ts
|
|
4
4
|
const REPLACEMENT_CHARACTER = "�";
|
|
5
5
|
const MAX_CODEPOINT = 1114111;
|
package/dist/inline/inline.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_inline_footnote = require("./footnote.cjs");
|
|
3
2
|
const require_html_html = require("../html/html.cjs");
|
|
4
3
|
const require_inline_chars = require("./chars.cjs");
|
|
5
|
-
const require_inline_entity = require("./entity.cjs");
|
|
6
4
|
const require_inline_delimiter = require("./delimiter.cjs");
|
|
5
|
+
const require_inline_entity = require("./entity.cjs");
|
|
6
|
+
const require_inline_footnote = require("./footnote.cjs");
|
|
7
7
|
const require_inline_node = require("./node.cjs");
|
|
8
8
|
const require_inline_gfm_autolink = require("./gfm-autolink.cjs");
|
|
9
9
|
const require_inline_link = require("./link.cjs");
|
package/dist/inline/inline.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as assertNeverInlineKind, r as parseInlines, t as InlineParseOptions } from "../inline-
|
|
1
|
+
import { n as assertNeverInlineKind, r as parseInlines, t as InlineParseOptions } from "../inline-BxX0iOy6.cjs";
|
|
2
2
|
export { InlineParseOptions, assertNeverInlineKind, parseInlines };
|
package/dist/inline/inline.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as assertNeverInlineKind, r as parseInlines, t as InlineParseOptions } from "../inline-
|
|
1
|
+
import { n as assertNeverInlineKind, r as parseInlines, t as InlineParseOptions } from "../inline-BG6ge5m2.js";
|
|
2
2
|
export { InlineParseOptions, assertNeverInlineKind, parseInlines };
|
package/dist/inline/inline.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { matchFootnoteLabel } from "./footnote.js";
|
|
2
1
|
import { matchHtmlTag } from "../html/html.js";
|
|
3
2
|
import { containsAsciiControlOrSpace, isAsciiPunctuation } from "./chars.js";
|
|
4
|
-
import { matchEntity } from "./entity.js";
|
|
5
3
|
import { DelimiterStack, processEmphasis, scanDelimiterRun } from "./delimiter.js";
|
|
4
|
+
import { matchEntity } from "./entity.js";
|
|
5
|
+
import { matchFootnoteLabel } from "./footnote.js";
|
|
6
6
|
import { InlineNode, createTextNode } from "./node.js";
|
|
7
7
|
import { applyGfmAutolinks } from "./gfm-autolink.js";
|
|
8
8
|
import { matchLinkLabel, normalizeLinkLabel, parseLinkDestination, parseLinkTitle, skipInlineWhitespace } from "./link.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { y as MarkdownInlineNode } from "./ast-DI-t9uKv.js";
|
|
2
|
-
import { r as FootnoteLabelSet } from "./footnote-CKk4JbLk.js";
|
|
3
2
|
import { LinkReferenceMap } from "./inline/link.js";
|
|
3
|
+
import { r as FootnoteLabelSet } from "./footnote-CKk4JbLk.js";
|
|
4
4
|
//#region src/inline/inline.d.ts
|
|
5
5
|
interface InlineParseOptions {
|
|
6
6
|
readonly gfmAutolinks?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { y as MarkdownInlineNode } from "./ast-DI-t9uKv.cjs";
|
|
2
|
-
import { r as FootnoteLabelSet } from "./footnote-CKk4JbLk.cjs";
|
|
3
2
|
import { LinkReferenceMap } from "./inline/link.cjs";
|
|
3
|
+
import { r as FootnoteLabelSet } from "./footnote-CKk4JbLk.cjs";
|
|
4
4
|
//#region src/inline/inline.d.ts
|
|
5
5
|
interface InlineParseOptions {
|
|
6
6
|
readonly gfmAutolinks?: boolean;
|
package/dist/lower/lower.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_defaults_defaults = require("../defaults/defaults.cjs");
|
|
3
2
|
const require_diagnostics_diagnostics = require("../diagnostics/diagnostics.cjs");
|
|
4
|
-
const
|
|
3
|
+
const require_defaults_defaults = require("../defaults/defaults.cjs");
|
|
4
|
+
const require_block = require("../block-DsxTiUms.cjs");
|
|
5
5
|
const require_lower_image = require("./image.cjs");
|
|
6
6
|
const require_shared_style_constants = require("../shared/style-constants.cjs");
|
|
7
7
|
const require_html_html_table = require("../html/html-table.cjs");
|
|
@@ -369,7 +369,7 @@ function lowerMarkdownDetailed(source, options = {}) {
|
|
|
369
369
|
maxNesting: options.maxBlockNesting,
|
|
370
370
|
sink
|
|
371
371
|
};
|
|
372
|
-
const parsed =
|
|
372
|
+
const parsed = require_block.parseMarkdown(extracted.rest, parseOptions);
|
|
373
373
|
return {
|
|
374
374
|
document: lowerParsedMarkdown(parsed, options, extracted.metadata),
|
|
375
375
|
references: parsed.references,
|