markdown-codec 9.0.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/block/block.d.cts +1 -1
- package/dist/block/block.d.ts +1 -1
- package/dist/block/definitions.d.cts +1 -1
- package/dist/block/definitions.d.ts +1 -1
- package/dist/codec.cjs +4 -11
- package/dist/codec.js +4 -11
- package/dist/diagnostics/diagnostics.cjs +7 -6
- package/dist/diagnostics/diagnostics.d.cts +2 -2
- package/dist/diagnostics/diagnostics.d.ts +2 -2
- package/dist/diagnostics/diagnostics.js +7 -6
- package/dist/{diagnostics-Dzg9Nl9H.d.cts → diagnostics-DpAXEzZP.d.cts} +3 -2
- package/dist/{diagnostics-Dzg9Nl9H.d.ts → diagnostics-DpAXEzZP.d.ts} +3 -2
- package/dist/emit/html-table.cjs +6 -2
- package/dist/emit/html-table.js +6 -2
- package/dist/emit/inline.d.cts +1 -1
- package/dist/emit/inline.d.ts +1 -1
- package/dist/emit/table.cjs +5 -0
- package/dist/emit/table.d.cts +2 -2
- package/dist/emit/table.d.ts +2 -2
- package/dist/emit/table.js +5 -0
- package/dist/html/html-table.cjs +9 -3
- package/dist/html/html-table.js +9 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{inline-DwGatpGm.d.ts → inline-BJj81pYp.d.ts} +1 -1
- package/dist/{inline-C2130eAp.d.cts → inline-DD4bcJFT.d.cts} +1 -1
- package/dist/lower/front-matter.d.cts +1 -1
- package/dist/lower/front-matter.d.ts +1 -1
- package/dist/lower/inline.d.cts +1 -1
- package/dist/lower/inline.d.ts +1 -1
- package/dist/lower/table.cjs +4 -1
- package/dist/lower/table.js +4 -1
- package/dist/options/options.d.cts +1 -1
- package/dist/options/options.d.ts +1 -1
- package/dist/read.d.cts +1 -1
- package/dist/read.d.ts +1 -1
- package/package.json +3 -3
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
|
|
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
|
|
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
|
|
package/dist/block/block.d.cts
CHANGED
|
@@ -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-
|
|
3
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.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
|
package/dist/block/block.d.ts
CHANGED
|
@@ -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-
|
|
3
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.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-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.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-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.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
|
-
|
|
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(
|
|
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(
|
|
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.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
|
-
|
|
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(
|
|
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(
|
|
13
|
+
decode: (bytes) => readMarkdownContent(decodeText(bytes).text).document,
|
|
21
14
|
encode: (document) => new TextEncoder().encode(writeMarkdownContent(document))
|
|
22
15
|
});
|
|
23
16
|
//#endregion
|
|
@@ -32,7 +32,8 @@ const MarkdownDiagnosticCodes = {
|
|
|
32
32
|
TABLE_CELL_FORMATTING_DROPPED: "md/table-cell-formatting-dropped",
|
|
33
33
|
TABLE_CELL_MULTI_PARAGRAPH_JOINED: "md/table-cell-multi-paragraph-joined",
|
|
34
34
|
TABLE_CELL_IMAGE_DEGRADED: "md/table-cell-image-degraded",
|
|
35
|
-
TABLE_HTML_FALLBACK: "md/table-html-fallback"
|
|
35
|
+
TABLE_HTML_FALLBACK: "md/table-html-fallback",
|
|
36
|
+
TABLE_HEADER_ROW_SYNTHESISED: "md/table-header-row-synthesised"
|
|
36
37
|
};
|
|
37
38
|
var MarkdownParseError = class extends Error {
|
|
38
39
|
code;
|
|
@@ -42,10 +43,10 @@ var MarkdownParseError = class extends Error {
|
|
|
42
43
|
this.code = code;
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
|
-
var
|
|
46
|
-
constructor(message = "input
|
|
47
|
-
super("md/
|
|
48
|
-
this.name = "
|
|
46
|
+
var MarkdownUndecodableTextError = class extends MarkdownParseError {
|
|
47
|
+
constructor(message = "input does not decode as text under any supported encoding") {
|
|
48
|
+
super("md/undecodable-text", message);
|
|
49
|
+
this.name = "MarkdownUndecodableTextError";
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
52
|
var MarkdownInputTooLargeError = class extends MarkdownParseError {
|
|
@@ -121,12 +122,12 @@ var MarkdownPackageFlattenError = class extends MarkdownWriteError {
|
|
|
121
122
|
exports.MarkdownDiagnosticCodes = MarkdownDiagnosticCodes;
|
|
122
123
|
exports.MarkdownInputTooLargeError = MarkdownInputTooLargeError;
|
|
123
124
|
exports.MarkdownInvalidRunConstructExtentError = MarkdownInvalidRunConstructExtentError;
|
|
124
|
-
exports.MarkdownInvalidUtf8Error = MarkdownInvalidUtf8Error;
|
|
125
125
|
exports.MarkdownNestingLimitExceededError = MarkdownNestingLimitExceededError;
|
|
126
126
|
exports.MarkdownPackageFlattenError = MarkdownPackageFlattenError;
|
|
127
127
|
exports.MarkdownParseError = MarkdownParseError;
|
|
128
128
|
exports.MarkdownTableGridFaultError = MarkdownTableGridFaultError;
|
|
129
129
|
exports.MarkdownUnbalancedConstructMarkersError = MarkdownUnbalancedConstructMarkersError;
|
|
130
|
+
exports.MarkdownUndecodableTextError = MarkdownUndecodableTextError;
|
|
130
131
|
exports.MarkdownUnsupportedDocumentKindError = MarkdownUnsupportedDocumentKindError;
|
|
131
132
|
exports.MarkdownWriteError = MarkdownWriteError;
|
|
132
133
|
exports.NOOP_MARKDOWN_DIAGNOSTIC_SINK = NOOP_MARKDOWN_DIAGNOSTIC_SINK;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MarkdownInputTooLargeError, c as
|
|
2
|
-
export { MarkdownDiagnostic, MarkdownDiagnosticCodes, MarkdownDiagnosticSeverity, MarkdownDiagnosticSink, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError,
|
|
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-DpAXEzZP.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
|
|
2
|
-
export { MarkdownDiagnostic, MarkdownDiagnosticCodes, MarkdownDiagnosticSeverity, MarkdownDiagnosticSink, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError,
|
|
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-DpAXEzZP.js";
|
|
2
|
+
export { MarkdownDiagnostic, MarkdownDiagnosticCodes, MarkdownDiagnosticSeverity, MarkdownDiagnosticSink, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownNestingLimitExceededError, MarkdownPackageFlattenError, MarkdownParseError, MarkdownTableGridFaultError, MarkdownUnbalancedConstructMarkersError, MarkdownUndecodableTextError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK };
|
|
@@ -31,7 +31,8 @@ const MarkdownDiagnosticCodes = {
|
|
|
31
31
|
TABLE_CELL_FORMATTING_DROPPED: "md/table-cell-formatting-dropped",
|
|
32
32
|
TABLE_CELL_MULTI_PARAGRAPH_JOINED: "md/table-cell-multi-paragraph-joined",
|
|
33
33
|
TABLE_CELL_IMAGE_DEGRADED: "md/table-cell-image-degraded",
|
|
34
|
-
TABLE_HTML_FALLBACK: "md/table-html-fallback"
|
|
34
|
+
TABLE_HTML_FALLBACK: "md/table-html-fallback",
|
|
35
|
+
TABLE_HEADER_ROW_SYNTHESISED: "md/table-header-row-synthesised"
|
|
35
36
|
};
|
|
36
37
|
var MarkdownParseError = class extends Error {
|
|
37
38
|
code;
|
|
@@ -41,10 +42,10 @@ var MarkdownParseError = class extends Error {
|
|
|
41
42
|
this.code = code;
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
|
-
var
|
|
45
|
-
constructor(message = "input
|
|
46
|
-
super("md/
|
|
47
|
-
this.name = "
|
|
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 {
|
|
@@ -117,4 +118,4 @@ var MarkdownPackageFlattenError = class extends MarkdownWriteError {
|
|
|
117
118
|
}
|
|
118
119
|
};
|
|
119
120
|
//#endregion
|
|
120
|
-
export { MarkdownDiagnosticCodes, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError,
|
|
121
|
+
export { MarkdownDiagnosticCodes, MarkdownInputTooLargeError, MarkdownInvalidRunConstructExtentError, MarkdownNestingLimitExceededError, MarkdownPackageFlattenError, MarkdownParseError, MarkdownTableGridFaultError, MarkdownUnbalancedConstructMarkersError, MarkdownUndecodableTextError, MarkdownUnsupportedDocumentKindError, MarkdownWriteError, NOOP_MARKDOWN_DIAGNOSTIC_SINK };
|
|
@@ -40,12 +40,13 @@ declare const MarkdownDiagnosticCodes: {
|
|
|
40
40
|
readonly TABLE_CELL_MULTI_PARAGRAPH_JOINED: "md/table-cell-multi-paragraph-joined";
|
|
41
41
|
readonly TABLE_CELL_IMAGE_DEGRADED: "md/table-cell-image-degraded";
|
|
42
42
|
readonly TABLE_HTML_FALLBACK: "md/table-html-fallback";
|
|
43
|
+
readonly TABLE_HEADER_ROW_SYNTHESISED: "md/table-header-row-synthesised";
|
|
43
44
|
};
|
|
44
45
|
declare class MarkdownParseError extends Error {
|
|
45
46
|
readonly code: string;
|
|
46
47
|
constructor(code: string, message: string);
|
|
47
48
|
}
|
|
48
|
-
declare class
|
|
49
|
+
declare class MarkdownUndecodableTextError extends MarkdownParseError {
|
|
49
50
|
constructor(message?: string);
|
|
50
51
|
}
|
|
51
52
|
declare class MarkdownInputTooLargeError extends MarkdownParseError {
|
|
@@ -83,4 +84,4 @@ declare class MarkdownPackageFlattenError extends MarkdownWriteError {
|
|
|
83
84
|
constructor(cause: unknown);
|
|
84
85
|
}
|
|
85
86
|
//#endregion
|
|
86
|
-
export { MarkdownInputTooLargeError as a,
|
|
87
|
+
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 };
|
|
@@ -40,12 +40,13 @@ declare const MarkdownDiagnosticCodes: {
|
|
|
40
40
|
readonly TABLE_CELL_MULTI_PARAGRAPH_JOINED: "md/table-cell-multi-paragraph-joined";
|
|
41
41
|
readonly TABLE_CELL_IMAGE_DEGRADED: "md/table-cell-image-degraded";
|
|
42
42
|
readonly TABLE_HTML_FALLBACK: "md/table-html-fallback";
|
|
43
|
+
readonly TABLE_HEADER_ROW_SYNTHESISED: "md/table-header-row-synthesised";
|
|
43
44
|
};
|
|
44
45
|
declare class MarkdownParseError extends Error {
|
|
45
46
|
readonly code: string;
|
|
46
47
|
constructor(code: string, message: string);
|
|
47
48
|
}
|
|
48
|
-
declare class
|
|
49
|
+
declare class MarkdownUndecodableTextError extends MarkdownParseError {
|
|
49
50
|
constructor(message?: string);
|
|
50
51
|
}
|
|
51
52
|
declare class MarkdownInputTooLargeError extends MarkdownParseError {
|
|
@@ -83,4 +84,4 @@ declare class MarkdownPackageFlattenError extends MarkdownWriteError {
|
|
|
83
84
|
constructor(cause: unknown);
|
|
84
85
|
}
|
|
85
86
|
//#endregion
|
|
86
|
-
export { MarkdownInputTooLargeError as a,
|
|
87
|
+
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 };
|
package/dist/emit/html-table.cjs
CHANGED
|
@@ -12,8 +12,11 @@ function escapeHtmlAttribute(text) {
|
|
|
12
12
|
function blockNeedsHtmlFallback(block) {
|
|
13
13
|
return block.kind !== "paragraph" && block.kind !== "image";
|
|
14
14
|
}
|
|
15
|
+
function headerRowsNeedHtmlFallback(table) {
|
|
16
|
+
return table.rows.some((row, index) => row.isHeader === true && index > 0);
|
|
17
|
+
}
|
|
15
18
|
function tableNeedsHtmlFallback(table) {
|
|
16
|
-
return table.rows.some((row) => row.cells.some((cell) => cell.colSpan !== void 0 || cell.rowSpan !== void 0 || cell.background !== void 0 || cell.blocks.some(blockNeedsHtmlFallback)));
|
|
19
|
+
return headerRowsNeedHtmlFallback(table) || table.rows.some((row) => row.cells.some((cell) => cell.colSpan !== void 0 || cell.rowSpan !== void 0 || cell.background !== void 0 || cell.blocks.some(blockNeedsHtmlFallback)));
|
|
17
20
|
}
|
|
18
21
|
function emitRunHtml(run) {
|
|
19
22
|
let text = escapeHtmlText(run.text);
|
|
@@ -103,7 +106,8 @@ function emitHtmlTable(table, context) {
|
|
|
103
106
|
return [
|
|
104
107
|
"<table>",
|
|
105
108
|
...(0, document_schema_js.walkTableGrid)(table).map((positions, rowIndex) => {
|
|
106
|
-
|
|
109
|
+
const isHeader = table.rows[rowIndex].isHeader === true;
|
|
110
|
+
return `<tr>${positions.flatMap((position) => position.anchorRowIndex === void 0 ? [emitCellTag(position.cell, isHeader, context)] : []).join("")}</tr>`;
|
|
107
111
|
}),
|
|
108
112
|
"</table>"
|
|
109
113
|
].join("\n");
|
package/dist/emit/html-table.js
CHANGED
|
@@ -11,8 +11,11 @@ function escapeHtmlAttribute(text) {
|
|
|
11
11
|
function blockNeedsHtmlFallback(block) {
|
|
12
12
|
return block.kind !== "paragraph" && block.kind !== "image";
|
|
13
13
|
}
|
|
14
|
+
function headerRowsNeedHtmlFallback(table) {
|
|
15
|
+
return table.rows.some((row, index) => row.isHeader === true && index > 0);
|
|
16
|
+
}
|
|
14
17
|
function tableNeedsHtmlFallback(table) {
|
|
15
|
-
return table.rows.some((row) => row.cells.some((cell) => cell.colSpan !== void 0 || cell.rowSpan !== void 0 || cell.background !== void 0 || cell.blocks.some(blockNeedsHtmlFallback)));
|
|
18
|
+
return headerRowsNeedHtmlFallback(table) || table.rows.some((row) => row.cells.some((cell) => cell.colSpan !== void 0 || cell.rowSpan !== void 0 || cell.background !== void 0 || cell.blocks.some(blockNeedsHtmlFallback)));
|
|
16
19
|
}
|
|
17
20
|
function emitRunHtml(run) {
|
|
18
21
|
let text = escapeHtmlText(run.text);
|
|
@@ -102,7 +105,8 @@ function emitHtmlTable(table, context) {
|
|
|
102
105
|
return [
|
|
103
106
|
"<table>",
|
|
104
107
|
...walkTableGrid(table).map((positions, rowIndex) => {
|
|
105
|
-
|
|
108
|
+
const isHeader = table.rows[rowIndex].isHeader === true;
|
|
109
|
+
return `<tr>${positions.flatMap((position) => position.anchorRowIndex === void 0 ? [emitCellTag(position.cell, isHeader, context)] : []).join("")}</tr>`;
|
|
106
110
|
}),
|
|
107
111
|
"</table>"
|
|
108
112
|
].join("\n");
|
package/dist/emit/inline.d.cts
CHANGED
|
@@ -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-
|
|
1
|
+
import { a as escapeMarkdownText, i as escapeLinkDestination, n as emitRuns, o as renderLinkTitle, r as emitRunsSingleLine, t as InlineEmitContext } from "../inline-DD4bcJFT.cjs";
|
|
2
2
|
export { InlineEmitContext, emitRuns, emitRunsSingleLine, escapeLinkDestination, escapeMarkdownText, renderLinkTitle };
|
package/dist/emit/inline.d.ts
CHANGED
|
@@ -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-
|
|
1
|
+
import { a as escapeMarkdownText, i as escapeLinkDestination, n as emitRuns, o as renderLinkTitle, r as emitRunsSingleLine, t as InlineEmitContext } from "../inline-BJj81pYp.js";
|
|
2
2
|
export { InlineEmitContext, emitRuns, emitRunsSingleLine, escapeLinkDestination, escapeMarkdownText, renderLinkTitle };
|
package/dist/emit/table.cjs
CHANGED
|
@@ -70,6 +70,11 @@ function emitTable(table, context) {
|
|
|
70
70
|
require_emit_html_table.assertTableObeysGridRule(table);
|
|
71
71
|
const [header, ...body] = table.rows;
|
|
72
72
|
if (header === void 0) return "";
|
|
73
|
+
if (header.isHeader !== true) context.sink({
|
|
74
|
+
code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.TABLE_HEADER_ROW_SYNTHESISED,
|
|
75
|
+
severity: "info",
|
|
76
|
+
message: "this table states no header row, and GFM's own table extension has no syntax for a table without one (github.github.com/gfm, \"Tables (extension)\"), so its first row is rendered as the header row and will read back as one"
|
|
77
|
+
});
|
|
73
78
|
const alignments = header.cells.map((cell) => toMarkdownAlignment(cell.blocks[0]?.kind === "paragraph" ? cell.blocks[0].alignment : void 0));
|
|
74
79
|
return [
|
|
75
80
|
`| ${header.cells.map((cell) => renderCellText(cell, context)).join(" | ")} |`,
|
package/dist/emit/table.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
2
|
-
import { t as InlineEmitContext } from "../inline-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.cjs";
|
|
2
|
+
import { t as InlineEmitContext } from "../inline-DD4bcJFT.cjs";
|
|
3
3
|
import { ContentTable } from "document-schema.js";
|
|
4
4
|
//#region src/emit/table.d.ts
|
|
5
5
|
interface TableEmitContext extends InlineEmitContext {
|
package/dist/emit/table.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
2
|
-
import { t as InlineEmitContext } from "../inline-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.js";
|
|
2
|
+
import { t as InlineEmitContext } from "../inline-BJj81pYp.js";
|
|
3
3
|
import { ContentTable } from "document-schema.js";
|
|
4
4
|
//#region src/emit/table.d.ts
|
|
5
5
|
interface TableEmitContext extends InlineEmitContext {
|
package/dist/emit/table.js
CHANGED
|
@@ -69,6 +69,11 @@ function emitTable(table, context) {
|
|
|
69
69
|
assertTableObeysGridRule(table);
|
|
70
70
|
const [header, ...body] = table.rows;
|
|
71
71
|
if (header === void 0) return "";
|
|
72
|
+
if (header.isHeader !== true) context.sink({
|
|
73
|
+
code: MarkdownDiagnosticCodes.TABLE_HEADER_ROW_SYNTHESISED,
|
|
74
|
+
severity: "info",
|
|
75
|
+
message: "this table states no header row, and GFM's own table extension has no syntax for a table without one (github.github.com/gfm, \"Tables (extension)\"), so its first row is rendered as the header row and will read back as one"
|
|
76
|
+
});
|
|
72
77
|
const alignments = header.cells.map((cell) => toMarkdownAlignment(cell.blocks[0]?.kind === "paragraph" ? cell.blocks[0].alignment : void 0));
|
|
73
78
|
return [
|
|
74
79
|
`| ${header.cells.map((cell) => renderCellText(cell, context)).join(" | ")} |`,
|
package/dist/html/html-table.cjs
CHANGED
|
@@ -25,7 +25,7 @@ function findBalancedClose(text, openEnd, tagNames) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function extractTopLevelElements(text, tagNames) {
|
|
28
|
-
const openPattern = new RegExp(`<(
|
|
28
|
+
const openPattern = new RegExp(`<(${tagNames.join("|")})\\b([^>]*)>`, "gi");
|
|
29
29
|
const elements = [];
|
|
30
30
|
let pos = 0;
|
|
31
31
|
for (;;) {
|
|
@@ -33,11 +33,13 @@ function extractTopLevelElements(text, tagNames) {
|
|
|
33
33
|
const match = openPattern.exec(text);
|
|
34
34
|
if (match === null) break;
|
|
35
35
|
if (text.slice(pos, match.index).trim().length > 0) return;
|
|
36
|
-
const
|
|
36
|
+
const tag = match[1].toLowerCase();
|
|
37
|
+
const attrs = match[2];
|
|
37
38
|
const openEnd = match.index + match[0].length;
|
|
38
39
|
const close = findBalancedClose(text, openEnd, tagNames);
|
|
39
40
|
if (close === void 0) return;
|
|
40
41
|
elements.push({
|
|
42
|
+
tag,
|
|
41
43
|
attrs,
|
|
42
44
|
inner: text.slice(openEnd, close.start)
|
|
43
45
|
});
|
|
@@ -210,7 +212,11 @@ function parseTableRows(inner, contentWidthPt) {
|
|
|
210
212
|
for (const row of rowElements) {
|
|
211
213
|
const cellElements = extractTopLevelElements(row.inner, ["td", "th"]);
|
|
212
214
|
if (cellElements === void 0 || cellElements.length === 0) return;
|
|
213
|
-
|
|
215
|
+
const isHeader = cellElements.every((cell) => cell.tag === "th");
|
|
216
|
+
anchorRows.push({
|
|
217
|
+
cells: cellElements.map((cell) => buildCell(cell, contentWidthPt)),
|
|
218
|
+
...isHeader ? { isHeader: true } : {}
|
|
219
|
+
});
|
|
214
220
|
}
|
|
215
221
|
return (0, document_schema_js.placeAnchorTableRows)(anchorRows, NO_DECLARED_COLUMN_COUNT);
|
|
216
222
|
}
|
package/dist/html/html-table.js
CHANGED
|
@@ -24,7 +24,7 @@ function findBalancedClose(text, openEnd, tagNames) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
function extractTopLevelElements(text, tagNames) {
|
|
27
|
-
const openPattern = new RegExp(`<(
|
|
27
|
+
const openPattern = new RegExp(`<(${tagNames.join("|")})\\b([^>]*)>`, "gi");
|
|
28
28
|
const elements = [];
|
|
29
29
|
let pos = 0;
|
|
30
30
|
for (;;) {
|
|
@@ -32,11 +32,13 @@ function extractTopLevelElements(text, tagNames) {
|
|
|
32
32
|
const match = openPattern.exec(text);
|
|
33
33
|
if (match === null) break;
|
|
34
34
|
if (text.slice(pos, match.index).trim().length > 0) return;
|
|
35
|
-
const
|
|
35
|
+
const tag = match[1].toLowerCase();
|
|
36
|
+
const attrs = match[2];
|
|
36
37
|
const openEnd = match.index + match[0].length;
|
|
37
38
|
const close = findBalancedClose(text, openEnd, tagNames);
|
|
38
39
|
if (close === void 0) return;
|
|
39
40
|
elements.push({
|
|
41
|
+
tag,
|
|
40
42
|
attrs,
|
|
41
43
|
inner: text.slice(openEnd, close.start)
|
|
42
44
|
});
|
|
@@ -209,7 +211,11 @@ function parseTableRows(inner, contentWidthPt) {
|
|
|
209
211
|
for (const row of rowElements) {
|
|
210
212
|
const cellElements = extractTopLevelElements(row.inner, ["td", "th"]);
|
|
211
213
|
if (cellElements === void 0 || cellElements.length === 0) return;
|
|
212
|
-
|
|
214
|
+
const isHeader = cellElements.every((cell) => cell.tag === "th");
|
|
215
|
+
anchorRows.push({
|
|
216
|
+
cells: cellElements.map((cell) => buildCell(cell, contentWidthPt)),
|
|
217
|
+
...isHeader ? { isHeader: true } : {}
|
|
218
|
+
});
|
|
213
219
|
}
|
|
214
220
|
return placeAnchorTableRows(anchorRows, NO_DECLARED_COLUMN_COUNT);
|
|
215
221
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -14,11 +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;
|
|
20
19
|
exports.MarkdownTableGridFaultError = require_diagnostics_diagnostics.MarkdownTableGridFaultError;
|
|
21
20
|
exports.MarkdownUnbalancedConstructMarkersError = require_diagnostics_diagnostics.MarkdownUnbalancedConstructMarkersError;
|
|
21
|
+
exports.MarkdownUndecodableTextError = require_diagnostics_diagnostics.MarkdownUndecodableTextError;
|
|
22
22
|
exports.MarkdownUnsupportedDocumentKindError = require_diagnostics_diagnostics.MarkdownUnsupportedDocumentKindError;
|
|
23
23
|
exports.MarkdownWriteError = require_diagnostics_diagnostics.MarkdownWriteError;
|
|
24
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,
|
|
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-DpAXEzZP.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,
|
|
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,
|
|
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-DpAXEzZP.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,
|
|
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,
|
|
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,
|
|
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-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "./diagnostics-DpAXEzZP.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-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "./diagnostics-DpAXEzZP.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-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.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-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.js";
|
|
2
2
|
import { LayoutMetadata } from "document-schema.js";
|
|
3
3
|
//#region src/lower/front-matter.d.ts
|
|
4
4
|
interface FrontMatterResult {
|
package/dist/lower/inline.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as MarkdownInlineNode } from "../ast-CNfTgS0N.cjs";
|
|
2
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
2
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.cjs";
|
|
3
3
|
import { ContentRun, RunConstructExtent } from "document-schema.js";
|
|
4
4
|
//#region src/lower/inline.d.ts
|
|
5
5
|
interface InlineLowerContext {
|
package/dist/lower/inline.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as MarkdownInlineNode } from "../ast-CNfTgS0N.js";
|
|
2
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
2
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.js";
|
|
3
3
|
import { ContentRun, RunConstructExtent } from "document-schema.js";
|
|
4
4
|
//#region src/lower/inline.d.ts
|
|
5
5
|
interface InlineLowerContext {
|
package/dist/lower/table.cjs
CHANGED
|
@@ -20,7 +20,10 @@ function lowerTable(node, contentWidthPt, context) {
|
|
|
20
20
|
const columnWidthsPt = Array.from({ length: columnCount }, () => contentWidthPt / columnCount);
|
|
21
21
|
return {
|
|
22
22
|
kind: "table",
|
|
23
|
-
rows: node.children.map((row
|
|
23
|
+
rows: node.children.map((row, rowIndex) => ({
|
|
24
|
+
cells: row.children.map((cell, index) => lowerTableCell(cell, node.alignments[index], context)),
|
|
25
|
+
...rowIndex === 0 ? { isHeader: true } : {}
|
|
26
|
+
})),
|
|
24
27
|
columnWidthsPt
|
|
25
28
|
};
|
|
26
29
|
}
|
package/dist/lower/table.js
CHANGED
|
@@ -19,7 +19,10 @@ function lowerTable(node, contentWidthPt, context) {
|
|
|
19
19
|
const columnWidthsPt = Array.from({ length: columnCount }, () => contentWidthPt / columnCount);
|
|
20
20
|
return {
|
|
21
21
|
kind: "table",
|
|
22
|
-
rows: node.children.map((row
|
|
22
|
+
rows: node.children.map((row, rowIndex) => ({
|
|
23
|
+
cells: row.children.map((cell, index) => lowerTableCell(cell, node.alignments[index], context)),
|
|
24
|
+
...rowIndex === 0 ? { isHeader: true } : {}
|
|
25
|
+
})),
|
|
23
26
|
columnWidthsPt
|
|
24
27
|
};
|
|
25
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as MarkdownDiagnosticSink } from "../diagnostics-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.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-
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DpAXEzZP.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-
|
|
1
|
+
import { t as MarkdownDiagnostic } from "./diagnostics-DpAXEzZP.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-
|
|
1
|
+
import { t as MarkdownDiagnostic } from "./diagnostics-DpAXEzZP.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": "markdown-codec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Hand-written CommonMark+GFM <-> DocumentTree codec, built on document-schema.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"license": "MIT",
|
|
84
84
|
"packageManager": "pnpm@12.4.1+sha512.2e81e399d73fe8390dab25e06aa788ab7a5908248d2f5a370f82b481147a6a7a367bf8048f9a6fdb6460f21a66f0542dedb8b94ca2c8723596741920b1656d4c",
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"byte-codec": "1.
|
|
87
|
-
"document-schema.js": "7.
|
|
86
|
+
"byte-codec": "1.8.0",
|
|
87
|
+
"document-schema.js": "7.14.0",
|
|
88
88
|
"zod": "4.4.3"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|