mrkdwn.js 8.0.1 → 10.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.
Files changed (40) hide show
  1. package/README.md +3 -3
  2. package/dist/block/block.d.cts +1 -1
  3. package/dist/block/block.d.ts +1 -1
  4. package/dist/block/definitions.d.cts +1 -1
  5. package/dist/block/definitions.d.ts +1 -1
  6. package/dist/codec.cjs +4 -11
  7. package/dist/codec.d.cts +10 -10
  8. package/dist/codec.d.ts +10 -10
  9. package/dist/codec.js +4 -11
  10. package/dist/diagnostics/diagnostics.cjs +15 -5
  11. package/dist/diagnostics/diagnostics.d.cts +2 -2
  12. package/dist/diagnostics/diagnostics.d.ts +2 -2
  13. package/dist/diagnostics/diagnostics.js +14 -5
  14. package/dist/{diagnostics-CjfBoW4K.d.cts → diagnostics-BJtTrxpp.d.cts} +7 -2
  15. package/dist/{diagnostics-CjfBoW4K.d.ts → diagnostics-BJtTrxpp.d.ts} +7 -2
  16. package/dist/emit/html-table.cjs +9 -0
  17. package/dist/emit/html-table.d.cts +5 -1
  18. package/dist/emit/html-table.d.ts +5 -1
  19. package/dist/emit/html-table.js +11 -3
  20. package/dist/emit/inline.d.cts +1 -1
  21. package/dist/emit/inline.d.ts +1 -1
  22. package/dist/emit/table.cjs +1 -0
  23. package/dist/emit/table.d.cts +2 -2
  24. package/dist/emit/table.d.ts +2 -2
  25. package/dist/emit/table.js +2 -1
  26. package/dist/index.cjs +2 -1
  27. package/dist/index.d.cts +2 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/index.js +2 -2
  30. package/dist/{inline-DCIKQ83j.d.cts → inline-C8ObWyKW.d.cts} +1 -1
  31. package/dist/{inline-INoDAG37.d.ts → inline-XJ4cdpPz.d.ts} +1 -1
  32. package/dist/lower/front-matter.d.cts +1 -1
  33. package/dist/lower/front-matter.d.ts +1 -1
  34. package/dist/lower/inline.d.cts +1 -1
  35. package/dist/lower/inline.d.ts +1 -1
  36. package/dist/options/options.d.cts +1 -1
  37. package/dist/options/options.d.ts +1 -1
  38. package/dist/read.d.cts +1 -1
  39. package/dist/read.d.ts +1 -1
  40. package/package.json +2 -2
package/README.md CHANGED
@@ -105,11 +105,11 @@ The same round trip as a schema-validated [`z.codec()`](https://zod.dev) pair, m
105
105
  import { z } from "zod";
106
106
  import { markdownCodec, MarkdownBytesSchema } from "markdown-codec";
107
107
 
108
- const documentPackage = z.decode(markdownCodec, bytes); // throws if bytes are not well-formed UTF-8
108
+ const documentPackage = z.decode(markdownCodec, bytes); // throws if the bytes are not text
109
109
  const bytes2 = z.encode(markdownCodec, documentPackage);
110
110
  ```
111
111
 
112
- `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).
112
+ `MarkdownBytesSchema` checks that the bytes are text at all, which is the only structural question markdown's lack of a magic number leaves. The character encoding is worked out from the bytes by [byte-codec](../byte-codec/README.md#text-decoding) rather than assumed to be UTF-8, so a file saved in the Windows system code page or as UTF-16 reads; binary content, and text in an encoding that cannot be placed, are refused rather than guessed at. 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).
113
113
 
114
114
  ## Two encodings: `DocumentTree` and `ContentDocument`
115
115
 
@@ -229,7 +229,7 @@ Emission is the inverse and validates first: a section's markers must pair as ba
229
229
 
230
230
  ## HTML-table fallback
231
231
 
