markdown-codec 1.4.1 → 2.0.0
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/README.md +1 -1
- package/dist/codec.d.cts +9 -0
- package/dist/codec.d.ts +9 -0
- package/dist/emit/emit.cjs +7 -9
- package/dist/emit/emit.js +7 -9
- package/dist/lower/lower.cjs +2 -1
- package/dist/lower/lower.js +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -168,7 +168,7 @@ Every construct `src/lower`/`src/emit` cannot represent losslessly is a document
|
|
|
168
168
|
- **`md/image-unresolved`** — no resolver, `undefined` return, or non-PNG/JPEG bytes degrades to alt-text run.
|
|
169
169
|
- **`md/raw-html-preserved-as-text` / `md/raw-html-dropped`** — raw HTML kept as literal text (default) or dropped; never interpreted.
|
|
170
170
|
- **`md/front-matter-key-unmapped`** — no YAML/TOML engine; only five known `LayoutMetadata` keys recognised.
|
|
171
|
-
- **`md/heading-level-clamped`** — styleId beyond `Heading6` (from another format) clamps to level 6.
|
|
171
|
+
- **`md/heading-level-clamped`** — styleId beyond `Heading6` (from another format) clamps to level 6 via document-schema.js's shared `clampHeadingLevel()`.
|
|
172
172
|
- **`md/adjacent-links-merged`** / **`md/code-span-as-monospace-run`** — same-destination adjacent links merge; monospace runs emit as code spans.
|
|
173
173
|
- **`md/paragraph-indent-dropped`** — `indentLeftPt` without a recognised styleId; indent dropped, paragraph renders.
|
|
174
174
|
- **`md/list-numid-fallback`** — a foreign `numId` falls back to a plain bullet list.
|
package/dist/codec.d.cts
CHANGED
|
@@ -226,6 +226,15 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
|
|
|
226
226
|
bottom: "bottom";
|
|
227
227
|
middle: "middle";
|
|
228
228
|
}>>;
|
|
229
|
+
comment: z.ZodOptional<z.ZodObject<{
|
|
230
|
+
text: z.ZodString;
|
|
231
|
+
author: z.ZodOptional<z.ZodString>;
|
|
232
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
233
|
+
replies: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
234
|
+
text: z.ZodString;
|
|
235
|
+
author: z.ZodOptional<z.ZodString>;
|
|
236
|
+
}, z.core.$strip>>>;
|
|
237
|
+
}, z.core.$strip>>;
|
|
229
238
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
230
239
|
frames: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
231
240
|
pageIndex: z.ZodNumber;
|
package/dist/codec.d.ts
CHANGED
|
@@ -226,6 +226,15 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
|
|
|
226
226
|
bottom: "bottom";
|
|
227
227
|
middle: "middle";
|
|
228
228
|
}>>;
|
|
229
|
+
comment: z.ZodOptional<z.ZodObject<{
|
|
230
|
+
text: z.ZodString;
|
|
231
|
+
author: z.ZodOptional<z.ZodString>;
|
|
232
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
233
|
+
replies: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
234
|
+
text: z.ZodString;
|
|
235
|
+
author: z.ZodOptional<z.ZodString>;
|
|
236
|
+
}, z.core.$strip>>>;
|
|
237
|
+
}, z.core.$strip>>;
|
|
229
238
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
230
239
|
frames: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
231
240
|
pageIndex: z.ZodNumber;
|
package/dist/emit/emit.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const require_emit_front_matter = require("./front-matter.cjs");
|
|
|
7
7
|
const require_emit_inline = require("./inline.cjs");
|
|
8
8
|
const require_emit_image = require("./image.cjs");
|
|
9
9
|
const require_emit_table = require("./table.cjs");
|
|
10
|
+
let document_schema_js = require("document-schema.js");
|
|
10
11
|
//#region src/emit/emit.ts
|
|
11
12
|
const MAX_SETEXT_LEVEL = 2;
|
|
12
13
|
const SETEXT_LEVEL_1_CHAR = "=";
|
|
@@ -56,15 +57,12 @@ function renderParagraphBody(paragraph, context) {
|
|
|
56
57
|
if (paragraph.styleId === "MathBlock") return `$$\n${paragraph.runs.map((run) => run.text).join("")}\n$$`;
|
|
57
58
|
const headingLevel = paragraph.styleId === void 0 ? void 0 : require_shared_style_constants.parseHeadingStyleId(paragraph.styleId);
|
|
58
59
|
if (headingLevel !== void 0) {
|
|
59
|
-
|
|
60
|
-
if (level
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
level = 6;
|
|
67
|
-
}
|
|
60
|
+
const level = (0, document_schema_js.clampHeadingLevel)(headingLevel);
|
|
61
|
+
if (level !== headingLevel) context.sink({
|
|
62
|
+
code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.HEADING_LEVEL_CLAMPED,
|
|
63
|
+
severity: "info",
|
|
64
|
+
message: `heading level ${String(headingLevel)} exceeds ATX's own six-"#" ceiling and is clamped to ${String(level)}`
|
|
65
|
+
});
|
|
68
66
|
const text = require_emit_inline.emitRuns(paragraph.runs, context);
|
|
69
67
|
if (context.headingStyle === "setext" && level <= MAX_SETEXT_LEVEL) return renderSetextHeading(level, text);
|
|
70
68
|
return `${"#".repeat(level)} ${text}`;
|
package/dist/emit/emit.js
CHANGED
|
@@ -6,6 +6,7 @@ import { emitFrontMatter } from "./front-matter.js";
|
|
|
6
6
|
import { emitRuns } from "./inline.js";
|
|
7
7
|
import { emitImage } from "./image.js";
|
|
8
8
|
import { emitTable } from "./table.js";
|
|
9
|
+
import { clampHeadingLevel } from "document-schema.js";
|
|
9
10
|
//#region src/emit/emit.ts
|
|
10
11
|
const MAX_SETEXT_LEVEL = 2;
|
|
11
12
|
const SETEXT_LEVEL_1_CHAR = "=";
|
|
@@ -55,15 +56,12 @@ function renderParagraphBody(paragraph, context) {
|
|
|
55
56
|
if (paragraph.styleId === "MathBlock") return `$$\n${paragraph.runs.map((run) => run.text).join("")}\n$$`;
|
|
56
57
|
const headingLevel = paragraph.styleId === void 0 ? void 0 : parseHeadingStyleId(paragraph.styleId);
|
|
57
58
|
if (headingLevel !== void 0) {
|
|
58
|
-
|
|
59
|
-
if (level
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
level = 6;
|
|
66
|
-
}
|
|
59
|
+
const level = clampHeadingLevel(headingLevel);
|
|
60
|
+
if (level !== headingLevel) context.sink({
|
|
61
|
+
code: MarkdownDiagnosticCodes.HEADING_LEVEL_CLAMPED,
|
|
62
|
+
severity: "info",
|
|
63
|
+
message: `heading level ${String(headingLevel)} exceeds ATX's own six-"#" ceiling and is clamped to ${String(level)}`
|
|
64
|
+
});
|
|
67
65
|
const text = emitRuns(paragraph.runs, context);
|
|
68
66
|
if (context.headingStyle === "setext" && level <= MAX_SETEXT_LEVEL) return renderSetextHeading(level, text);
|
|
69
67
|
return `${"#".repeat(level)} ${text}`;
|
package/dist/lower/lower.cjs
CHANGED
|
@@ -36,7 +36,8 @@ function lowerHeading(node, context) {
|
|
|
36
36
|
return [decorateParagraph({
|
|
37
37
|
kind: "paragraph",
|
|
38
38
|
runs: require_lower_inline.lowerInlineNodes(node.children, inlineContext(context)),
|
|
39
|
-
styleId: require_shared_style_constants.headingStyleId(node.level)
|
|
39
|
+
styleId: require_shared_style_constants.headingStyleId(node.level),
|
|
40
|
+
headingLevel: node.level
|
|
40
41
|
}, context)];
|
|
41
42
|
}
|
|
42
43
|
function lowerParagraph(node, context) {
|
package/dist/lower/lower.js
CHANGED
|
@@ -35,7 +35,8 @@ function lowerHeading(node, context) {
|
|
|
35
35
|
return [decorateParagraph({
|
|
36
36
|
kind: "paragraph",
|
|
37
37
|
runs: lowerInlineNodes(node.children, inlineContext(context)),
|
|
38
|
-
styleId: headingStyleId(node.level)
|
|
38
|
+
styleId: headingStyleId(node.level),
|
|
39
|
+
headingLevel: node.level
|
|
39
40
|
}, context)];
|
|
40
41
|
}
|
|
41
42
|
function lowerParagraph(node, context) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdown-codec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Hand-written CommonMark+GFM <-> ContentDocument codec, built on document-schema.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"license": "MIT",
|
|
80
80
|
"packageManager": "pnpm@11.6.0",
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"document-schema.js": "^3.
|
|
82
|
+
"document-schema.js": "^3.1.0",
|
|
83
83
|
"zod": "^4.4.3"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|