mrkdwn.js 4.0.5 → 6.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +85 -66
  2. package/dist/ast/ast.d.cts +1 -1
  3. package/dist/ast/ast.d.ts +1 -1
  4. package/dist/{ast-8XCbjRQT.d.cts → ast-CNfTgS0N.d.cts} +35 -35
  5. package/dist/{ast-8XCbjRQT.d.ts → ast-CNfTgS0N.d.ts} +35 -35
  6. package/dist/block/block.cjs +12 -4
  7. package/dist/block/block.d.cts +9 -5
  8. package/dist/block/block.d.ts +9 -5
  9. package/dist/block/block.js +8 -4
  10. package/dist/block/definitions.d.cts +2 -2
  11. package/dist/block/definitions.d.ts +2 -2
  12. package/dist/block/node.d.cts +4 -4
  13. package/dist/block/node.d.ts +4 -4
  14. package/dist/block/table.d.cts +1 -1
  15. package/dist/block/table.d.ts +1 -1
  16. package/dist/codec.cjs +1 -1
  17. package/dist/codec.d.cts +1625 -23
  18. package/dist/codec.d.ts +1625 -23
  19. package/dist/codec.js +2 -2
  20. package/dist/defaults/defaults.d.cts +1 -1
  21. package/dist/defaults/defaults.d.ts +1 -1
  22. package/dist/diagnostics/diagnostics.cjs +17 -7
  23. package/dist/diagnostics/diagnostics.d.cts +2 -2
  24. package/dist/diagnostics/diagnostics.d.ts +2 -2
  25. package/dist/diagnostics/diagnostics.js +17 -8
  26. package/dist/{diagnostics-BWK1iGy7.d.cts → diagnostics-CjfBoW4K.d.cts} +14 -10
  27. package/dist/{diagnostics-BWK1iGy7.d.ts → diagnostics-CjfBoW4K.d.ts} +14 -10
  28. package/dist/emit/emit.cjs +378 -42
  29. package/dist/emit/emit.js +381 -45
  30. package/dist/emit/front-matter.cjs +22 -5
  31. package/dist/emit/front-matter.js +22 -5
  32. package/dist/emit/html-table.cjs +104 -0
  33. package/dist/emit/html-table.d.cts +7 -0
  34. package/dist/emit/html-table.d.ts +7 -0
  35. package/dist/emit/html-table.js +102 -0
  36. package/dist/emit/inline.cjs +69 -26
  37. package/dist/emit/inline.d.cts +2 -12
  38. package/dist/emit/inline.d.ts +2 -12
  39. package/dist/emit/inline.js +68 -27
  40. package/dist/emit/table.cjs +18 -11
  41. package/dist/emit/table.d.cts +3 -2
  42. package/dist/emit/table.d.ts +3 -2
  43. package/dist/emit/table.js +18 -11
  44. package/dist/html/html-table.cjs +243 -0
  45. package/dist/html/html-table.d.cts +5 -0
  46. package/dist/html/html-table.d.ts +5 -0
  47. package/dist/html/html-table.js +242 -0
  48. package/dist/html/render.d.cts +1 -1
  49. package/dist/html/render.d.ts +1 -1
  50. package/dist/image/image.cjs +4 -4
  51. package/dist/image/image.d.cts +1 -1
  52. package/dist/image/image.d.ts +1 -1
  53. package/dist/image/image.js +4 -4
  54. package/dist/{image-C4KYmz_L.d.cts → image-B5L0HpAJ.d.cts} +1 -1
  55. package/dist/{image-DescdRgq.d.cts → image-BtmTG4_a.d.cts} +1 -1
  56. package/dist/{image-DescdRgq.d.ts → image-BtmTG4_a.d.ts} +1 -1
  57. package/dist/{image-Cm3hT5PS.d.ts → image-C390OIB3.d.ts} +1 -1
  58. package/dist/index.cjs +2 -2
  59. package/dist/index.d.cts +4 -4
  60. package/dist/index.d.ts +4 -4
  61. package/dist/index.js +3 -3
  62. package/dist/inline/delimiter.d.cts +2 -2
  63. package/dist/inline/delimiter.d.ts +2 -2
  64. package/dist/inline/inline.d.cts +1 -1
  65. package/dist/inline/inline.d.ts +1 -1
  66. package/dist/inline/link.d.cts +17 -1
  67. package/dist/inline/link.d.ts +17 -1
  68. package/dist/inline/node.d.cts +2 -2
  69. package/dist/inline/node.d.ts +2 -2
  70. package/dist/{inline-CXVQWQnW.d.cts → inline-CnO86zMw.d.cts} +2 -2
  71. package/dist/inline-DCIKQ83j.d.cts +14 -0
  72. package/dist/{inline-B_V7bs5j.d.ts → inline-DItZ-VVw.d.ts} +2 -2
  73. package/dist/inline-INoDAG37.d.ts +14 -0
  74. package/dist/lower/front-matter.cjs +73 -26
  75. package/dist/lower/front-matter.d.cts +2 -1
  76. package/dist/lower/front-matter.d.ts +2 -1
  77. package/dist/lower/front-matter.js +72 -25
  78. package/dist/lower/image.d.cts +1 -1
  79. package/dist/lower/image.d.ts +1 -1
  80. package/dist/lower/inline.cjs +87 -33
  81. package/dist/lower/inline.d.cts +9 -12
  82. package/dist/lower/inline.d.ts +9 -12
  83. package/dist/lower/inline.js +89 -34
  84. package/dist/lower/lower.cjs +143 -113
  85. package/dist/lower/lower.d.cts +8 -1
  86. package/dist/lower/lower.d.ts +8 -1
  87. package/dist/lower/lower.js +144 -115
  88. package/dist/lower/table.cjs +3 -2
  89. package/dist/lower/table.d.cts +1 -1
  90. package/dist/lower/table.d.ts +1 -1
  91. package/dist/lower/table.js +3 -2
  92. package/dist/options/options.d.cts +10 -10
  93. package/dist/options/options.d.ts +10 -10
  94. package/dist/read.cjs +45 -9
  95. package/dist/read.d.cts +3 -3
  96. package/dist/read.d.ts +3 -3
  97. package/dist/read.js +47 -11
  98. package/dist/scan/entity-table.cjs +2125 -2125
  99. package/dist/scan/entity-table.js +2125 -2125
  100. package/dist/shared/line-ending.cjs +7 -0
  101. package/dist/shared/line-ending.d.cts +5 -0
  102. package/dist/shared/line-ending.d.ts +5 -0
  103. package/dist/shared/line-ending.js +5 -0
  104. package/dist/shared/list-id.cjs +11 -3
  105. package/dist/shared/list-id.d.cts +7 -4
  106. package/dist/shared/list-id.d.ts +7 -4
  107. package/dist/shared/list-id.js +11 -4
  108. package/dist/shared/style-constants.cjs +0 -2
  109. package/dist/shared/style-constants.d.cts +1 -2
  110. package/dist/shared/style-constants.d.ts +1 -2
  111. package/dist/shared/style-constants.js +1 -2
  112. package/dist/write.cjs +33 -6
  113. package/dist/write.d.cts +2 -2
  114. package/dist/write.d.ts +2 -2
  115. package/dist/write.js +34 -7
  116. package/package.json +29 -30
  117. package/dist/link-Dv4kxVjk.d.cts +0 -18
  118. package/dist/link-Dv4kxVjk.d.ts +0 -18
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # markdown-codec
2
2
 