232
- 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
+ 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. Either way a table must obey the grid rule (document-schema.js's `findTableGridFault`: no blocks or span on a covered position, rows of one length, no region running past the grid or into another) or `writeMarkdownContent` throws `MarkdownTableGridFaultError`, since neither a pipe row nor an HTML row has a cell for a covered position's content.
233
233
 
234
234
  `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.
235
235
 
@@ -1,6 +1,6 @@
1
1
  import { s as MarkdownDocumentNode } from "../ast-CNfTgS0N.cjs";
2
2
  import { r as FootnoteLabelSet } from "../footnote-CKk4JbLk.cjs";
3
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.cjs";
3
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.cjs";
4
4
  import { LinkReferenceMap } from "../inline/link.cjs";
5
5
  import { t as InlineParseOptions } from "../inline-CnO86zMw.cjs";
6
6
  //#region src/block/block.d.ts
@@ -1,6 +1,6 @@
1
1
  import { s as MarkdownDocumentNode } from "../ast-CNfTgS0N.js";
2
2
  import { r as FootnoteLabelSet } from "../footnote-CKk4JbLk.js";
3
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.js";
3
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.js";
4
4
  import { LinkReferenceMap } from "../inline/link.js";
5
5
  import { t as InlineParseOptions } from "../inline-DItZ-VVw.js";
6
6
  //#region src/block/block.d.ts
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.cjs";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.cjs";
2
2
  import { LinkReferenceDefinition } from "../inline/link.cjs";
3
3
  //#region src/block/definitions.d.ts
4
4
  declare function extractDefinitions(content: string, references: Map<string, LinkReferenceDefinition>, sink?: MarkdownDiagnosticSink, startLine?: number): string;
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.js";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.js";
2
2
  import { LinkReferenceDefinition } from "../inline/link.js";
3
3
  //#region src/block/definitions.d.ts
4
4
  declare function extractDefinitions(content: string, references: Map<string, LinkReferenceDefinition>, sink?: MarkdownDiagnosticSink, startLine?: number): string;
package/dist/codec.cjs CHANGED
@@ -3,22 +3,15 @@ const require_read = require("./read.cjs");
3
3
  const require_write = require("./write.cjs");
4
4
  let zod = require("zod");
5
5
  let document_schema_js = require("document-schema.js");
6
+ let byte_codec = require("byte-codec");
6
7
  //#region src/codec.ts
7
- function isWellFormedUtf8Text(bytes) {
8
- try {
9
- new TextDecoder("utf-8", { fatal: true }).decode(bytes);
10
- return true;
11
- } catch {
12
- return false;
13
- }
14
- }
15
- const MarkdownBytesSchema = zod.z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
8
+ const MarkdownBytesSchema = zod.z.instanceof(Uint8Array).refine((bytes) => (0, byte_codec.tryDecodeText)(bytes) !== void 0, { message: "not text in any supported character encoding" });
16
9
  const markdownCodec = zod.z.codec(MarkdownBytesSchema, document_schema_js.DocumentTreeSchema, {
17
- decode: (bytes) => require_read.readMarkdown(new TextDecoder().decode(bytes)).documentPackage,
10
+ decode: (bytes) => require_read.readMarkdown((0, byte_codec.decodeText)(bytes).text).documentPackage,
18
11
  encode: (documentPackage) => new TextEncoder().encode(require_write.writeMarkdown(documentPackage))
19
12
  });
20
13
  const markdownContentCodec = zod.z.codec(MarkdownBytesSchema, document_schema_js.ContentDocumentSchema, {
21
- decode: (bytes) => require_read.readMarkdownContent(new TextDecoder().decode(bytes)).document,
14
+ decode: (bytes) => require_read.readMarkdownContent((0, byte_codec.decodeText)(bytes).text).document,
22
15
  encode: (document) => new TextEncoder().encode(require_write.writeMarkdownContent(document))
23
16
  });
24
17
  //#endregion
package/dist/codec.d.cts CHANGED
@@ -17,8 +17,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
17
17
  paragraph: z.ZodOptional<z.ZodObject<{
18
18
  alignment: z.ZodOptional<z.ZodEnum<{
19
19
  left: "left";
20
- right: "right";
21
20
  center: "center";
21
+ right: "right";
22
22
  justify: "justify";
23
23
  }>>;
24
24
  list: z.ZodOptional<z.ZodObject<{
@@ -172,8 +172,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
172
172
  paragraph: z.ZodOptional<z.ZodObject<{
173
173
  alignment: z.ZodOptional<z.ZodEnum<{
174
174
  left: "left";
175
- right: "right";
176
175
  center: "center";
176
+ right: "right";
177
177
  justify: "justify";
178
178
  }>>;
179
179
  list: z.ZodOptional<z.ZodObject<{
@@ -332,8 +332,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
332
332
  paragraph: z.ZodOptional<z.ZodObject<{
333
333
  alignment: z.ZodOptional<z.ZodEnum<{
334
334
  left: "left";
335
- right: "right";
336
335
  center: "center";
336
+ right: "right";
337
337
  justify: "justify";
338
338
  }>>;
339
339
  list: z.ZodOptional<z.ZodObject<{
@@ -487,8 +487,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
487
487
  paragraph: z.ZodOptional<z.ZodObject<{
488
488
  alignment: z.ZodOptional<z.ZodEnum<{
489
489
  left: "left";
490
- right: "right";
491
490
  center: "center";
491
+ right: "right";
492
492
  justify: "justify";
493
493
  }>>;
494
494
  list: z.ZodOptional<z.ZodObject<{
@@ -701,8 +701,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
701
701
  paragraph: z.ZodOptional<z.ZodObject<{
702
702
  alignment: z.ZodOptional<z.ZodEnum<{
703
703
  left: "left";
704
- right: "right";
705
704
  center: "center";
705
+ right: "right";
706
706
  justify: "justify";
707
707
  }>>;
708
708
  list: z.ZodOptional<z.ZodObject<{
@@ -1538,8 +1538,8 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1538
1538
  }, z.core.$strip>>;
1539
1539
  alignment: z.ZodOptional<z.ZodEnum<{
1540
1540
  left: "left";
1541
- right: "right";
1542
1541
  center: "center";
1542
+ right: "right";
1543
1543
  justify: "justify";
1544
1544
  }>>;
1545
1545
  verticalAlignment: z.ZodOptional<z.ZodEnum<{
@@ -1681,10 +1681,10 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1681
1681
  }>;
1682
1682
  align: z.ZodEnum<{
1683
1683
  left: "left";
1684
+ center: "center";
1684
1685
  right: "right";
1685
1686
  top: "top";
1686
1687
  bottom: "bottom";
1687
- center: "center";
1688
1688
  inside: "inside";
1689
1689
  outside: "outside";
1690
1690
  }>;
@@ -1724,10 +1724,10 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1724
1724
  }>;
1725
1725
  align: z.ZodEnum<{
1726
1726
  left: "left";
1727
+ center: "center";
1727
1728
  right: "right";
1728
1729
  top: "top";
1729
1730
  bottom: "bottom";
1730
- center: "center";
1731
1731
  inside: "inside";
1732
1732
  outside: "outside";
1733
1733
  }>;
@@ -1816,10 +1816,10 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1816
1816
  endColumn: z.ZodNumber;
1817
1817
  }, z.core.$strip>>;
1818
1818
  type: z.ZodEnum<{
1819
- date: "date";
1820
- custom: "custom";
1821
1819
  decimal: "decimal";
1822
1820
  list: "list";
1821
+ date: "date";
1822
+ custom: "custom";
1823
1823
  time: "time";
1824
1824
  whole: "whole";
1825
1825
  textLength: "textLength";
package/dist/codec.d.ts CHANGED
@@ -17,8 +17,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
17
17
  paragraph: z.ZodOptional<z.ZodObject<{
18
18
  alignment: z.ZodOptional<z.ZodEnum<{
19
19
  left: "left";
20
- right: "right";
21
20
  center: "center";
21
+ right: "right";
22
22
  justify: "justify";
23
23
  }>>;
24
24
  list: z.ZodOptional<z.ZodObject<{
@@ -172,8 +172,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
172
172
  paragraph: z.ZodOptional<z.ZodObject<{
173
173
  alignment: z.ZodOptional<z.ZodEnum<{
174
174
  left: "left";
175
- right: "right";
176
175
  center: "center";
176
+ right: "right";
177
177
  justify: "justify";
178
178
  }>>;
179
179
  list: z.ZodOptional<z.ZodObject<{
@@ -332,8 +332,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
332
332
  paragraph: z.ZodOptional<z.ZodObject<{
333
333
  alignment: z.ZodOptional<z.ZodEnum<{
334
334
  left: "left";
335
- right: "right";
336
335
  center: "center";
336
+ right: "right";
337
337
  justify: "justify";
338
338
  }>>;
339
339
  list: z.ZodOptional<z.ZodObject<{
@@ -487,8 +487,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
487
487
  paragraph: z.ZodOptional<z.ZodObject<{
488
488
  alignment: z.ZodOptional<z.ZodEnum<{
489
489
  left: "left";
490
- right: "right";
491
490
  center: "center";
491
+ right: "right";
492
492
  justify: "justify";
493
493
  }>>;
494
494
  list: z.ZodOptional<z.ZodObject<{
@@ -701,8 +701,8 @@ declare const markdownCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uin
701
701
  paragraph: z.ZodOptional<z.ZodObject<{
702
702
  alignment: z.ZodOptional<z.ZodEnum<{
703
703
  left: "left";
704
- right: "right";
705
704
  center: "center";
705
+ right: "right";
706
706
  justify: "justify";
707
707
  }>>;
708
708
  list: z.ZodOptional<z.ZodObject<{
@@ -1538,8 +1538,8 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1538
1538
  }, z.core.$strip>>;
1539
1539
  alignment: z.ZodOptional<z.ZodEnum<{
1540
1540
  left: "left";
1541
- right: "right";
1542
1541
  center: "center";
1542
+ right: "right";
1543
1543
  justify: "justify";
1544
1544
  }>>;
1545
1545
  verticalAlignment: z.ZodOptional<z.ZodEnum<{
@@ -1681,10 +1681,10 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1681
1681
  }>;
1682
1682
  align: z.ZodEnum<{
1683
1683
  left: "left";
1684
+ center: "center";
1684
1685
  right: "right";
1685
1686
  top: "top";
1686
1687
  bottom: "bottom";
1687
- center: "center";
1688
1688
  inside: "inside";
1689
1689
  outside: "outside";
1690
1690
  }>;
@@ -1724,10 +1724,10 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1724
1724
  }>;
1725
1725
  align: z.ZodEnum<{
1726
1726
  left: "left";
1727
+ center: "center";
1727
1728
  right: "right";
1728
1729
  top: "top";
1729
1730
  bottom: "bottom";
1730
- center: "center";
1731
1731
  inside: "inside";
1732
1732
  outside: "outside";
1733
1733
  }>;
@@ -1816,10 +1816,10 @@ declare const markdownContentCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffe
1816
1816
  endColumn: z.ZodNumber;
1817
1817
  }, z.core.$strip>>;
1818
1818
  type: z.ZodEnum<{
1819
- date: "date";
1820
- custom: "custom";
1821
1819
  decimal: "decimal";
1822
1820
  list: "list";
1821
+ date: "date";
1822
+ custom: "custom";
1823
1823
  time: "time";
1824
1824
  whole: "whole";
1825
1825
  textLength: "textLength";
package/dist/codec.js CHANGED
@@ -2,22 +2,15 @@ import { readMarkdown, readMarkdownContent } from "./read.js";
2
2
  import { writeMarkdown, writeMarkdownContent } from "./write.js";
3
3
  import { z } from "zod";
4
4
  import { ContentDocumentSchema, DocumentTreeSchema } from "document-schema.js";
5
+ import { decodeText, tryDecodeText } from "byte-codec";
5
6
  //#region src/codec.ts
6
- function isWellFormedUtf8Text(bytes) {
7
- try {
8
- new TextDecoder("utf-8", { fatal: true }).decode(bytes);
9
- return true;
10
- } catch {
11
- return false;
12
- }
13
- }
14
- const MarkdownBytesSchema = z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
7
+ const MarkdownBytesSchema = z.instanceof(Uint8Array).refine((bytes) => tryDecodeText(bytes) !== void 0, { message: "not text in any supported character encoding" });
15
8
  const markdownCodec = z.codec(MarkdownBytesSchema, DocumentTreeSchema, {
16
- decode: (bytes) => readMarkdown(new TextDecoder().decode(bytes)).documentPackage,
9
+ decode: (bytes) => readMarkdown(decodeText(bytes).text).documentPackage,
17
10
  encode: (documentPackage) => new TextEncoder().encode(writeMarkdown(documentPackage))
18
11
  });
19
12
  const markdownContentCodec = z.codec(MarkdownBytesSchema, ContentDocumentSchema, {
20
- decode: (bytes) => readMarkdownContent(new TextDecoder().decode(bytes)).document,
13
+ decode: (bytes) => readMarkdownContent(decodeText(bytes).text).document,
21
14
  encode: (document) => new TextEncoder().encode(writeMarkdownContent(document))
22
15
  });
23
16
  //#endregion
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let document_schema_js = require("document-schema.js");
2
3
  //#region src/diagnostics/diagnostics.ts
3
4
  const NOOP_MARKDOWN_DIAGNOSTIC_SINK = () => {};
4
5
  const MarkdownDiagnosticCodes = {
@@ -41,10 +42,10 @@ var MarkdownParseError = class extends Error {
41
42
  this.code = code;
42
43
  }
43
44
  };
44
- var MarkdownInvalidUtf8Error = class extends MarkdownParseError {
45
- constructor(message = "input is not valid UTF-8") {
46
- super("md/invalid-utf8", message);
47
- this.name = "MarkdownInvalidUtf8Error";
45
+ var MarkdownUndecodableTextError = class extends MarkdownParseError {
46
+ constructor(message = "input does not decode as text under any supported encoding") {
47
+ super("md/undecodable-text", message);
48
+ this.name = "MarkdownUndecodableTextError";
48
49
  }
49
50
  };
50
51
  var MarkdownInputTooLargeError = class extends MarkdownParseError {
@@ -83,6 +84,14 @@ var MarkdownUnbalancedConstructMarkersError = class extends MarkdownWriteError {
83
84
  this.blockIndex = blockIndex;
84
85
  }
85
86
  };
87
+ var MarkdownTableGridFaultError = class extends MarkdownWriteError {
88
+ fault;
89
+ constructor(fault) {
90
+ super("md/table-grid-fault", `a table breaks the grid rule: ${(0, document_schema_js.describeTableGridFault)(fault)}`);
91
+ this.name = "MarkdownTableGridFaultError";
92
+ this.fault = fault;
93
+ }
94
+ };
86
95
  var MarkdownInvalidRunConstructExtentError = class extends MarkdownWriteError {
87
96
  faultKind;
88
97
  entryIndex;
@@ -112,11 +121,12 @@ var MarkdownPackageFlattenError = class extends MarkdownWriteError {
112
121
  exports.MarkdownDiagnosticCodes = MarkdownDiagnosticCodes;
113
122
  exports.MarkdownInputTooLargeError = MarkdownInputTooLargeError;
114
123
  exports.MarkdownInvalidRunConstructExtentError = MarkdownInvalidRunConstructExtentError;
115
- exports.MarkdownInvalidUtf8Error = MarkdownInvalidUtf8Error;
116
124
  exports.MarkdownNestingLimitExceededError = MarkdownNestingLimitExceededError;
117
125
  exports.MarkdownPackageFlattenError = MarkdownPackageFlattenError;
118
126
  exports.MarkdownParseError = MarkdownParseError;
127
+ exports.MarkdownTableGridFaultError = MarkdownTableGridFaultError;
119
128
  exports.MarkdownUnbalancedConstructMarkersError = MarkdownUnbalancedConstructMarkersError;
129
+ exports.MarkdownUndecodableTextError = MarkdownUndecodableTextError;
120
130
  exports.MarkdownUnsupportedDocumentKindError = MarkdownUnsupportedDocumentKindError;
121
131
  exports.MarkdownWriteError = MarkdownWriteError;
122
132
  exports.NOOP_MARKDOWN_DIAGNOSTIC_SINK = NOOP_MARKDOWN_DIAGNOSTIC_SINK;
@@ -1,2 +1,2 @@
1
- import { a as MarkdownInputTooLargeError, c as MarkdownNestingLimitExceededError, d as MarkdownUnbalancedConstructMarkersError, f as MarkdownUnsupportedDocumentKindError, i as MarkdownDiagnosticSink, l as MarkdownPackageFlattenError, m as NOOP_MARKDOWN_DIAGNOSTIC_SINK, n as MarkdownDiagnosticCodes, o as MarkdownInvalidRunConstructExtentError, p as MarkdownWriteError, r as MarkdownDiagnosticSeverity, s as MarkdownInvalidUtf8Error, t as MarkdownDiagnostic, u as MarkdownParseError } from "../diagnostics-CjfBoW4K.cjs";
2
- export { MarkdownDiagnostic, MarkdownDiagnosticCodes, MarkdownDiagnosticSeverity, MarkdownDiagnosticSink, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownInvalidUtf8Error, MarkdownNestingLimitExceededError, MarkdownPackageFlattenError, MarkdownParseError, MarkdownUnbalancedConstructMarkersError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK };
1
+ import { a as MarkdownInputTooLargeError, c as MarkdownPackageFlattenError, 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-BJtTrxpp.cjs";
2
+ export { MarkdownDiagnostic, MarkdownDiagnosticCodes, MarkdownDiagnosticSeverity, MarkdownDiagnosticSink, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownNestingLimitExceededError, MarkdownPackageFlattenError, MarkdownParseError, MarkdownTableGridFaultError, MarkdownUnbalancedConstructMarkersError, MarkdownUndecodableTextError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK };
@@ -1,2 +1,2 @@
1
- import { a as MarkdownInputTooLargeError, c as MarkdownNestingLimitExceededError, d as MarkdownUnbalancedConstructMarkersError, f as MarkdownUnsupportedDocumentKindError, i as MarkdownDiagnosticSink, l as MarkdownPackageFlattenError, m as NOOP_MARKDOWN_DIAGNOSTIC_SINK, n as MarkdownDiagnosticCodes, o as MarkdownInvalidRunConstructExtentError, p as MarkdownWriteError, r as MarkdownDiagnosticSeverity, s as MarkdownInvalidUtf8Error, t as MarkdownDiagnostic, u as MarkdownParseError } from "../diagnostics-CjfBoW4K.js";
2
- export { MarkdownDiagnostic, MarkdownDiagnosticCodes, MarkdownDiagnosticSeverity, MarkdownDiagnosticSink, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownInvalidUtf8Error, MarkdownNestingLimitExceededError, MarkdownPackageFlattenError, MarkdownParseError, MarkdownUnbalancedConstructMarkersError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK };
1
+ import { a as MarkdownInputTooLargeError, c as MarkdownPackageFlattenError, 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-BJtTrxpp.js";
2
+ export { MarkdownDiagnostic, MarkdownDiagnosticCodes, MarkdownDiagnosticSeverity, MarkdownDiagnosticSink, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownNestingLimitExceededError, MarkdownPackageFlattenError, MarkdownParseError, MarkdownTableGridFaultError, MarkdownUnbalancedConstructMarkersError, MarkdownUndecodableTextError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK };
@@ -1,3 +1,4 @@
1
+ import { describeTableGridFault } from "document-schema.js";
1
2
  //#region src/diagnostics/diagnostics.ts
2
3
  const NOOP_MARKDOWN_DIAGNOSTIC_SINK = () => {};
3
4
  const MarkdownDiagnosticCodes = {
@@ -40,10 +41,10 @@ var MarkdownParseError = class extends Error {
40
41
  this.code = code;
41
42
  }
42
43
  };
43
- var MarkdownInvalidUtf8Error = class extends MarkdownParseError {
44
- constructor(message = "input is not valid UTF-8") {
45
- super("md/invalid-utf8", message);
46
- this.name = "MarkdownInvalidUtf8Error";
44
+ var MarkdownUndecodableTextError = class extends MarkdownParseError {
45
+ constructor(message = "input does not decode as text under any supported encoding") {
46
+ super("md/undecodable-text", message);
47
+ this.name = "MarkdownUndecodableTextError";
47
48
  }
48
49
  };
49
50
  var MarkdownInputTooLargeError = class extends MarkdownParseError {
@@ -82,6 +83,14 @@ var MarkdownUnbalancedConstructMarkersError = class extends MarkdownWriteError {
82
83
  this.blockIndex = blockIndex;
83
84
  }
84
85
  };
86
+ var MarkdownTableGridFaultError = class extends MarkdownWriteError {
87
+ fault;
88
+ constructor(fault) {
89
+ super("md/table-grid-fault", `a table breaks the grid rule: ${describeTableGridFault(fault)}`);
90
+ this.name = "MarkdownTableGridFaultError";
91
+ this.fault = fault;
92
+ }
93
+ };
85
94
  var MarkdownInvalidRunConstructExtentError = class extends MarkdownWriteError {
86
95
  faultKind;
87
96
  entryIndex;
@@ -108,4 +117,4 @@ var MarkdownPackageFlattenError = class extends MarkdownWriteError {
108
117
  }
109
118
  };
110
119
  //#endregion
111
- export { MarkdownDiagnosticCodes, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownInvalidUtf8Error, MarkdownNestingLimitExceededError, MarkdownPackageFlattenError, MarkdownParseError, MarkdownUnbalancedConstructMarkersError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK };
120
+ export { MarkdownDiagnosticCodes, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownNestingLimitExceededError, MarkdownPackageFlattenError, MarkdownParseError, MarkdownTableGridFaultError, MarkdownUnbalancedConstructMarkersError, MarkdownUndecodableTextError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK };
@@ -1,3 +1,4 @@
1
+ import { TableGridFault } from "document-schema.js";
1
2
  //#region src/diagnostics/diagnostics.d.ts
2
3
  type MarkdownDiagnosticSeverity = "info" | "warning";
3
4
  interface MarkdownDiagnostic {
@@ -44,7 +45,7 @@ declare class MarkdownParseError extends Error {
44
45
  readonly code: string;
45
46
  constructor(code: string, message: string);
46
47
  }
47
- declare class MarkdownInvalidUtf8Error extends MarkdownParseError {
48
+ declare class MarkdownUndecodableTextError extends MarkdownParseError {
48
49
  constructor(message?: string);
49
50
  }
50
51
  declare class MarkdownInputTooLargeError extends MarkdownParseError {
@@ -65,6 +66,10 @@ declare class MarkdownUnbalancedConstructMarkersError extends MarkdownWriteError
65
66
  readonly blockIndex: number;
66
67
  constructor(imbalanceKind: "unmatchedEnd" | "unclosedStart", blockIndex: number);
67
68
  }
69
+ declare class MarkdownTableGridFaultError extends MarkdownWriteError {
70
+ readonly fault: TableGridFault;
71
+ constructor(fault: TableGridFault);
72
+ }
68
73
  declare class MarkdownInvalidRunConstructExtentError extends MarkdownWriteError {
69
74
  readonly faultKind: "invertedRange" | "beyondRuns";
70
75
  readonly entryIndex: number;
@@ -78,4 +83,4 @@ declare class MarkdownPackageFlattenError extends MarkdownWriteError {
78
83
  constructor(cause: unknown);
79
84
  }
80
85
  //#endregion
81
- export { MarkdownInputTooLargeError as a, MarkdownNestingLimitExceededError as c, MarkdownUnbalancedConstructMarkersError as d, MarkdownUnsupportedDocumentKindError as f, MarkdownDiagnosticSink as i, MarkdownPackageFlattenError as l, NOOP_MARKDOWN_DIAGNOSTIC_SINK as m, MarkdownDiagnosticCodes as n, MarkdownInvalidRunConstructExtentError as o, MarkdownWriteError as p, MarkdownDiagnosticSeverity as r, MarkdownInvalidUtf8Error as s, MarkdownDiagnostic as t, MarkdownParseError as u };
86
+ export { MarkdownInputTooLargeError as a, MarkdownPackageFlattenError as c, MarkdownUnbalancedConstructMarkersError as d, MarkdownUndecodableTextError as f, NOOP_MARKDOWN_DIAGNOSTIC_SINK as h, MarkdownDiagnosticSink as i, MarkdownParseError as l, MarkdownWriteError as m, MarkdownDiagnosticCodes as n, MarkdownInvalidRunConstructExtentError as o, MarkdownUnsupportedDocumentKindError as p, MarkdownDiagnosticSeverity as r, MarkdownNestingLimitExceededError as s, MarkdownDiagnostic as t, MarkdownTableGridFaultError as u };
@@ -1,3 +1,4 @@
1
+ import { TableGridFault } from "document-schema.js";
1
2
  //#region src/diagnostics/diagnostics.d.ts
2
3
  type MarkdownDiagnosticSeverity = "info" | "warning";
3
4
  interface MarkdownDiagnostic {
@@ -44,7 +45,7 @@ declare class MarkdownParseError extends Error {
44
45
  readonly code: string;
45
46
  constructor(code: string, message: string);
46
47
  }
47
- declare class MarkdownInvalidUtf8Error extends MarkdownParseError {
48
+ declare class MarkdownUndecodableTextError extends MarkdownParseError {
48
49
  constructor(message?: string);
49
50
  }
50
51
  declare class MarkdownInputTooLargeError extends MarkdownParseError {
@@ -65,6 +66,10 @@ declare class MarkdownUnbalancedConstructMarkersError extends MarkdownWriteError
65
66
  readonly blockIndex: number;
66
67
  constructor(imbalanceKind: "unmatchedEnd" | "unclosedStart", blockIndex: number);
67
68
  }
69
+ declare class MarkdownTableGridFaultError extends MarkdownWriteError {
70
+ readonly fault: TableGridFault;
71
+ constructor(fault: TableGridFault);
72
+ }
68
73
  declare class MarkdownInvalidRunConstructExtentError extends MarkdownWriteError {
69
74
  readonly faultKind: "invertedRange" | "beyondRuns";
70
75
  readonly entryIndex: number;
@@ -78,4 +83,4 @@ declare class MarkdownPackageFlattenError extends MarkdownWriteError {
78
83
  constructor(cause: unknown);
79
84
  }
80
85
  //#endregion
81
- export { MarkdownInputTooLargeError as a, MarkdownNestingLimitExceededError as c, MarkdownUnbalancedConstructMarkersError as d, MarkdownUnsupportedDocumentKindError as f, MarkdownDiagnosticSink as i, MarkdownPackageFlattenError as l, NOOP_MARKDOWN_DIAGNOSTIC_SINK as m, MarkdownDiagnosticCodes as n, MarkdownInvalidRunConstructExtentError as o, MarkdownWriteError as p, MarkdownDiagnosticSeverity as r, MarkdownInvalidUtf8Error as s, MarkdownDiagnostic as t, MarkdownParseError as u };
86
+ export { MarkdownInputTooLargeError as a, MarkdownPackageFlattenError as c, MarkdownUnbalancedConstructMarkersError as d, MarkdownUndecodableTextError as f, NOOP_MARKDOWN_DIAGNOSTIC_SINK as h, MarkdownDiagnosticSink as i, MarkdownParseError as l, MarkdownWriteError as m, MarkdownDiagnosticCodes as n, MarkdownInvalidRunConstructExtentError as o, MarkdownUnsupportedDocumentKindError as p, MarkdownDiagnosticSeverity as r, MarkdownNestingLimitExceededError as s, MarkdownDiagnostic as t, MarkdownTableGridFaultError as u };
@@ -91,7 +91,15 @@ function emitCellTag(cell, isHeader, context) {
91
91
  if (styleParts.length > 0) attrs.push(`style="${escapeHtmlAttribute(styleParts.join(";"))}"`);
92
92
  return `<${tag}${attrs.length > 0 ? ` ${attrs.join(" ")}` : ""}>${emitCellHtml(cell, context)}</${tag}>`;
93
93
  }
94
+ /**
95
+ * Throws MarkdownTableGridFaultError when `table` breaks the grid rule. Both table renderers run it before writing anything: a pipe row and an HTML row alike state one cell per anchor, so a table whose covered positions hold content or whose rows disagree about the grid has no faithful rendering in either.
96
+ */
97
+ function assertTableObeysGridRule(table) {
98
+ const fault = (0, document_schema_js.findTableGridFault)(table);
99
+ if (fault !== void 0) throw new require_diagnostics_diagnostics.MarkdownTableGridFaultError(fault);
100
+ }
94
101
  function emitHtmlTable(table, context) {
102
+ assertTableObeysGridRule(table);
95
103
  return [
96
104
  "<table>",
97
105
  ...(0, document_schema_js.walkTableGrid)(table).map((positions, rowIndex) => {
@@ -101,5 +109,6 @@ function emitHtmlTable(table, context) {
101
109
  ].join("\n");
102
110
  }
103
111
  //#endregion
112
+ exports.assertTableObeysGridRule = assertTableObeysGridRule;
104
113
  exports.emitHtmlTable = emitHtmlTable;
105
114
  exports.tableNeedsHtmlFallback = tableNeedsHtmlFallback;
@@ -2,6 +2,10 @@ import { TableEmitContext } from "./table.cjs";
2
2
  import { ContentTable } from "document-schema.js";
3
3
  //#region src/emit/html-table.d.ts
4
4
  declare function tableNeedsHtmlFallback(table: ContentTable): boolean;
5
+ /**
6
+ * Throws MarkdownTableGridFaultError when `table` breaks the grid rule. Both table renderers run it before writing anything: a pipe row and an HTML row alike state one cell per anchor, so a table whose covered positions hold content or whose rows disagree about the grid has no faithful rendering in either.
7
+ */
8
+ declare function assertTableObeysGridRule(table: ContentTable): void;
5
9
  declare function emitHtmlTable(table: ContentTable, context: TableEmitContext): string;
6
10
  //#endregion
7
- export { emitHtmlTable, tableNeedsHtmlFallback };
11
+ export { assertTableObeysGridRule, emitHtmlTable, tableNeedsHtmlFallback };
@@ -2,6 +2,10 @@ import { TableEmitContext } from "./table.js";
2
2
  import { ContentTable } from "document-schema.js";
3
3
  //#region src/emit/html-table.d.ts
4
4
  declare function tableNeedsHtmlFallback(table: ContentTable): boolean;
5
+ /**
6
+ * Throws MarkdownTableGridFaultError when `table` breaks the grid rule. Both table renderers run it before writing anything: a pipe row and an HTML row alike state one cell per anchor, so a table whose covered positions hold content or whose rows disagree about the grid has no faithful rendering in either.
7
+ */
8
+ declare function assertTableObeysGridRule(table: ContentTable): void;
5
9
  declare function emitHtmlTable(table: ContentTable, context: TableEmitContext): string;
6
10
  //#endregion
7
- export { emitHtmlTable, tableNeedsHtmlFallback };
11
+ export { assertTableObeysGridRule, emitHtmlTable, tableNeedsHtmlFallback };
@@ -1,6 +1,6 @@
1
- import { MarkdownDiagnosticCodes } from "../diagnostics/diagnostics.js";
1
+ import { MarkdownDiagnosticCodes, MarkdownTableGridFaultError } from "../diagnostics/diagnostics.js";
2
2
  import "../shared/style-constants.js";
3
- import { colorToRgbHex, walkTableGrid } from "document-schema.js";
3
+ import { colorToRgbHex, findTableGridFault, walkTableGrid } from "document-schema.js";
4
4
  //#region src/emit/html-table.ts
5
5
  function escapeHtmlText(text) {
6
6
  return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
@@ -90,7 +90,15 @@ function emitCellTag(cell, isHeader, context) {
90
90
  if (styleParts.length > 0) attrs.push(`style="${escapeHtmlAttribute(styleParts.join(";"))}"`);
91
91
  return `<${tag}${attrs.length > 0 ? ` ${attrs.join(" ")}` : ""}>${emitCellHtml(cell, context)}</${tag}>`;
92
92
  }
93
+ /**
94
+ * Throws MarkdownTableGridFaultError when `table` breaks the grid rule. Both table renderers run it before writing anything: a pipe row and an HTML row alike state one cell per anchor, so a table whose covered positions hold content or whose rows disagree about the grid has no faithful rendering in either.
95
+ */
96
+ function assertTableObeysGridRule(table) {
97
+ const fault = findTableGridFault(table);
98
+ if (fault !== void 0) throw new MarkdownTableGridFaultError(fault);
99
+ }
93
100
  function emitHtmlTable(table, context) {
101
+ assertTableObeysGridRule(table);
94
102
  return [
95
103
  "<table>",
96
104
  ...walkTableGrid(table).map((positions, rowIndex) => {
@@ -100,4 +108,4 @@ function emitHtmlTable(table, context) {
100
108
  ].join("\n");
101
109
  }
102
110
  //#endregion
103
- export { emitHtmlTable, tableNeedsHtmlFallback };
111
+ export { assertTableObeysGridRule, emitHtmlTable, tableNeedsHtmlFallback };
@@ -1,2 +1,2 @@
1
- import { a as escapeMarkdownText, i as escapeLinkDestination, n as emitRuns, o as renderLinkTitle, r as emitRunsSingleLine, t as InlineEmitContext } from "../inline-DCIKQ83j.cjs";
1
+ import { a as escapeMarkdownText, i as escapeLinkDestination, n as emitRuns, o as renderLinkTitle, r as emitRunsSingleLine, t as InlineEmitContext } from "../inline-C8ObWyKW.cjs";
2
2
  export { InlineEmitContext, emitRuns, emitRunsSingleLine, escapeLinkDestination, escapeMarkdownText, renderLinkTitle };
@@ -1,2 +1,2 @@
1
- import { a as escapeMarkdownText, i as escapeLinkDestination, n as emitRuns, o as renderLinkTitle, r as emitRunsSingleLine, t as InlineEmitContext } from "../inline-INoDAG37.js";
1
+ import { a as escapeMarkdownText, i as escapeLinkDestination, n as emitRuns, o as renderLinkTitle, r as emitRunsSingleLine, t as InlineEmitContext } from "../inline-XJ4cdpPz.js";
2
2
  export { InlineEmitContext, emitRuns, emitRunsSingleLine, escapeLinkDestination, escapeMarkdownText, renderLinkTitle };
@@ -67,6 +67,7 @@ function emitTable(table, context) {
67
67
  });
68
68
  return require_emit_html_table.emitHtmlTable(table, context);
69
69
  }
70
+ require_emit_html_table.assertTableObeysGridRule(table);
70
71
  const [header, ...body] = table.rows;
71
72
  if (header === void 0) return "";
72
73
  const alignments = header.cells.map((cell) => toMarkdownAlignment(cell.blocks[0]?.kind === "paragraph" ? cell.blocks[0].alignment : void 0));
@@ -1,5 +1,5 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.cjs";
2
- import { t as InlineEmitContext } from "../inline-DCIKQ83j.cjs";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.cjs";
2
+ import { t as InlineEmitContext } from "../inline-C8ObWyKW.cjs";
3
3
  import { ContentTable } from "document-schema.js";
4
4
  //#region src/emit/table.d.ts
5
5
  interface TableEmitContext extends InlineEmitContext {
@@ -1,5 +1,5 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.js";
2
- import { t as InlineEmitContext } from "../inline-INoDAG37.js";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.js";
2
+ import { t as InlineEmitContext } from "../inline-XJ4cdpPz.js";
3
3
  import { ContentTable } from "document-schema.js";
4
4
  //#region src/emit/table.d.ts
5
5
  interface TableEmitContext extends InlineEmitContext {
@@ -1,7 +1,7 @@
1
1
  import { MarkdownDiagnosticCodes } from "../diagnostics/diagnostics.js";
2
2
  import { emitRunsSingleLine } from "./inline.js";
3
3
  import { emitImage } from "./image.js";
4
- import { emitHtmlTable, tableNeedsHtmlFallback } from "./html-table.js";
4
+ import { assertTableObeysGridRule, emitHtmlTable, tableNeedsHtmlFallback } from "./html-table.js";
5
5
  //#region src/emit/table.ts
6
6
  function toMarkdownAlignment(alignment) {
7
7
  return alignment === void 0 || alignment === "justify" ? "none" : alignment;
@@ -66,6 +66,7 @@ function emitTable(table, context) {
66
66
  });
67
67
  return emitHtmlTable(table, context);
68
68
  }
69
+ assertTableObeysGridRule(table);
69
70
  const [header, ...body] = table.rows;
70
71
  if (header === void 0) return "";
71
72
  const alignments = header.cells.map((cell) => toMarkdownAlignment(cell.blocks[0]?.kind === "paragraph" ? cell.blocks[0].alignment : void 0));
package/dist/index.cjs CHANGED
@@ -14,10 +14,11 @@ exports.MarkdownBytesSchema = require_codec.MarkdownBytesSchema;
14
14
  exports.MarkdownDiagnosticCodes = require_diagnostics_diagnostics.MarkdownDiagnosticCodes;
15
15
  exports.MarkdownInputTooLargeError = require_diagnostics_diagnostics.MarkdownInputTooLargeError;
16
16
  exports.MarkdownInvalidRunConstructExtentError = require_diagnostics_diagnostics.MarkdownInvalidRunConstructExtentError;
17
- exports.MarkdownInvalidUtf8Error = require_diagnostics_diagnostics.MarkdownInvalidUtf8Error;
18
17
  exports.MarkdownNestingLimitExceededError = require_diagnostics_diagnostics.MarkdownNestingLimitExceededError;
19
18
  exports.MarkdownParseError = require_diagnostics_diagnostics.MarkdownParseError;
19
+ exports.MarkdownTableGridFaultError = require_diagnostics_diagnostics.MarkdownTableGridFaultError;
20
20
  exports.MarkdownUnbalancedConstructMarkersError = require_diagnostics_diagnostics.MarkdownUnbalancedConstructMarkersError;
21
+ exports.MarkdownUndecodableTextError = require_diagnostics_diagnostics.MarkdownUndecodableTextError;
21
22
  exports.MarkdownUnsupportedDocumentKindError = require_diagnostics_diagnostics.MarkdownUnsupportedDocumentKindError;
22
23
  exports.MarkdownWriteError = require_diagnostics_diagnostics.MarkdownWriteError;
23
24
  exports.NOOP_MARKDOWN_DIAGNOSTIC_SINK = require_diagnostics_diagnostics.NOOP_MARKDOWN_DIAGNOSTIC_SINK;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as MarkdownInputTooLargeError, c as MarkdownNestingLimitExceededError, d as MarkdownUnbalancedConstructMarkersError, f as MarkdownUnsupportedDocumentKindError, i as MarkdownDiagnosticSink, m as NOOP_MARKDOWN_DIAGNOSTIC_SINK, n as MarkdownDiagnosticCodes, o as MarkdownInvalidRunConstructExtentError, p as MarkdownWriteError, r as MarkdownDiagnosticSeverity, s as MarkdownInvalidUtf8Error, t as MarkdownDiagnostic, u as MarkdownParseError } from "./diagnostics-CjfBoW4K.cjs";
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-BJtTrxpp.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
4
  import { MarkdownBulletListMarker, MarkdownCodeFenceChar, MarkdownEmphasisMarker, MarkdownHeadingStyle, MarkdownLineEnding, MarkdownOrderedListDelimiter, MarkdownThematicBreakChar, ReadMarkdownOptions, WriteMarkdownOptions, WriteMarkdownStyleOptions } from "./options/options.cjs";
@@ -6,4 +6,4 @@ import { ReadMarkdownContentResult, ReadMarkdownResult, readMarkdown, readMarkdo
6
6
  import { writeMarkdown, writeMarkdownContent } from "./write.cjs";
7
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
- 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, MarkdownInvalidUtf8Error, type MarkdownLineEnding, MarkdownNestingLimitExceededError, type MarkdownOrderedListDelimiter, MarkdownParseError, type MarkdownResolvedImageBytes, type MarkdownThematicBreakChar, MarkdownUnbalancedConstructMarkersError, 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 };
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,4 +1,4 @@
1
- import { a as MarkdownInputTooLargeError, c as MarkdownNestingLimitExceededError, d as MarkdownUnbalancedConstructMarkersError, f as MarkdownUnsupportedDocumentKindError, i as MarkdownDiagnosticSink, m as NOOP_MARKDOWN_DIAGNOSTIC_SINK, n as MarkdownDiagnosticCodes, o as MarkdownInvalidRunConstructExtentError, p as MarkdownWriteError, r as MarkdownDiagnosticSeverity, s as MarkdownInvalidUtf8Error, t as MarkdownDiagnostic, u as MarkdownParseError } from "./diagnostics-CjfBoW4K.js";
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-BJtTrxpp.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
4
  import { MarkdownBulletListMarker, MarkdownCodeFenceChar, MarkdownEmphasisMarker, MarkdownHeadingStyle, MarkdownLineEnding, MarkdownOrderedListDelimiter, MarkdownThematicBreakChar, ReadMarkdownOptions, WriteMarkdownOptions, WriteMarkdownStyleOptions } from "./options/options.js";
@@ -6,4 +6,4 @@ import { ReadMarkdownContentResult, ReadMarkdownResult, readMarkdown, readMarkdo
6
6
  import { writeMarkdown, writeMarkdownContent } from "./write.js";
7
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
- 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, MarkdownInvalidUtf8Error, type MarkdownLineEnding, MarkdownNestingLimitExceededError, type MarkdownOrderedListDelimiter, MarkdownParseError, type MarkdownResolvedImageBytes, type MarkdownThematicBreakChar, MarkdownUnbalancedConstructMarkersError, 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 };
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.js CHANGED
@@ -1,7 +1,7 @@
1
- import { MarkdownDiagnosticCodes, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownInvalidUtf8Error, MarkdownNestingLimitExceededError, MarkdownParseError, MarkdownUnbalancedConstructMarkersError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK } from "./diagnostics/diagnostics.js";
1
+ import { MarkdownDiagnosticCodes, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownNestingLimitExceededError, MarkdownParseError, MarkdownTableGridFaultError, MarkdownUnbalancedConstructMarkersError, MarkdownUndecodableTextError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK } from "./diagnostics/diagnostics.js";
2
2
  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";
3
3
  import { createNumIdMintState, mintListNumId, mintedListType, parseListNumId } from "./shared/list-id.js";
4
4
  import { readMarkdown, readMarkdownContent } from "./read.js";
5
5
  import { writeMarkdown, writeMarkdownContent } from "./write.js";
6
6
  import { MarkdownBytesSchema, markdownCodec, markdownContentCodec } from "./codec.js";
7
- export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, MarkdownBytesSchema, MarkdownDiagnosticCodes, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownInvalidUtf8Error, MarkdownNestingLimitExceededError, MarkdownParseError, MarkdownUnbalancedConstructMarkersError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK, QUOTE_INDENT_PT, QUOTE_STYLE_ID, createNumIdMintState, headingStyleId, markdownCodec, markdownContentCodec, mintListNumId, mintedListType, parseHeadingStyleId, parseListNumId, readMarkdown, readMarkdownContent, writeMarkdown, writeMarkdownContent };
7
+ export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, MarkdownBytesSchema, MarkdownDiagnosticCodes, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownNestingLimitExceededError, MarkdownParseError, MarkdownTableGridFaultError, MarkdownUnbalancedConstructMarkersError, MarkdownUndecodableTextError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK, QUOTE_INDENT_PT, QUOTE_STYLE_ID, createNumIdMintState, headingStyleId, markdownCodec, markdownContentCodec, mintListNumId, mintedListType, parseHeadingStyleId, parseListNumId, readMarkdown, readMarkdownContent, writeMarkdown, writeMarkdownContent };
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "./diagnostics-CjfBoW4K.cjs";
1
+ import { i as MarkdownDiagnosticSink } from "./diagnostics-BJtTrxpp.cjs";
2
2
  import { ContentRun, RunConstructExtent } from "document-schema.js";
3
3
  //#region src/emit/inline.d.ts
4
4
  interface InlineEmitContext {
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "./diagnostics-CjfBoW4K.js";
1
+ import { i as MarkdownDiagnosticSink } from "./diagnostics-BJtTrxpp.js";
2
2
  import { ContentRun, RunConstructExtent } from "document-schema.js";
3
3
  //#region src/emit/inline.d.ts
4
4
  interface InlineEmitContext {
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.cjs";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.cjs";
2
2
  import { LayoutMetadata } from "document-schema.js";
3
3
  //#region src/lower/front-matter.d.ts
4
4
  interface FrontMatterResult {
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.js";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.js";
2
2
  import { LayoutMetadata } from "document-schema.js";
3
3
  //#region src/lower/front-matter.d.ts
4
4
  interface FrontMatterResult {
@@ -1,5 +1,5 @@
1
1
  import { v as MarkdownInlineNode } from "../ast-CNfTgS0N.cjs";
2
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.cjs";
2
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.cjs";
3
3
  import { ContentRun, RunConstructExtent } from "document-schema.js";
4
4
  //#region src/lower/inline.d.ts
5
5
  interface InlineLowerContext {
@@ -1,5 +1,5 @@
1
1
  import { v as MarkdownInlineNode } from "../ast-CNfTgS0N.js";
2
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.js";
2
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.js";
3
3
  import { ContentRun, RunConstructExtent } from "document-schema.js";
4
4
  //#region src/lower/inline.d.ts
5
5
  interface InlineLowerContext {
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.cjs";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.cjs";
2
2
  import { n as MarkdownImageResolver } from "../image-B6p0Ovgy.cjs";
3
3
  import { Margins, PageSize } from "document-schema.js";
4
4
  //#region src/options/options.d.ts
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-CjfBoW4K.js";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-BJtTrxpp.js";
2
2
  import { n as MarkdownImageResolver } from "../image-gR1vISI0.js";
3
3
  import { Margins, PageSize } from "document-schema.js";
4
4
  //#region src/options/options.d.ts
package/dist/read.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as MarkdownDiagnostic } from "./diagnostics-CjfBoW4K.cjs";
1
+ import { t as MarkdownDiagnostic } from "./diagnostics-BJtTrxpp.cjs";
2
2
  import { ReadMarkdownOptions } from "./options/options.cjs";
3
3
  import { ContentDocument, DocumentTree } from "document-schema.js";
4
4
  //#region src/read.d.ts
package/dist/read.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as MarkdownDiagnostic } from "./diagnostics-CjfBoW4K.js";
1
+ import { t as MarkdownDiagnostic } from "./diagnostics-BJtTrxpp.js";
2
2
  import { ReadMarkdownOptions } from "./options/options.js";
3
3
  import { ContentDocument, DocumentTree } from "document-schema.js";
4
4
  //#region src/read.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mrkdwn.js",
3
- "version": "8.0.1",
3
+ "version": "10.0.0",
4
4
  "description": "Hand-written CommonMark+GFM <-> DocumentTree codec, built on document-schema.js",
5
5
  "type": "module",
6
6
  "repository": {
@@ -57,7 +57,7 @@
57
57
  "license": "MIT",
58
58
  "dependencies": {
59
59
  "byte-codec": "1.7.0",
60
- "document-schema.js": "7.12.0",
60
+ "document-schema.js": "7.13.0",
61
61
  "zod": "4.4.3"
62
62
  },
63
63
  "devDependencies": {