3
- [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=white)](https://github.com/ExaDev/markdown-codec) [![npm](https://img.shields.io/badge/npm-CB3837?logo=npm&logoColor=white)](https://www.npmjs.com/package/markdown-codec) [![Release](https://img.shields.io/github/v/release/ExaDev/markdown-codec)](https://github.com/ExaDev/markdown-codec/releases/latest) [![CI](https://img.shields.io/github/actions/workflow/status/ExaDev/markdown-codec/ci.yml?branch=main)](https://github.com/ExaDev/markdown-codec/actions)
3
+ [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=white)](https://github.com/ExaDev/documents.js/tree/main/packages/markdown-codec) [![npm](https://img.shields.io/badge/npm-CB3837?logo=npm&logoColor=white)](https://www.npmjs.com/package/markdown-codec) [![npm version](https://img.shields.io/npm/v/markdown-codec)](https://www.npmjs.com/package/markdown-codec) [![CI](https://img.shields.io/github/actions/workflow/status/ExaDev/documents.js/ci.yml?branch=main)](https://github.com/ExaDev/documents.js/actions)
4
4
 
5
- > Hand-written CommonMark+GFM ⇄ `DocumentPackage` codec, built on [document-schema.js](https://github.com/ExaDev/document-schema.js).
5
+ > Hand-written CommonMark+GFM ⇄ `DocumentTree` codec, built on [document-schema.js](../document-schema.js/README.md).
6
6
 
7
- The same "hand-write the format instead of wrapping a third-party library" bet as [`pdf-codec`](https://github.com/ExaDev/pdf-codec), aimed at CommonMark and GFM. No `micromark`/`remark`/`marked`/`markdown-it`/`commonmark`/`mdast`/`unified`/`turndown`/`showdown` dependency (enforced by eslint `no-restricted-imports`). Runtime dependencies: `document-schema.js` (the shared pivot) and `zod`. `readMarkdown`/`writeMarkdown` read and write that pivot's tree-form `DocumentPackage`; `readMarkdownContent`/`writeMarkdownContent` read and write the flat `ContentDocument` underneath it — the same model [`documents.js`](https://github.com/ExaDev/documents.js) builds docx/pptx/odt/odp conversions around. See [Two encodings](#two-encodings-documentpackage-and-contentdocument).
7
+ The same "hand-write the format instead of wrapping a third-party library" bet as [`pdf-codec`](../pdf-codec/README.md), aimed at CommonMark and GFM. No `micromark`/`remark`/`marked`/`markdown-it`/`commonmark`/`mdast`/`unified`/`turndown`/`showdown` dependency (enforced by eslint `no-restricted-imports`). Runtime dependencies: `document-schema.js` (the shared pivot) and `zod`. `readMarkdown`/`writeMarkdown` read and write that pivot's tree-form `DocumentTree`; `readMarkdownContent`/`writeMarkdownContent` read and write the flat `ContentDocument` underneath it — the same model [`documents.js`](https://github.com/ExaDev/documents.js) builds docx/pptx/odt/odp conversions around. See [Two encodings](#two-encodings-documenttree-and-contentdocument).
8
8
 
9
9
  ```mermaid
10
10
  graph TD
@@ -36,15 +36,15 @@ graph TD
36
36
  odf --> cli
37
37
  pdfcodec --> cli
38
38
 
39
- click schema "https://github.com/ExaDev/document-schema.js" "document-schema.js"
40
- click ooxml "https://github.com/ExaDev/ooxml.js" "ooxml.js"
41
- click odf "https://github.com/ExaDev/odf.js" "odf.js"
42
- click pdfcodec "https://github.com/ExaDev/pdf-codec" "pdf-codec"
43
- click bytecodec "https://github.com/ExaDev/byte-codec" "byte-codec"
44
- click mdcodec "https://github.com/ExaDev/markdown-codec" "markdown-codec"
39
+ click schema "https://github.com/ExaDev/documents.js/tree/main/packages/document-schema.js" "document-schema.js"
40
+ click ooxml "https://github.com/ExaDev/documents.js/tree/main/packages/ooxml.js" "ooxml.js"
41
+ click odf "https://github.com/ExaDev/documents.js/tree/main/packages/odf.js" "odf.js"
42
+ click pdfcodec "https://github.com/ExaDev/documents.js/tree/main/packages/pdf-codec" "pdf-codec"
43
+ click bytecodec "https://github.com/ExaDev/documents.js/tree/main/packages/byte-codec" "byte-codec"
44
+ click mdcodec "https://github.com/ExaDev/documents.js/tree/main/packages/markdown-codec" "markdown-codec"
45
45
  click documents "https://github.com/ExaDev/documents.js" "documents.js"
46
- click mcp "https://github.com/ExaDev/document-mcp" "document-mcp"
47
- click cli "https://github.com/ExaDev/document-cli" "document-cli"
46
+ click mcp "https://github.com/ExaDev/documents.js/tree/main/packages/document-mcp" "document-mcp"
47
+ click cli "https://github.com/ExaDev/documents.js/tree/main/packages/document-cli" "document-cli"
48
48
 
49
49
  style mdcodec fill:#f9a825,stroke:#333,stroke-width:3px
50
50
  ```
@@ -69,37 +69,40 @@ pnpm add markdown-codec
69
69
  npm install markdown-codec
70
70
  ```
71
71
 
72
- Published to [npmjs.org](https://www.npmjs.com/package/markdown-codec) via OIDC trusted publishing. `dist/` is committed rather than gitignored — a holdover from a pre-publish period when a git-tarball install needed a working build; now a known cleanup.
72
+ Published to [npmjs.org](https://www.npmjs.com/package/markdown-codec) via OIDC trusted publishing. `dist/` is gitignored like every other package's build output: the published tarball carries the release build, and a workspace consumer gets `dist/` from turbo's `^_build` ordering, never from the repository.
73
73
 
74
74
  ## Usage
75
75
 
76
76
  Reading and writing markdown text:
77
77
 
78
78
  ```ts
79
- import { readMarkdown, writeMarkdown } from 'markdown-codec';
79
+ import { readMarkdown, writeMarkdown } from "markdown-codec";
80
80
 
81
- const { documentPackage, diagnostics } = readMarkdown('# Title\n\nSome **bold** text with a [link](https://example.com).', {
82
- frontMatter: true, // parse a leading YAML front matter block into the package's metadata
83
- footnotes: true, // recognise [^label] markers and [^label]: definitions (default; see Footnotes)
84
- images: (destination) => undefined, // a synchronous MarkdownImageResolver port for non-data: URI images
85
- });
81
+ const { documentPackage, diagnostics } = readMarkdown(
82
+ "# Title\n\nSome **bold** text with a [link](https://example.com).",
83
+ {
84
+ frontMatter: true, // parse a leading YAML front matter block into the package's metadata
85
+ footnotes: true, // recognise [^label] markers and [^label]: definitions (default; see Footnotes)
86
+ images: (destination) => undefined, // a synchronous MarkdownImageResolver port for non-data: URI images
87
+ },
88
+ );
86
89
 
87
90
  const markdown = writeMarkdown(documentPackage, {
88
- bulletListMarker: '-',
89
- emphasisMarker: '_',
91
+ bulletListMarker: "-",
92
+ emphasisMarker: "_",
90
93
  frontMatter: true, // emit the package's metadata back out as a leading front matter block
91
94
  });
92
95
  ```
93
96
 
94
- `documentPackage` is a `DocumentPackage` — document-schema.js's tree form, with a minted styles table (see [Two encodings](#two-encodings-documentpackage-and-contentdocument)). The field is named `documentPackage` rather than `package` because `package` is a reserved word in strict mode, so `const { package } = readMarkdown(src)` would not parse.
97
+ `documentPackage` is a `DocumentTree` — document-schema.js's tree form, with a minted styles table (see [Two encodings](#two-encodings-documenttree-and-contentdocument)). The field is named `documentPackage` rather than `package` because `package` is a reserved word in strict mode, so `const { package } = readMarkdown(src)` would not parse.
95
98
 
96
- Both accept an optional `signal` (`AbortSignal`) and `sink` (`MarkdownDiagnosticSink`, called once per recoverable issue or construct-mapping gap — see [Gotchas](#gotchas-and-quirks)). `writeMarkdown` throws `MarkdownUnsupportedDocumentKindError` for a package whose `kind` is not `'wordprocessing'`, checked before flattening so every non-`'wordprocessing'` package reaches it the same way regardless of what else about that package would have failed document-schema.js's own `flattenPackage`. A `'wordprocessing'` package can still fail to flatten — a group carrying a style reference the package's own `styles` table has no entry for — and that failure surfaces as `MarkdownPackageFlattenError`, not a bare `Error` from the dependency. A `DocumentPackage`'s own `definitions`/`layers`/`attachments`/`destinations`/`pages` tables have no flat-`ContentDocument` home to land in; `writeMarkdown` reports one `PACKAGE_TABLE_DROPPED` diagnostic per non-empty table it finds rather than dropping them without a trace.
99
+ Both accept an optional `signal` (`AbortSignal`) and `sink` (`MarkdownDiagnosticSink`, called once per recoverable issue or construct-mapping gap — see [Gotchas](#gotchas-and-quirks)). `writeMarkdown` throws `MarkdownUnsupportedDocumentKindError` for a package whose `kind` is not `'wordprocessing'`, checked before flattening so every non-`'wordprocessing'` package reaches it the same way regardless of what else about that package would have failed document-schema.js's own `flattenTree`. A `'wordprocessing'` package can still fail to flatten — a group carrying a style reference the package's own `styles` table has no entry for — and that failure surfaces as `MarkdownPackageFlattenError`, not a bare `Error` from the dependency. A `DocumentTree`'s own `layers`/`attachments`/`destinations`/`pages` tables have no flat-`ContentDocument` home to land in; `writeMarkdown` reports one `PACKAGE_TABLE_DROPPED` diagnostic per non-empty table it finds rather than dropping them without a trace. The `definitions` table is the one exemption: this package's own link-tenant entries (what `readMarkdown` splices there from the source's reference definitions) render back out as `[label]: destination "title"` lines, so only a table holding foreign tenants reports.
97
100
 
98
101
  The same round trip as a schema-validated [`z.codec()`](https://zod.dev) pair, mirroring `pdf-codec`'s `pdfCodec`:
99
102
 
100
103
  ```ts
101
- import { z } from 'zod';
102
- import { markdownCodec, MarkdownBytesSchema } from 'markdown-codec';
104
+ import { z } from "zod";
105
+ import { markdownCodec, MarkdownBytesSchema } from "markdown-codec";
103
106
 
104
107
  const documentPackage = z.decode(markdownCodec, bytes); // throws if bytes are not well-formed UTF-8
105
108
  const bytes2 = z.encode(markdownCodec, documentPackage);
@@ -107,23 +110,23 @@ const bytes2 = z.encode(markdownCodec, documentPackage);
107
110
 
108
111
  `MarkdownBytesSchema` checks for well-formed UTF-8. The no-options form only; `readMarkdown`/`writeMarkdown` remain the entry points for an `AbortSignal` or diagnostic sink. Every construct-mapping gap reports through the sink as a stable code (e.g. `md/nested-emphasis-flattened`) — see `MarkdownDiagnosticCodes` and [Gotchas](#gotchas-and-quirks).
109
112
 
110
- ## Two encodings: `DocumentPackage` and `ContentDocument`
113
+ ## Two encodings: `DocumentTree` and `ContentDocument`
111
114
 
112
- document-schema.js states one document in two shapes, and owns the transform between them: the flat `ContentDocument` every codec's lowering pipeline actually builds, and the tree-form `DocumentPackage` a serialised artefact carries — sections, headings, lists, and construct boundaries as real nested groups, plus a styles table minted over repeated property tuples. `assemblePackage` goes flat → tree (`decompose` then `factorStyles`), `flattenPackage` goes tree → flat. Only one direction is a genuine round trip: `flattenPackage(assemblePackage(document))` reproduces `document` exactly, for any `ContentDocument` this package's own read side produces (checked against the full CommonMark and GFM conformance corpora, not just a hand-picked fixture — see `src/conformance.test.ts`/`src/gfm-conformance.test.ts`'s own "tree pair matches the flat pair" suite). `assemblePackage(flattenPackage(documentPackage))` does not, in general, reproduce `documentPackage` — a package carrying `definitions`/`layers`/`attachments`/`destinations`/`pages` loses all of them on the way through `flattenPackage`, which carries forward only `metadata` and `symbolTable` (see [Gotchas](#gotchas-and-quirks)).
115
+ document-schema.js states one document in two shapes, and owns the transform between them: the flat `ContentDocument` every codec's lowering pipeline actually builds, and the tree-form `DocumentTree` a serialised artefact carries — sections, headings, lists, and construct boundaries as real nested groups, plus a styles table minted over repeated property tuples. `assembleTree` goes flat → tree (`decompose` then `factorStyles`), `flattenTree` goes tree → flat. Only one direction is a genuine round trip: `flattenTree(assembleTree(document))` reproduces `document` exactly, for any `ContentDocument` this package's own read side produces (checked against the full CommonMark and GFM conformance corpora, not just a hand-picked fixture — see `src/conformance.test.ts`/`src/gfm-conformance.test.ts`'s own "tree pair matches the flat pair" suite). `assembleTree(flattenTree(documentPackage))` does not, in general, reproduce `documentPackage` — a package carrying `definitions`/`layers`/`attachments`/`destinations`/`pages` loses all of them on the way through `flattenTree`, which carries forward only `metadata` and `symbolTable` (see [Gotchas](#gotchas-and-quirks)).
113
116
 
114
- This package exposes a read/write pair and a codec at each level. The unsuffixed names are the tree-form ones and are what to reach for by default — a codec is a construction site, so the tree is what a caller gets unless they ask for otherwise. The `Content`-suffixed names are the flat pair one level down, mirroring the `readXlsx`/`readXlsxContent` naming already in [`ooxml.js`](https://github.com/ExaDev/ooxml.js):
117
+ This package exposes a read/write pair and a codec at each level. The unsuffixed names are the tree-form ones and are what to reach for by default — a codec is a construction site, so the tree is what a caller gets unless they ask for otherwise. The `Content`-suffixed names are the flat pair one level down, mirroring the `readXlsx`/`readXlsxContent` naming already in [`ooxml.js`](../ooxml.js/README.md):
115
118
 
116
- | Level | Read | Write | Codec | Value type |
117
- | --- | --- | --- | --- | --- |
118
- | Tree (default) | `readMarkdown` | `writeMarkdown` | `markdownCodec` | `DocumentPackage` |
119
- | Flat | `readMarkdownContent` | `writeMarkdownContent` | `markdownContentCodec` | `ContentDocument` |
119
+ | Level | Read | Write | Codec | Value type |
120
+ | -------------- | --------------------- | ---------------------- | ---------------------- | ----------------- |
121
+ | Tree (default) | `readMarkdown` | `writeMarkdown` | `markdownCodec` | `DocumentTree` |
122
+ | Flat | `readMarkdownContent` | `writeMarkdownContent` | `markdownContentCodec` | `ContentDocument` |
120
123
 
121
- The tree pair is exactly the flat pair with the transform composed on — `readMarkdown` is `assemblePackage` over `readMarkdownContent`, `writeMarkdown` is `flattenPackage` before `writeMarkdownContent` — so both render identical markdown from the same source, pinned in `src/package.test.ts`. Options, diagnostics, and error behaviour are identical at both levels.
124
+ The tree pair is the flat pair with the transform composed on — `readMarkdown` is `assembleTree` over `readMarkdownContent`, `writeMarkdown` is `flattenTree` before `writeMarkdownContent` — plus the two tree-only carries the flat form has no root for: the source's reference definitions splice into `documentPackage.definitions` (link tenant, keyed by normalised label) and the verbatim front-matter block into `documentPackage.source.frontmatter`, both rendered back out by `writeMarkdown` (`[label]: dest "title"` lines after the body; the original front matter verbatim in place of the regenerated block). Sources carrying neither render identically to the flat pair, pinned in `src/package.test.ts`; a source carrying either renders its extra block, which is the point of reaching for the tree. Options, diagnostics, and error behaviour are identical at both levels.
122
125
 
123
- Reach for the flat pair when composing a package boundary by hand (`decompose`/`flattenPackage` directly, or `factorStyles` with your own minting policy), when feeding a `ContentDocument`-consuming builder such as `documents.js`'s conversion pipeline, or when a layout stage needs to stamp frames onto content before it is decomposed. Everything else wants the tree.
126
+ Reach for the flat pair when composing a package boundary by hand (`decompose`/`flattenTree` directly, or `factorStyles` with your own minting policy), when feeding a `ContentDocument`-consuming builder such as `documents.js`'s conversion pipeline, or when a layout stage needs to stamp frames onto content before it is decomposed. Everything else wants the tree.
124
127
 
125
128
  ```ts
126
- import { readMarkdownContent, writeMarkdownContent } from 'markdown-codec';
129
+ import { readMarkdownContent, writeMarkdownContent } from "markdown-codec";
127
130
 
128
131
  const { document } = readMarkdownContent(source); // a ContentDocument: kind, metadata, sections
129
132
  const markdown = writeMarkdownContent(document);
@@ -139,12 +142,12 @@ Modelled on `pdf-codec`'s own layering, aimed at CommonMark+GFM instead of PDF:
139
142
  - **`src/scan/`** — CommonMark line/character scanner, plus `entity-table.ts` (generated from `assets/html-entities/entities.json`).
140
143
  - **`src/block/`** — CommonMark block-structure algorithm (open-block stack, continuation matching): paragraphs, headings, code blocks, block quotes, lists (incl. GFM task-list-item), thematic breaks, link references, footnote definitions, GFM tables.
141
144
  - **`src/inline/`** — emphasis, code spans, links, autolinks, raw HTML, GFM strikethrough, footnote references, line breaks. `link.ts` and `footnote.ts` hold the label grammars the block phase shares.
142
- - **`src/html/`** — raw HTML recognition (bounded rules, not a general parser) plus `render.ts` (conformance oracle; internal only).
145
+ - **`src/html/`** — raw HTML recognition (bounded rules, not a general parser) plus `render.ts` (conformance oracle; internal only). `html-table.ts` is the one exception to "never parsed as markup": a block-level HTML that is, in full, one well-formed `<table>` recognises straight to a real `ContentTable` instead of opaque text — see [HTML-table fallback](#html-table-fallback).
143
146
  - **`src/image/`** — PNG/JPEG dimension reader and base64 codec, shared by `src/lower/` and `src/emit/`.
144
147
  - **`src/shared/`** — string-shape conventions `src/lower`/`src/emit` agree on (`style-constants.ts`, `list-id.ts`'s opaque `numId`). Re-exported so `documents.js`'s `MarkdownEditor` reuses the identical grammar.
145
148
  - **`src/lower/`** — AST → `ContentDocument` lowering (thin adapter, not a second parser); top-of-file table maps each construct to its diagnostic gap.
146
- - **`src/emit/`** — `ContentDocument` → markdown text emission, the structural inverse of `src/lower`.
147
- - **`src/read.ts`** / **`src/write.ts`** / **`src/codec.ts`** — the public entry points at both levels: `readMarkdown`/`writeMarkdown`/`markdownCodec` over `DocumentPackage`, and `readMarkdownContent`/`writeMarkdownContent`/`markdownContentCodec` over `ContentDocument`. The tree-form functions are thin compositions of `document-schema.js`'s `assemblePackage`/`flattenPackage` onto the flat ones; no conversion logic of their own lives here.
149
+ - **`src/emit/`** — `ContentDocument` → markdown text emission, the structural inverse of `src/lower`. `html-table.ts` is `src/html/html-table.ts`'s own write-side counterpart.
150
+ - **`src/read.ts`** / **`src/write.ts`** / **`src/codec.ts`** — the public entry points at both levels: `readMarkdown`/`writeMarkdown`/`markdownCodec` over `DocumentTree`, and `readMarkdownContent`/`writeMarkdownContent`/`markdownContentCodec` over `ContentDocument`. The tree-form functions are thin compositions of `document-schema.js`'s `assembleTree`/`flattenTree` onto the flat ones; no conversion logic of their own lives here.
148
151
 
149
152
  ## Vendored assets
150
153
 
@@ -185,70 +188,84 @@ Every construct `src/lower`/`src/emit` cannot represent losslessly is a document
185
188
 
186
189
  - **`md/invented-page-geometry`** — no page concept in markdown; one `ContentSection` with A4 + 1in defaults (overridable). Fires once.
187
190
  - **`md/nested-emphasis-flattened`** — same-kind nested emphasis flattens to one run.
188
- - **`md/link-title-dropped`** — link/image title has no `ContentRun`/`ContentImageBlock` field.
189
- - **`md/code-block-info-string-dropped`** — fenced code info string has no `ContentParagraph` field.
190
- - **`md/blockquote-nested-depth`** — nesting beyond one level is indent depth only; same-depth blockquotes are indistinguishable.
191
- - **`md/list-item-block-unlisted`** — a table/image in a list item cannot carry `ContentListMembership` (paragraphs only).
192
- - **`md/list-item-multi-block-flattened`** — multi-block list items lose item-boundary identity.
191
+ - **`md/link-title-dropped`** — the one titled shape still dropping: a nested image (inside a link or emphasis) or an unresolved image. Every other title rides a `link` construct's `title` field — a run-level extent for an inline or reference link, a block-scoped marker pair around a resolved image (which also restores the image's original destination on the way out).
192
+ - **`md/blockquote-container-skipped`** — a blockquote containing a heading anywhere in its subtree cannot carry its division construct (a marker extent may not open a heading scope), so that quote degrades to indent-only structure while the heading keeps its fidelity. Every other quote carries a `division` construct pair — exact container boundary and exact nesting depth, with the indent and `Quote` styleId kept as the materialised formatting.
193
+ - **`md/list-item-block-unlisted`** — a table, resolved image, or display-math block in a list item cannot carry `ContentListMembership` (paragraphs only).
194
+ - **`md/list-marker-type-conflict`** — a nested list whose marker type disagrees with its enclosing list's minted numId keeps the enclosing type (first-wins).
195
+ - **`md/math-inline-preserved-as-text`** — inline `\( \)` math stays a Cambria-Math-marked raw-LaTeX run; display `$$` math is a real embedded formula carrying the presentation layer.
193
196
  - **`md/image-unresolved`** — no resolver, `undefined` return, or non-PNG/JPEG bytes degrades to alt-text run.
194
- - **`md/raw-html-preserved-as-text` / `md/raw-html-dropped`** — raw HTML kept as literal text (default) or dropped; never interpreted.
195
- - **`md/front-matter-key-unmapped`** — no YAML/TOML engine; only five known `LayoutMetadata` keys recognised.
197
+ - **`md/raw-html-preserved-as-text` / `md/raw-html-dropped`** — raw HTML kept as literal text (default) or dropped; never interpreted. The preserved text's verbatim original quarantines as markdown residue on its node, and this package's own writer re-emits that residue as-is.
198
+ - **`md/front-matter-key-unmapped`** — no YAML/TOML engine; only `LayoutMetadata`'s own string/array/enum fields are recognised (every one of them except `producer`, which is PDF-writer-only), each as a flat `key: value` (or `keywords: [a, b]`) line. The verbatim original block rides the package-level residue table (`readMarkdown`'s `documentPackage.source.frontmatter`), which `writeMarkdown` re-emits as-is.
196
199
  - **`md/heading-level-clamped`** — styleId beyond `Heading6` (from another format) clamps to level 6 via document-schema.js's shared `clampHeadingLevel()`.
200
+ - **`md/heading-line-break-collapsed`** — a hard or soft break embedded in a heading's own runs (most commonly a setext heading read with more than one physical line) is promoted to setext output whenever the level admits one (1 or 2) and the break's own placement is safe to promote, the only markdown grammar that can hold a genuine line break inside heading text; a level 3-6 heading with the same shape has no such fallback and always collapses the break to a single space instead, as does a level 1/2 heading whose break placement is unsafe to promote (see `md/heading-line-break-unsafe-for-setext` below).
201
+ - **`md/heading-line-break-unsafe-for-setext`** — a level 1/2 heading's own embedded break sits where promoting to setext would violate one of the three clauses packed into setext's own grammar sentence (spec 0.31.2, "Setext headings"): "one or more lines of text, not interrupted by a blank line, of which the first line does not have more than 3 spaces of indentation, followed by a setext heading underline. The lines of text must be such that, were they not followed by the setext heading underline, they would be interpreted as a paragraph: they cannot be interpretable as a code fence, ATX heading, block quote, thematic break, list item, or HTML block." Reported when promoting would leave a blank line immediately before the underline (a trailing break) or in the middle of the heading's own text (an interior break between two embedded breaks, or a break immediately followed by incidental whitespace-only content); when the heading's own first content line opens with 4 or more columns of space/tab indentation — CommonMark's own tab-stop rule counts a tab by the same 4-column stop, so a single leading tab is exactly as unsafe as 4 leading spaces — since that line would read back as an indented code block rather than heading text; or when a line AFTER the first would itself be read as one of the spec's six interrupting constructs (a code fence, ATX heading, block quote, thematic break, list item, or HTML block) instead of ordinary paragraph continuation text — reachable from a bold or strikethrough run that becomes empty immediately after a break, whose bare pair of emphasis markers spells as a thematic break (`____`/`****`) or a code-fence opener (`~~~~`). ATX collapses the break to a single space instead of promoting into any of these corrupt reparses. A break at the very START of the heading's own text stays eligible for setext, but that exemption covers only a single leading blank line, and only the blank line itself: it sits before the text-and-underline run even begins, so it reparses as ordinary inter-block whitespace ahead of the heading rather than corrupting anything. A second consecutive leading blank line is not exempt — CommonMark's own list-item grammar allows at most one, so a second closes a list item as empty and spills the heading out with its list membership lost, even though it would be harmless at top level or inside a blockquote — and the indentation clause above still applies in full to the line that follows the leading blank line, the heading's own first real content: a leading break immediately followed by 4 or more columns of indentation is refused exactly as an unbroken heading in the same shape would be, since promoting would read that following line back as an indented code block regardless of the leading break ahead of it.
202
+ - **`md/heading-style-overridden-for-line-break`** — the setext promotion above overriding the effective `headingStyle: 'atx'` (this option's own default just as much as an explicit caller choice); that one heading renders as setext regardless because ATX cannot hold the embedded break at all.
197
203
  - **`md/adjacent-links-merged`** / **`md/code-span-as-monospace-run`** — same-destination adjacent links merge; monospace runs emit as code spans.
198
204
  - **`md/paragraph-indent-dropped`** — `indentLeftPt` without a recognised styleId; indent dropped, paragraph renders.
199
205
  - **`md/list-numid-fallback`** — a foreign or absent `numId` (depth-only `ContentListMembership`) falls back to a plain bullet list.
200
- - **`md/table-cell-formatting-dropped`** / **`md/table-cell-multi-paragraph-joined`** — GFM cells have no rich-formatting or multi-paragraph representation.
206
+ - **`md/raw-html-preserved-as-text`** — see the raw-HTML entry above.
207
+ - **`md/table-html-fallback`** — a cell's own colSpan/rowSpan/background, or a block a plain GFM cell cannot represent at all (most commonly a nested table), sends the WHOLE table through the HTML-table fallback instead of plain pipe syntax — see [HTML-table fallback](#html-table-fallback). Fires once per table that falls back.
208
+ - **`md/table-cell-formatting-dropped`** — the residual gap even inside the HTML-table fallback: a cell's own pattern background fill (only a solid fill maps onto CSS `background-color`), a nested table mixed with sibling content in the same cell (a cell's own nested table must be its entire content), or any other block kind (`embeddedObject`, `pageBreak`) — none of these have a representation this bounded recogniser attempts; the cell still renders, unmerged/unstyled, with that content dropped.
209
+ - **`md/table-cell-multi-paragraph-joined`** — a cell carrying more than one block joins their rendered content with a literal `<br>`, real inline HTML every GFM table renderer treats as a genuine line break — markdown syntax in the plain pipe-syntax writer, a real `<br>` HTML tag in the HTML-table fallback.
210
+ - **`md/table-cell-image-degraded`** — plain pipe-syntax writer only: an `image`-kind cell block emits inline (`![alt](data:...)`) rather than being dropped; on read-back it degrades to a run carrying the alt text with the image's own data URI as that run's hyperlink, the same "nested image" shape an image inside emphasis/a link already degrades to elsewhere in this package. The HTML-table fallback represents an image losslessly instead, as a real `<img>` tag.
201
211
  - **`md/duplicate-footnote-definition`** — two definitions share a label; every reference resolves to the first, both are kept as written.
202
- - **`md/footnote-reference-preserved-as-text`** — a reference site is a marked run, not an `anchor` construct; see [Footnotes](#footnotes).
203
212
  - **`md/footnote-body-heading-flattened`** — a heading inside a definition body is carried as literal ATX text, since a construct extent may not open or close a heading scope.
204
213
  - **`md/construct-unrepresented`** — a construct kind markdown has no syntax for renders transparently: its extent still appears, the construct itself does not.
205
- - **`md/package-table-dropped`** — `writeMarkdown` only, ahead of flattening: a `DocumentPackage`'s own `definitions`/`layers`/`attachments`/`destinations`/`pages` table has no flat-`ContentDocument` home (`flattenPackage`'s own envelope carries forward only `metadata` and `symbolTable`); fires once per non-empty table present.
214
+ - **`md/package-table-dropped`** — `writeMarkdown` only, ahead of flattening: a `DocumentTree`'s own `definitions`/`layers`/`attachments`/`destinations`/`pages` table has no flat-`ContentDocument` home (`flattenTree`'s own envelope carries forward only `metadata` and `symbolTable`); fires once per non-empty table present.
206
215
 
207
216
  ## Footnotes
208
217
 
209
218
  GitHub's footnote extension (`[^label]` markers, `[^label]: body` definitions) is on by default, alongside the four GFM toggles — switch it off with `footnotes: false`. Neither CommonMark nor the GFM spec document defines footnotes, so both spellings are ordinary text with it off.
210
219
 
211
- The two halves of a footnote map onto **two different mechanisms**, and that split is structural rather than a choice:
220
+ The two halves of a footnote map onto the **same `anchor` construct at two different scopes**, and that split is structural rather than a choice:
212
221
 
213
- - **A definition becomes an `anchor` construct.** Lowering emits document-schema.js's construct boundary markers — a `constructStart` carrying `{ kind: 'anchor', anchorType: 'footnote', name }`, the definition's own lowered body blocks, and a `constructEnd` — which is what `readMarkdownContent` returns in its block flow, and what `decompose` promotes to a construct group of its own in the `DocumentPackage` `readMarkdown` returns (the descriptor rides the group's `node`, the body blocks its `children`). The body rides the construct's extent rather than `AnchorDescriptor.definition`, which names a key in a package-level definitions table: `DocumentPackage` does carry that table as a root (unlike the flat `ContentDocument`), but a table entry there is a flat descriptor record, not a container for block content, so a body that is genuinely several paragraphs, a code block, or a list still has nowhere to live as a table value either way — the construct's own bracketed extent is the one shape in this schema built to hold real block content. A bodyless `[^1]:` lowers to the point anchor the same descriptor describes: a pair with nothing between it.
214
- - **A reference site stays a marked run.** A construct's extent is block-scoped by document-schema.js's own definition, and a reference sits between two runs inside a paragraph, so no block-level boundary marker can bracket it without splitting the paragraph in two. The schema names this gap itself and parks the inline-anchor case on a run-level extent mechanism it has not shipped. Until it does, the reference is a `ContentRun` keeping its own `[^label]` spelling and carrying `FOOTNOTE_REFERENCE_FONT_MARKER`, reported through `md/footnote-reference-preserved-as-text`.
222
+ - **A definition becomes an `anchor` construct.** Lowering emits document-schema.js's construct boundary markers — a `constructStart` carrying `{ kind: 'anchor', anchorType: 'footnote', name }`, the definition's own lowered body blocks, and a `constructEnd` — which is what `readMarkdownContent` returns in its block flow, and what `decompose` promotes to a construct group of its own in the `DocumentTree` `readMarkdown` returns (the descriptor rides the group's `node`, the body blocks its `children`). The body rides the construct's extent rather than `AnchorDescriptor.definition`, which names a key in a package-level definitions table: `DocumentTree` does carry that table as a root (unlike the flat `ContentDocument`), but a table entry there is a flat descriptor record, not a container for block content, so a body that is genuinely several paragraphs, a code block, or a list still has nowhere to live as a table value either way — the construct's own bracketed extent is the one shape in this schema built to hold real block content. A bodyless `[^1]:` lowers to the point anchor the same descriptor describes: a pair with nothing between it.
223
+ - **A reference site becomes a point run-level `anchor` extent.** A reference sits between two runs inside a paragraph, so no block-level boundary marker can bracket it without splitting the paragraph in two — but a run-level construct extent (`RunConstructExtent` on `ContentParagraph.constructs`, document-schema.js 4.5.0) names exactly that shape. Lowering emits an ordinary text run keeping the reference's own `[^label]` spelling (the materialised rendering, so a consumer that ignores constructs still shows `[^1]`) plus a point extent — `{ kind: 'anchor', anchorType: 'footnote', name }` at `startRun === endRun` naming that run, the same wiring ooxml.js's docx reader mints for a `w:footnoteReference` — carried through `decompose`/`flattenTree` verbatim, exactly the way a table cell's own markers are. The writer spells `[^label]` back out from the covering extent rather than from anything about the run's text (which is what still distinguishes a genuine reference from a deliberately-escaped literal `\[^1\]`), gated by the same label grammar as the definition marker: a foreign name that grammar cannot spell degrades to the run's own escaped text plus `md/construct-unrepresented`.
215
224
 
216
- Definitions are recognised only at the document's own top level. Inside a block quote or a list item, the pair's extent would sit inside a scope the enclosing container had already opened, which the marker contract forbids a producer from emitting — so the text stays an ordinary paragraph there. A heading inside a definition body is flattened to literal ATX text for the same reason.
225
+ Definitions are recognised at the document's own top level, directly inside a block quote, or directly inside a list item (ExaDev/markdown-codec#957) — a blockquote's own division construct threads its enclosing container's context straight through the definition's anchor pair the same way it already does for a nested blockquote, and a list item whose own first block is the anchor pair picks up the same placeholder-paragraph carry a nested blockquote already relies on. Not recognised inside another definition's own body: a footnote-in-a-footnote has no cross-format shape, so a `[^2]:` line there stays ordinary body text. A heading inside a definition body is still flattened to literal ATX text, and a blockquote containing a heading anywhere in its own subtree still degrades to indent-only structure — both because a construct boundary marker's extent may not open or close a heading-group scope, a document-schema.js-level limitation this package cannot route around from its own side.
217
226
 
218
227
  Emission is the inverse and validates first: a section's markers must pair as balanced brackets (checked through document-schema.js's own `findConstructMarkerImbalance`, the shared definition every codec and `decompose` agree on) or `writeMarkdownContent` throws `MarkdownUnbalancedConstructMarkersError`. A tree already satisfies that balance by construction — `decompose` refuses to build one from an unbalanced stream — so `writeMarkdown` reaches this check only on a hand-built package flattened back to an unbalanced flow. A construct kind with no markdown syntax — a bookmark, a division, a tracked change — renders transparently: its extent still appears in place, only the construct's own identity is lost.
219
228
 
229
+ ## HTML-table fallback
230
+
231
+ GFM's own pipe-table syntax (github.github.com/gfm, "Tables (extension)") holds inline content only — no cell can carry `colSpan`/`rowSpan`/a background, and no cell can hold a block that isn't inlinable (a nested table, most notably). `writeMarkdownContent` detects this per table (`tableNeedsHtmlFallback`, `src/emit/html-table.ts`): the moment ANY cell needs one of these, the WHOLE table renders as a raw HTML `<table>` block instead of the plain `| a | b |` writer — GFM's own cell grammar cannot mix an HTML sub-block into one cell of an otherwise pipe-syntax table, so a partial, per-cell fallback is not an option. A raw HTML `<table>` block is legal CommonMark regardless (spec 0.31.2, "HTML blocks" start condition 6 names `table` directly — <https://spec.commonmark.org/0.31.2/#html-blocks>). A table with none of these needs still emits the existing, human-readable pipe syntax, unaffected.
232
+
233
+ `readMarkdownContent`/`readMarkdown` recognise this same shape on the way back in (`parseHtmlTable`, `src/html/html-table.ts`) — the one exception to this package's own "raw HTML is never parsed as markup" rule (see the raw-HTML gotcha above and `src/html/html.ts`'s own top comment): a block-level HTML that is, in full, one well-formed `<table>` lowers straight to a real `ContentTable`, so a table written through this fallback reads back as an equal (or equivalent) `ContentTable` rather than degrading to opaque preserved text. This recognition is gated on GFM's table extension being enabled (`gfmTables`, default `true`) exactly the way plain pipe-table promotion already is — with it disabled, a `<table>` block stays exactly the opaque raw HTML it always was, since a `ContentTable` is a GFM-table-extension construct either way it is spelled in the source.
234
+
235
+ Both halves are **bounded recognisers, not a general HTML/DOM parser** — matching `src/html/html.ts`'s own deliberate scope. They recognise `<table>`/`<tr>`/`<td>`/`<th>` and, on each cell, `colspan`/`rowspan` (positive integers) and a `style="background-color:#rrggbb"` declaration (a `ContentCellFill`'s `solid` variant only — a `pattern` fill has no plain-CSS equivalent this writer attempts, and degrades with `TABLE_CELL_FORMATTING_DROPPED`), plus `style="text-align:..."` for the cell's own paragraph alignment — read per cell rather than only from the header row, a strictly richer fidelity than plain GFM's single per-column delimiter marker can ever express, so a table already falling back for another reason never silently loses alignment plain GFM would have kept. Attribute values must be double-quoted, matching exactly what the writer itself emits; a single-quoted or unquoted value is a real HTML shape neither side attempts.
236
+
237
+ A cell's own inline formatting renders as real HTML tags — `<strong>`/`<em>`/`<del>`/`<code>`/`<a href>`, the identical bold/italic/strike/hyperlink/Courier-New-as-code-span vocabulary the plain writer already spells in markdown syntax — because raw HTML block content is never reprocessed as markdown, so writing markdown punctuation inside this block would render as its own literal characters rather than formatting. The reader also recognises the common `<b>`/`<i>`/`<s>`/`<strike>` synonyms real hand-authored HTML tends to use, in any nesting order or combination.
238
+
239
+ A cell's own nested-block content is bounded to two shapes: several paragraph/image blocks join with a literal `<br>`, exactly as the plain writer already joins a multi-paragraph cell (`TABLE_CELL_MULTI_PARAGRAPH_JOINED`); or, when a cell's ENTIRE content is one nested table and nothing else, that table recurses through the identical fallback, unconditionally, since a table nested inside another table's cell can never itself be pipe syntax. A nested table mixed with sibling content in the same cell, or any other block kind (`embeddedObject`, `pageBreak`), has no representation either side attempts and is dropped with `TABLE_CELL_FORMATTING_DROPPED`, exactly as it always was before this fallback existed.
240
+
220
241
  ## Fidelity
221
242
 
222
243
  **Markdown → `ContentDocument` is dominated by target-schema limits, not parsing gaps.** The parser recognises every construct CommonMark and GFM define; the limiting factor is what `ContentDocument` can hold — a cross-format pivot shaped around docx/pptx/odt/odp/ods/odg, not markdown's richer model. Each gap is a permanent structural mismatch.
223
244
 
224
245
  **Round-trip conformance rate** (read → write → reparse → render to HTML, compared byte for byte against expected HTML):
225
246
 
226
- | Corpus | Examples | Passing round trip | Rate |
227
- | --- | --- | --- | --- |
228
- | CommonMark 0.31.2 (`assets/commonmark/spec.json`) | 652 | 461 | 70.7% |
229
- | GFM tagged extensions (table/strikethrough/autolink/task-list, `assets/gfm/spec.txt`) | 23 | 22 | 95.7% |
230
- | Combined | 675 | 483 | 71.6% |
247
+ | Corpus | Examples | Passing round trip | Rate |
248
+ | ------------------------------------------------------------------------------------- | -------- | ------------------ | ----- |
249
+ | CommonMark 0.31.2 (`assets/commonmark/spec.json`) | 652 | 575 | 88.2% |
250
+ | GFM tagged extensions (table/strikethrough/autolink/task-list, `assets/gfm/spec.txt`) | 23 | 23 | 100% |
251
+ | Combined | 675 | 598 | 88.6% |
231
252
 
232
- Every non-passing example is named individually in `src/test-support/conformance-exclusions.ts`, attributed to a closed set of causes (shrink-only — see [Conventions](#conventions)): most commonly a soft line break collapsing to a space, a dropped title/info string, a flattened list item/blockquote, or touching emphasis spans.
253
+ Every non-passing example is named individually in `src/test-support/conformance-exclusions.ts`, attributed to a closed set of causes (shrink-only — see [Conventions](#conventions)): most commonly an emphasis-span collision, an image with no `data:` URI source for the harness to embed, or a blockquote whose heading content skips its container pair.
233
254
 
234
255
  **Optional real-world corpus.** `test/corpus/` (gitignored) holds a `pnpm test:corpus` project for a manual sanity check against sibling READMEs on disk — asserts no throw and real content on reparse, not byte fidelity. Not part of `pnpm test`; run locally before significant parser/lower/emit changes.
235
256
 
236
-
237
-
238
257
  ## Release and publishing
239
258
 
240
- `.github/workflows/ci.yml` runs commitlint, lint, typecheck, unit suite (incl. conformance), and smoke test on every push/PR. On a push to `main` where those pass, `release.config.ts` drives [semantic-release](https://semantic-release.gitbook.io/semantic-release): commit history decides the version bump, `CHANGELOG.md` and `package.json` are committed back to `main`, a GitHub Release is cut, and the package publishes to [npmjs.org](https://www.npmjs.com/package/markdown-codec) via OIDC trusted publishing (no `NPM_TOKEN`).
241
-
242
- Release detection diffs `package.json`'s version before/after the release step. Four further jobs gate on that: a `sibling-released` `repository_dispatch` to `documents.js`; a republish under `@exadev/markdown-codec` to GitHub Packages (`GITHUB_TOKEN`); a republish under `mrkdwn.js` to npmjs.org (same OIDC exchange); and an SPDX SBOM + build-provenance attestation signed against the packed tarball.
259
+ Release, CI, and commit-message conventions are all workspace-wide, not package-local — see the [monorepo root README](../../README.md#releases) for the mechanism (topological per-package `semantic-release` via `@exadev/semantic-release-workspace`, OIDC trusted npm publishing, automatic sibling dependency-range rewriting) and its [post-release republishing and attestation](../../README.md#releases) note on the restored GitHub Packages mirrors, npm aliases, and SBOM/provenance signing.
243
260
 
244
261
  ## Contributing
245
262
 
246
- Conventional Commits enforced by commitlint (`commitlint.config.ts`) via a husky `commit-msg` hook and CI job — semantic-release's version bump depends on well-formed messages. `pre-commit` runs `lint-staged` (`eslint --fix` on staged `*.ts`); `pre-push` runs the test suite. Single `main` branch, no open PR workflow.
263
+ Conventional Commits, enforced workspace-wide by commitlint through a root `commit-msg` hook. Work inside `packages/markdown-codec/`; see [CONTRIBUTING.md](../../CONTRIBUTING.md) for the shared git hooks and history conventions.
247
264
 
248
265
  ## References
249
266
 
250
- - [document-schema.js](https://github.com/ExaDev/document-schema.js) — owns both shared encodings (`ContentDocument`, `DocumentPackage`) and the `assemblePackage`/`flattenPackage` transform between them.
251
- - [pdf-codec](https://github.com/ExaDev/pdf-codec) — the sibling whose scaffold, tooling, and "hand-write the format" philosophy this project mirrors.
267
+ - [document-schema.js](../document-schema.js/README.md) — owns both shared encodings (`ContentDocument`, `DocumentTree`) and the `assembleTree`/`flattenTree` transform between them.
268
+ - [pdf-codec](../pdf-codec/README.md) — the sibling whose scaffold, tooling, and "hand-write the format" philosophy this project mirrors.
252
269
  - [documents.js](https://github.com/ExaDev/documents.js) — bridges markdown to docx/odt/PDF via this package's `ContentDocument` (the flat pair; its own conversion pipeline assembles the package itself). Markdown has no presentation/spreadsheet/drawing variant, so pptx/odp/ods/odg are structurally out of reach.
253
270
  - [CommonMark Spec](https://spec.commonmark.org/) — the base specification targeted.
254
271
  - [GitHub Flavored Markdown Spec](https://github.github.com/gfm/) — GFM extensions layered on top.
@@ -256,10 +273,12 @@ Conventional Commits enforced by commitlint (`commitlint.config.ts`) via a husky
256
273
 
257
274
  ## npm aliases
258
275
 
259
- This package also publishes under the alternate name — identical build, same version, republished by CI:
276
+ This package also published under an alternate name from the pre-monorepo pipeline:
260
277
 
261
278
  - [mrkdwn.js](https://www.npmjs.com/package/mrkdwn.js)
262
279
 
280
+ **Frozen since the monorepo migration** — see the [root README's release note](../../README.md#releases): the alias republish step was dropped along with GitHub Packages mirroring and SBOM/provenance signing, and nothing today keeps this name in sync with `markdown-codec`'s own releases. Tracked in [ExaDev/documents.js#728](https://github.com/ExaDev/documents.js/issues/728).
281
+
263
282
  ## License
264
283
 
265
284
  MIT
@@ -1,2 +1,2 @@
1
- import { A as MarkdownSoftBreakNode, B as isMarkdownInlineNode, C as MarkdownMathBlockNode, D as MarkdownParagraphNode, E as MarkdownOrderedListDelimiter, F as MarkdownTableNode, I as MarkdownTableRowNode, L as MarkdownTextNode, M as MarkdownStrongNode, N as MarkdownTableAlignment, O as MarkdownPosition, P as MarkdownTableCellNode, R as MarkdownThematicBreakNode, S as MarkdownListNode, T as MarkdownNode, _ as MarkdownImageNode, a as MarkdownCodeBlockNode, b as MarkdownListItemNode, c as MarkdownEmphasisMarker, d as MarkdownFootnoteDefinitionNode, f as MarkdownFootnoteReferenceNode, g as MarkdownHtmlBlockNode, h as MarkdownHeadingStyle, i as MarkdownBulletMarker, j as MarkdownStrikethroughNode, k as MarkdownRawHtmlNode, l as MarkdownEmphasisNode, m as MarkdownHeadingNode, n as MarkdownBlockNode, o as MarkdownCodeSpanNode, p as MarkdownHardBreakNode, r as MarkdownBlockquoteNode, s as MarkdownDocumentNode, t as MarkdownAutolinkNode, u as MarkdownEntityNode, v as MarkdownInlineNode, w as MarkdownMathInlineNode, x as MarkdownListMarkerType, y as MarkdownLinkNode, z as isMarkdownBlockNode } from "../ast-8XCbjRQT.cjs";
1
+ import { A as MarkdownSoftBreakNode, B as isMarkdownInlineNode, C as MarkdownMathBlockNode, D as MarkdownParagraphNode, E as MarkdownOrderedListDelimiter, F as MarkdownTableNode, I as MarkdownTableRowNode, L as MarkdownTextNode, M as MarkdownStrongNode, N as MarkdownTableAlignment, O as MarkdownPosition, P as MarkdownTableCellNode, R as MarkdownThematicBreakNode, S as MarkdownListNode, T as MarkdownNode, _ as MarkdownImageNode, a as MarkdownCodeBlockNode, b as MarkdownListItemNode, c as MarkdownEmphasisMarker, d as MarkdownFootnoteDefinitionNode, f as MarkdownFootnoteReferenceNode, g as MarkdownHtmlBlockNode, h as MarkdownHeadingStyle, i as MarkdownBulletMarker, j as MarkdownStrikethroughNode, k as MarkdownRawHtmlNode, l as MarkdownEmphasisNode, m as MarkdownHeadingNode, n as MarkdownBlockNode, o as MarkdownCodeSpanNode, p as MarkdownHardBreakNode, r as MarkdownBlockquoteNode, s as MarkdownDocumentNode, t as MarkdownAutolinkNode, u as MarkdownEntityNode, v as MarkdownInlineNode, w as MarkdownMathInlineNode, x as MarkdownListMarkerType, y as MarkdownLinkNode, z as isMarkdownBlockNode } from "../ast-CNfTgS0N.cjs";
2
2
  export { MarkdownAutolinkNode, MarkdownBlockNode, MarkdownBlockquoteNode, MarkdownBulletMarker, MarkdownCodeBlockNode, MarkdownCodeSpanNode, MarkdownDocumentNode, MarkdownEmphasisMarker, MarkdownEmphasisNode, MarkdownEntityNode, MarkdownFootnoteDefinitionNode, MarkdownFootnoteReferenceNode, MarkdownHardBreakNode, MarkdownHeadingNode, MarkdownHeadingStyle, MarkdownHtmlBlockNode, MarkdownImageNode, MarkdownInlineNode, MarkdownLinkNode, MarkdownListItemNode, MarkdownListMarkerType, MarkdownListNode, MarkdownMathBlockNode, MarkdownMathInlineNode, MarkdownNode, MarkdownOrderedListDelimiter, MarkdownParagraphNode, MarkdownPosition, MarkdownRawHtmlNode, MarkdownSoftBreakNode, MarkdownStrikethroughNode, MarkdownStrongNode, MarkdownTableAlignment, MarkdownTableCellNode, MarkdownTableNode, MarkdownTableRowNode, MarkdownTextNode, MarkdownThematicBreakNode, isMarkdownBlockNode, isMarkdownInlineNode };
package/dist/ast/ast.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as MarkdownSoftBreakNode, B as isMarkdownInlineNode, C as MarkdownMathBlockNode, D as MarkdownParagraphNode, E as MarkdownOrderedListDelimiter, F as MarkdownTableNode, I as MarkdownTableRowNode, L as MarkdownTextNode, M as MarkdownStrongNode, N as MarkdownTableAlignment, O as MarkdownPosition, P as MarkdownTableCellNode, R as MarkdownThematicBreakNode, S as MarkdownListNode, T as MarkdownNode, _ as MarkdownImageNode, a as MarkdownCodeBlockNode, b as MarkdownListItemNode, c as MarkdownEmphasisMarker, d as MarkdownFootnoteDefinitionNode, f as MarkdownFootnoteReferenceNode, g as MarkdownHtmlBlockNode, h as MarkdownHeadingStyle, i as MarkdownBulletMarker, j as MarkdownStrikethroughNode, k as MarkdownRawHtmlNode, l as MarkdownEmphasisNode, m as MarkdownHeadingNode, n as MarkdownBlockNode, o as MarkdownCodeSpanNode, p as MarkdownHardBreakNode, r as MarkdownBlockquoteNode, s as MarkdownDocumentNode, t as MarkdownAutolinkNode, u as MarkdownEntityNode, v as MarkdownInlineNode, w as MarkdownMathInlineNode, x as MarkdownListMarkerType, y as MarkdownLinkNode, z as isMarkdownBlockNode } from "../ast-8XCbjRQT.js";
1
+ import { A as MarkdownSoftBreakNode, B as isMarkdownInlineNode, C as MarkdownMathBlockNode, D as MarkdownParagraphNode, E as MarkdownOrderedListDelimiter, F as MarkdownTableNode, I as MarkdownTableRowNode, L as MarkdownTextNode, M as MarkdownStrongNode, N as MarkdownTableAlignment, O as MarkdownPosition, P as MarkdownTableCellNode, R as MarkdownThematicBreakNode, S as MarkdownListNode, T as MarkdownNode, _ as MarkdownImageNode, a as MarkdownCodeBlockNode, b as MarkdownListItemNode, c as MarkdownEmphasisMarker, d as MarkdownFootnoteDefinitionNode, f as MarkdownFootnoteReferenceNode, g as MarkdownHtmlBlockNode, h as MarkdownHeadingStyle, i as MarkdownBulletMarker, j as MarkdownStrikethroughNode, k as MarkdownRawHtmlNode, l as MarkdownEmphasisNode, m as MarkdownHeadingNode, n as MarkdownBlockNode, o as MarkdownCodeSpanNode, p as MarkdownHardBreakNode, r as MarkdownBlockquoteNode, s as MarkdownDocumentNode, t as MarkdownAutolinkNode, u as MarkdownEntityNode, v as MarkdownInlineNode, w as MarkdownMathInlineNode, x as MarkdownListMarkerType, y as MarkdownLinkNode, z as isMarkdownBlockNode } from "../ast-CNfTgS0N.js";
2
2
  export { MarkdownAutolinkNode, MarkdownBlockNode, MarkdownBlockquoteNode, MarkdownBulletMarker, MarkdownCodeBlockNode, MarkdownCodeSpanNode, MarkdownDocumentNode, MarkdownEmphasisMarker, MarkdownEmphasisNode, MarkdownEntityNode, MarkdownFootnoteDefinitionNode, MarkdownFootnoteReferenceNode, MarkdownHardBreakNode, MarkdownHeadingNode, MarkdownHeadingStyle, MarkdownHtmlBlockNode, MarkdownImageNode, MarkdownInlineNode, MarkdownLinkNode, MarkdownListItemNode, MarkdownListMarkerType, MarkdownListNode, MarkdownMathBlockNode, MarkdownMathInlineNode, MarkdownNode, MarkdownOrderedListDelimiter, MarkdownParagraphNode, MarkdownPosition, MarkdownRawHtmlNode, MarkdownSoftBreakNode, MarkdownStrikethroughNode, MarkdownStrongNode, MarkdownTableAlignment, MarkdownTableCellNode, MarkdownTableNode, MarkdownTableRowNode, MarkdownTextNode, MarkdownThematicBreakNode, isMarkdownBlockNode, isMarkdownInlineNode };
@@ -8,33 +8,33 @@ interface MarkdownPosition {
8
8
  type MarkdownNode = MarkdownBlockNode | MarkdownInlineNode;
9
9
  type MarkdownBlockNode = MarkdownDocumentNode | MarkdownParagraphNode | MarkdownHeadingNode | MarkdownBlockquoteNode | MarkdownListNode | MarkdownListItemNode | MarkdownCodeBlockNode | MarkdownThematicBreakNode | MarkdownHtmlBlockNode | MarkdownTableNode | MarkdownTableRowNode | MarkdownTableCellNode | MarkdownMathBlockNode | MarkdownFootnoteDefinitionNode;
10
10
  interface MarkdownDocumentNode {
11
- readonly type: 'document';
11
+ readonly type: "document";
12
12
  readonly children: MarkdownBlockNode[];
13
13
  readonly position?: MarkdownPosition;
14
14
  }
15
15
  interface MarkdownParagraphNode {
16
- readonly type: 'paragraph';
16
+ readonly type: "paragraph";
17
17
  readonly children: MarkdownInlineNode[];
18
18
  readonly position?: MarkdownPosition;
19
19
  }
20
- type MarkdownHeadingStyle = 'atx' | 'setext';
20
+ type MarkdownHeadingStyle = "atx" | "setext";
21
21
  interface MarkdownHeadingNode {
22
- readonly type: 'heading';
22
+ readonly type: "heading";
23
23
  readonly level: 1 | 2 | 3 | 4 | 5 | 6;
24
24
  readonly style: MarkdownHeadingStyle;
25
25
  readonly children: MarkdownInlineNode[];
26
26
  readonly position?: MarkdownPosition;
27
27
  }
28
28
  interface MarkdownBlockquoteNode {
29
- readonly type: 'blockquote';
29
+ readonly type: "blockquote";
30
30
  readonly children: MarkdownBlockNode[];
31
31
  readonly position?: MarkdownPosition;
32
32
  }
33
- type MarkdownListMarkerType = 'bullet' | 'ordered';
34
- type MarkdownBulletMarker = '-' | '*' | '+';
35
- type MarkdownOrderedListDelimiter = '.' | ')';
33
+ type MarkdownListMarkerType = "bullet" | "ordered";
34
+ type MarkdownBulletMarker = "-" | "*" | "+";
35
+ type MarkdownOrderedListDelimiter = "." | ")";
36
36
  interface MarkdownListNode {
37
- readonly type: 'list';
37
+ readonly type: "list";
38
38
  readonly markerType: MarkdownListMarkerType;
39
39
  readonly bulletMarker?: MarkdownBulletMarker;
40
40
  readonly orderedDelimiter?: MarkdownOrderedListDelimiter;
@@ -44,95 +44,95 @@ interface MarkdownListNode {
44
44
  readonly position?: MarkdownPosition;
45
45
  }
46
46
  interface MarkdownListItemNode {
47
- readonly type: 'listItem';
47
+ readonly type: "listItem";
48
48
  readonly checked?: boolean;
49
49
  readonly children: MarkdownBlockNode[];
50
50
  readonly position?: MarkdownPosition;
51
51
  }
52
52
  interface MarkdownCodeBlockNode {
53
- readonly type: 'codeBlock';
53
+ readonly type: "codeBlock";
54
54
  readonly fenced: boolean;
55
- readonly fenceChar?: '`' | '~';
55
+ readonly fenceChar?: "`" | "~";
56
56
  readonly infoString?: string;
57
57
  readonly literal: string;
58
58
  readonly position?: MarkdownPosition;
59
59
  }
60
60
  interface MarkdownThematicBreakNode {
61
- readonly type: 'thematicBreak';
61
+ readonly type: "thematicBreak";
62
62
  readonly position?: MarkdownPosition;
63
63
  }
64
64
  interface MarkdownHtmlBlockNode {
65
- readonly type: 'htmlBlock';
65
+ readonly type: "htmlBlock";
66
66
  readonly literal: string;
67
67
  readonly position?: MarkdownPosition;
68
68
  }
69
- type MarkdownTableAlignment = 'left' | 'right' | 'center' | 'none';
69
+ type MarkdownTableAlignment = "left" | "right" | "center" | "none";
70
70
  interface MarkdownTableNode {
71
- readonly type: 'table';
71
+ readonly type: "table";
72
72
  readonly alignments: MarkdownTableAlignment[];
73
73
  readonly children: MarkdownTableRowNode[];
74
74
  readonly position?: MarkdownPosition;
75
75
  }
76
76
  interface MarkdownTableRowNode {
77
- readonly type: 'tableRow';
77
+ readonly type: "tableRow";
78
78
  readonly header: boolean;
79
79
  readonly children: MarkdownTableCellNode[];
80
80
  readonly position?: MarkdownPosition;
81
81
  }
82
82
  interface MarkdownTableCellNode {
83
- readonly type: 'tableCell';
83
+ readonly type: "tableCell";
84
84
  readonly children: MarkdownInlineNode[];
85
85
  readonly position?: MarkdownPosition;
86
86
  }
87
87
  interface MarkdownMathBlockNode {
88
- readonly type: 'mathBlock';
88
+ readonly type: "mathBlock";
89
89
  readonly literal: string;
90
90
  readonly position?: MarkdownPosition;
91
91
  }
92
92
  interface MarkdownFootnoteDefinitionNode {
93
- readonly type: 'footnoteDefinition';
93
+ readonly type: "footnoteDefinition";
94
94
  readonly label: string;
95
95
  readonly children: MarkdownBlockNode[];
96
96
  readonly position?: MarkdownPosition;
97
97
  }
98
98
  type MarkdownInlineNode = MarkdownTextNode | MarkdownEmphasisNode | MarkdownStrongNode | MarkdownStrikethroughNode | MarkdownCodeSpanNode | MarkdownLinkNode | MarkdownImageNode | MarkdownAutolinkNode | MarkdownHardBreakNode | MarkdownSoftBreakNode | MarkdownRawHtmlNode | MarkdownEntityNode | MarkdownMathInlineNode | MarkdownFootnoteReferenceNode;
99
- type MarkdownEmphasisMarker = '_' | '*';
99
+ type MarkdownEmphasisMarker = "_" | "*";
100
100
  interface MarkdownTextNode {
101
- readonly type: 'text';
101
+ readonly type: "text";
102
102
  readonly value: string;
103
103
  readonly position?: MarkdownPosition;
104
104
  }
105
105
  interface MarkdownEmphasisNode {
106
- readonly type: 'emphasis';
106
+ readonly type: "emphasis";
107
107
  readonly marker: MarkdownEmphasisMarker;
108
108
  readonly children: MarkdownInlineNode[];
109
109
  readonly position?: MarkdownPosition;
110
110
  }
111
111
  interface MarkdownStrongNode {
112
- readonly type: 'strong';
112
+ readonly type: "strong";
113
113
  readonly marker: MarkdownEmphasisMarker;
114
114
  readonly children: MarkdownInlineNode[];
115
115
  readonly position?: MarkdownPosition;
116
116
  }
117
117
  interface MarkdownStrikethroughNode {
118
- readonly type: 'strikethrough';
118
+ readonly type: "strikethrough";
119
119
  readonly children: MarkdownInlineNode[];
120
120
  readonly position?: MarkdownPosition;
121
121
  }
122
122
  interface MarkdownCodeSpanNode {
123
- readonly type: 'codeSpan';
123
+ readonly type: "codeSpan";
124
124
  readonly literal: string;
125
125
  readonly position?: MarkdownPosition;
126
126
  }
127
127
  interface MarkdownLinkNode {
128
- readonly type: 'link';
128
+ readonly type: "link";
129
129
  readonly destination: string;
130
130
  readonly title?: string;
131
131
  readonly children: MarkdownInlineNode[];
132
132
  readonly position?: MarkdownPosition;
133
133
  }
134
134
  interface MarkdownImageNode {
135
- readonly type: 'image';
135
+ readonly type: "image";
136
136
  readonly destination: string;
137
137
  readonly title?: string;
138
138
  readonly alt: string;
@@ -141,37 +141,37 @@ interface MarkdownImageNode {
141
141
  readonly position?: MarkdownPosition;
142
142
  }
143
143
  interface MarkdownAutolinkNode {
144
- readonly type: 'autolink';
144
+ readonly type: "autolink";
145
145
  readonly destination: string;
146
146
  readonly email: boolean;
147
147
  readonly position?: MarkdownPosition;
148
148
  }
149
149
  interface MarkdownHardBreakNode {
150
- readonly type: 'hardBreak';
150
+ readonly type: "hardBreak";
151
151
  readonly position?: MarkdownPosition;
152
152
  }
153
153
  interface MarkdownSoftBreakNode {
154
- readonly type: 'softBreak';
154
+ readonly type: "softBreak";
155
155
  readonly position?: MarkdownPosition;
156
156
  }
157
157
  interface MarkdownRawHtmlNode {
158
- readonly type: 'rawHtml';
158
+ readonly type: "rawHtml";
159
159
  readonly literal: string;
160
160
  readonly position?: MarkdownPosition;
161
161
  }
162
162
  interface MarkdownEntityNode {
163
- readonly type: 'entity';
163
+ readonly type: "entity";
164
164
  readonly raw: string;
165
165
  readonly value: string;
166
166
  readonly position?: MarkdownPosition;
167
167
  }
168
168
  interface MarkdownMathInlineNode {
169
- readonly type: 'mathInline';
169
+ readonly type: "mathInline";
170
170
  readonly literal: string;
171
171
  readonly position?: MarkdownPosition;
172
172
  }
173
173
  interface MarkdownFootnoteReferenceNode {
174
- readonly type: 'footnoteReference';
174
+ readonly type: "footnoteReference";
175
175
  readonly label: string;
176
176
  readonly position?: MarkdownPosition;
177
177
  }