markdown-codec 0.0.0 → 1.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/LICENSE +21 -0
- package/README.md +215 -0
- package/dist/ast/ast.cjs +25 -0
- package/dist/ast/ast.d.cts +2 -0
- package/dist/ast/ast.d.ts +2 -0
- package/dist/ast/ast.js +23 -0
- package/dist/ast-BXYwy08e.d.cts +160 -0
- package/dist/ast-BXYwy08e.d.ts +160 -0
- package/dist/block/block.cjs +530 -0
- package/dist/block/block.d.cts +18 -0
- package/dist/block/block.d.ts +18 -0
- package/dist/block/block.js +529 -0
- package/dist/block/definitions.cjs +59 -0
- package/dist/block/definitions.d.cts +6 -0
- package/dist/block/definitions.d.ts +6 -0
- package/dist/block/definitions.js +58 -0
- package/dist/block/line.cjs +76 -0
- package/dist/block/line.d.cts +28 -0
- package/dist/block/line.d.ts +28 -0
- package/dist/block/line.js +74 -0
- package/dist/block/list.cjs +110 -0
- package/dist/block/list.d.cts +8 -0
- package/dist/block/list.d.ts +8 -0
- package/dist/block/list.js +107 -0
- package/dist/block/node.cjs +68 -0
- package/dist/block/node.d.cts +45 -0
- package/dist/block/node.d.ts +45 -0
- package/dist/block/node.js +65 -0
- package/dist/block/table.cjs +64 -0
- package/dist/block/table.d.cts +7 -0
- package/dist/block/table.d.ts +7 -0
- package/dist/block/table.js +61 -0
- package/dist/codec.cjs +22 -0
- package/dist/codec.d.cts +361 -0
- package/dist/codec.d.ts +361 -0
- package/dist/codec.js +20 -0
- package/dist/defaults/defaults.cjs +31 -0
- package/dist/defaults/defaults.d.cts +16 -0
- package/dist/defaults/defaults.d.ts +16 -0
- package/dist/defaults/defaults.js +20 -0
- package/dist/diagnostics/diagnostics.cjs +85 -0
- package/dist/diagnostics/diagnostics.d.cts +2 -0
- package/dist/diagnostics/diagnostics.d.ts +2 -0
- package/dist/diagnostics/diagnostics.js +77 -0
- package/dist/diagnostics-DmuWc7d8.d.cts +61 -0
- package/dist/diagnostics-DmuWc7d8.d.ts +61 -0
- package/dist/emit/emit.cjs +228 -0
- package/dist/emit/emit.d.cts +6 -0
- package/dist/emit/emit.d.ts +6 -0
- package/dist/emit/emit.js +227 -0
- package/dist/emit/front-matter.cjs +24 -0
- package/dist/emit/front-matter.d.cts +5 -0
- package/dist/emit/front-matter.d.ts +5 -0
- package/dist/emit/front-matter.js +23 -0
- package/dist/emit/image.cjs +10 -0
- package/dist/emit/image.d.cts +5 -0
- package/dist/emit/image.d.ts +5 -0
- package/dist/emit/image.js +9 -0
- package/dist/emit/inline.cjs +183 -0
- package/dist/emit/inline.d.cts +12 -0
- package/dist/emit/inline.d.ts +12 -0
- package/dist/emit/inline.js +180 -0
- package/dist/emit/table.cjs +73 -0
- package/dist/emit/table.d.cts +10 -0
- package/dist/emit/table.d.ts +10 -0
- package/dist/emit/table.js +72 -0
- package/dist/html/html.cjs +116 -0
- package/dist/html/html.d.cts +2 -0
- package/dist/html/html.d.ts +2 -0
- package/dist/html/html.js +113 -0
- package/dist/html/render.cjs +193 -0
- package/dist/html/render.d.cts +8 -0
- package/dist/html/render.d.ts +8 -0
- package/dist/html/render.js +189 -0
- package/dist/html-bkz2QTuq.d.cts +7 -0
- package/dist/html-bkz2QTuq.d.ts +7 -0
- package/dist/image/image.cjs +129 -0
- package/dist/image/image.d.cts +2 -0
- package/dist/image/image.d.ts +2 -0
- package/dist/image/image.js +125 -0
- package/dist/image-C4KYmz_L.d.cts +19 -0
- package/dist/image-Cm3hT5PS.d.ts +19 -0
- package/dist/image-DescdRgq.d.cts +12 -0
- package/dist/image-DescdRgq.d.ts +12 -0
- package/dist/index.cjs +17 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -0
- package/dist/inline/chars.cjs +50 -0
- package/dist/inline/chars.d.cts +11 -0
- package/dist/inline/chars.d.ts +11 -0
- package/dist/inline/chars.js +42 -0
- package/dist/inline/delimiter.cjs +136 -0
- package/dist/inline/delimiter.d.cts +29 -0
- package/dist/inline/delimiter.d.ts +29 -0
- package/dist/inline/delimiter.js +132 -0
- package/dist/inline/entity.cjs +67 -0
- package/dist/inline/entity.d.cts +9 -0
- package/dist/inline/entity.d.ts +9 -0
- package/dist/inline/entity.js +65 -0
- package/dist/inline/gfm-autolink.cjs +156 -0
- package/dist/inline/gfm-autolink.d.cts +5 -0
- package/dist/inline/gfm-autolink.d.ts +5 -0
- package/dist/inline/gfm-autolink.js +155 -0
- package/dist/inline/inline.cjs +457 -0
- package/dist/inline/inline.d.cts +2 -0
- package/dist/inline/inline.d.ts +2 -0
- package/dist/inline/inline.js +456 -0
- package/dist/inline/link.cjs +130 -0
- package/dist/inline/link.d.cts +2 -0
- package/dist/inline/link.d.ts +2 -0
- package/dist/inline/link.js +124 -0
- package/dist/inline/node.cjs +57 -0
- package/dist/inline/node.d.cts +23 -0
- package/dist/inline/node.d.ts +23 -0
- package/dist/inline/node.js +55 -0
- package/dist/inline-B50cM6cn.d.ts +10 -0
- package/dist/inline-C9YEGDV5.d.cts +10 -0
- package/dist/link-Dv4kxVjk.d.cts +18 -0
- package/dist/link-Dv4kxVjk.d.ts +18 -0
- package/dist/lower/front-matter.cjs +75 -0
- package/dist/lower/front-matter.d.cts +10 -0
- package/dist/lower/front-matter.d.ts +10 -0
- package/dist/lower/front-matter.js +74 -0
- package/dist/lower/image.cjs +29 -0
- package/dist/lower/image.d.cts +2 -0
- package/dist/lower/image.d.ts +2 -0
- package/dist/lower/image.js +28 -0
- package/dist/lower/inline.cjs +96 -0
- package/dist/lower/inline.d.cts +19 -0
- package/dist/lower/inline.d.ts +19 -0
- package/dist/lower/inline.js +93 -0
- package/dist/lower/lower.cjs +293 -0
- package/dist/lower/lower.d.cts +8 -0
- package/dist/lower/lower.d.ts +8 -0
- package/dist/lower/lower.js +291 -0
- package/dist/lower/table.cjs +27 -0
- package/dist/lower/table.d.cts +7 -0
- package/dist/lower/table.d.ts +7 -0
- package/dist/lower/table.js +26 -0
- package/dist/options/options.cjs +0 -0
- package/dist/options/options.d.cts +43 -0
- package/dist/options/options.d.ts +43 -0
- package/dist/options/options.js +0 -0
- package/dist/read.cjs +20 -0
- package/dist/read.d.cts +11 -0
- package/dist/read.d.ts +11 -0
- package/dist/read.js +19 -0
- package/dist/scan/entity-table.cjs +2131 -0
- package/dist/scan/entity-table.d.cts +4 -0
- package/dist/scan/entity-table.d.ts +4 -0
- package/dist/scan/entity-table.js +2130 -0
- package/dist/scan/scan.cjs +80 -0
- package/dist/scan/scan.d.cts +2 -0
- package/dist/scan/scan.d.ts +2 -0
- package/dist/scan/scan.js +78 -0
- package/dist/scan-DeBxgG-r.d.cts +30 -0
- package/dist/scan-DeBxgG-r.d.ts +30 -0
- package/dist/shared/list-id.cjs +36 -0
- package/dist/shared/list-id.d.cts +22 -0
- package/dist/shared/list-id.d.ts +22 -0
- package/dist/shared/list-id.js +32 -0
- package/dist/shared/style-constants.cjs +34 -0
- package/dist/shared/style-constants.d.cts +14 -0
- package/dist/shared/style-constants.d.ts +14 -0
- package/dist/shared/style-constants.js +23 -0
- package/dist/write.cjs +9 -0
- package/dist/write.d.cts +6 -0
- package/dist/write.d.ts +6 -0
- package/dist/write.js +8 -0
- package/package.json +92 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_lower_inline = require("./inline.cjs");
|
|
3
|
+
//#region src/lower/table.ts
|
|
4
|
+
const MIN_COLUMN_COUNT = 1;
|
|
5
|
+
function toParagraphAlignment(alignment) {
|
|
6
|
+
return alignment === "none" ? void 0 : alignment;
|
|
7
|
+
}
|
|
8
|
+
function lowerTableCell(cell, alignment, context) {
|
|
9
|
+
const runs = require_lower_inline.lowerInlineNodes(cell.children, context);
|
|
10
|
+
const paragraphAlignment = toParagraphAlignment(alignment ?? "none");
|
|
11
|
+
return { blocks: [{
|
|
12
|
+
kind: "paragraph",
|
|
13
|
+
runs,
|
|
14
|
+
...paragraphAlignment === void 0 ? {} : { alignment: paragraphAlignment }
|
|
15
|
+
}] };
|
|
16
|
+
}
|
|
17
|
+
function lowerTable(node, contentWidthPt, context) {
|
|
18
|
+
const columnCount = Math.max(MIN_COLUMN_COUNT, node.alignments.length);
|
|
19
|
+
const columnWidthsPt = Array.from({ length: columnCount }, () => contentWidthPt / columnCount);
|
|
20
|
+
return {
|
|
21
|
+
kind: "table",
|
|
22
|
+
rows: node.children.map((row) => ({ cells: row.children.map((cell, index) => lowerTableCell(cell, node.alignments[index], context)) })),
|
|
23
|
+
columnWidthsPt
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.lowerTable = lowerTable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { j as MarkdownTableNode } from "../ast-BXYwy08e.cjs";
|
|
2
|
+
import { InlineLowerContext } from "./inline.cjs";
|
|
3
|
+
import { ContentTable } from "document-schema.js";
|
|
4
|
+
//#region src/lower/table.d.ts
|
|
5
|
+
declare function lowerTable(node: MarkdownTableNode, contentWidthPt: number, context: InlineLowerContext): ContentTable;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { lowerTable };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { j as MarkdownTableNode } from "../ast-BXYwy08e.js";
|
|
2
|
+
import { InlineLowerContext } from "./inline.js";
|
|
3
|
+
import { ContentTable } from "document-schema.js";
|
|
4
|
+
//#region src/lower/table.d.ts
|
|
5
|
+
declare function lowerTable(node: MarkdownTableNode, contentWidthPt: number, context: InlineLowerContext): ContentTable;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { lowerTable };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { lowerInlineNodes } from "./inline.js";
|
|
2
|
+
//#region src/lower/table.ts
|
|
3
|
+
const MIN_COLUMN_COUNT = 1;
|
|
4
|
+
function toParagraphAlignment(alignment) {
|
|
5
|
+
return alignment === "none" ? void 0 : alignment;
|
|
6
|
+
}
|
|
7
|
+
function lowerTableCell(cell, alignment, context) {
|
|
8
|
+
const runs = lowerInlineNodes(cell.children, context);
|
|
9
|
+
const paragraphAlignment = toParagraphAlignment(alignment ?? "none");
|
|
10
|
+
return { blocks: [{
|
|
11
|
+
kind: "paragraph",
|
|
12
|
+
runs,
|
|
13
|
+
...paragraphAlignment === void 0 ? {} : { alignment: paragraphAlignment }
|
|
14
|
+
}] };
|
|
15
|
+
}
|
|
16
|
+
function lowerTable(node, contentWidthPt, context) {
|
|
17
|
+
const columnCount = Math.max(MIN_COLUMN_COUNT, node.alignments.length);
|
|
18
|
+
const columnWidthsPt = Array.from({ length: columnCount }, () => contentWidthPt / columnCount);
|
|
19
|
+
return {
|
|
20
|
+
kind: "table",
|
|
21
|
+
rows: node.children.map((row) => ({ cells: row.children.map((cell, index) => lowerTableCell(cell, node.alignments[index], context)) })),
|
|
22
|
+
columnWidthsPt
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { lowerTable };
|
|
File without changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DmuWc7d8.cjs";
|
|
2
|
+
import { n as MarkdownImageResolver } from "../image-C4KYmz_L.cjs";
|
|
3
|
+
import { Margins, PageSize } from "document-schema.js";
|
|
4
|
+
//#region src/options/options.d.ts
|
|
5
|
+
interface ReadMarkdownOptions {
|
|
6
|
+
readonly sink?: MarkdownDiagnosticSink;
|
|
7
|
+
readonly signal?: AbortSignal;
|
|
8
|
+
readonly pageSize?: PageSize;
|
|
9
|
+
readonly margins?: Margins;
|
|
10
|
+
readonly images?: MarkdownImageResolver;
|
|
11
|
+
readonly rawHtml?: 'preserve' | 'drop';
|
|
12
|
+
readonly frontMatter?: boolean;
|
|
13
|
+
readonly gfmTables?: boolean;
|
|
14
|
+
readonly gfmAutolinks?: boolean;
|
|
15
|
+
readonly gfmStrikethrough?: boolean;
|
|
16
|
+
readonly gfmTaskLists?: boolean;
|
|
17
|
+
readonly maxInputBytes?: number;
|
|
18
|
+
readonly maxBlockNesting?: number;
|
|
19
|
+
}
|
|
20
|
+
type MarkdownHeadingStyle = 'atx' | 'setext';
|
|
21
|
+
type MarkdownBulletListMarker = '-' | '*' | '+';
|
|
22
|
+
type MarkdownOrderedListDelimiter = '.' | ')';
|
|
23
|
+
type MarkdownEmphasisMarker = '_' | '*';
|
|
24
|
+
type MarkdownCodeFenceChar = '`' | '~';
|
|
25
|
+
type MarkdownThematicBreakChar = '-' | '_' | '*';
|
|
26
|
+
type MarkdownLineEnding = 'lf' | 'crlf';
|
|
27
|
+
interface WriteMarkdownStyleOptions {
|
|
28
|
+
readonly headingStyle?: MarkdownHeadingStyle;
|
|
29
|
+
readonly bulletListMarker?: MarkdownBulletListMarker;
|
|
30
|
+
readonly orderedListDelimiter?: MarkdownOrderedListDelimiter;
|
|
31
|
+
readonly emphasisMarker?: MarkdownEmphasisMarker;
|
|
32
|
+
readonly codeFenceChar?: MarkdownCodeFenceChar;
|
|
33
|
+
readonly thematicBreakChar?: MarkdownThematicBreakChar;
|
|
34
|
+
}
|
|
35
|
+
interface WriteMarkdownOptions extends WriteMarkdownStyleOptions {
|
|
36
|
+
readonly sink?: MarkdownDiagnosticSink;
|
|
37
|
+
readonly signal?: AbortSignal;
|
|
38
|
+
readonly images?: boolean;
|
|
39
|
+
readonly lineEnding?: MarkdownLineEnding;
|
|
40
|
+
readonly frontMatter?: boolean;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { MarkdownBulletListMarker, MarkdownCodeFenceChar, MarkdownEmphasisMarker, MarkdownHeadingStyle, MarkdownLineEnding, MarkdownOrderedListDelimiter, MarkdownThematicBreakChar, ReadMarkdownOptions, WriteMarkdownOptions, WriteMarkdownStyleOptions };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { i as MarkdownDiagnosticSink } from "../diagnostics-DmuWc7d8.js";
|
|
2
|
+
import { n as MarkdownImageResolver } from "../image-Cm3hT5PS.js";
|
|
3
|
+
import { Margins, PageSize } from "document-schema.js";
|
|
4
|
+
//#region src/options/options.d.ts
|
|
5
|
+
interface ReadMarkdownOptions {
|
|
6
|
+
readonly sink?: MarkdownDiagnosticSink;
|
|
7
|
+
readonly signal?: AbortSignal;
|
|
8
|
+
readonly pageSize?: PageSize;
|
|
9
|
+
readonly margins?: Margins;
|
|
10
|
+
readonly images?: MarkdownImageResolver;
|
|
11
|
+
readonly rawHtml?: 'preserve' | 'drop';
|
|
12
|
+
readonly frontMatter?: boolean;
|
|
13
|
+
readonly gfmTables?: boolean;
|
|
14
|
+
readonly gfmAutolinks?: boolean;
|
|
15
|
+
readonly gfmStrikethrough?: boolean;
|
|
16
|
+
readonly gfmTaskLists?: boolean;
|
|
17
|
+
readonly maxInputBytes?: number;
|
|
18
|
+
readonly maxBlockNesting?: number;
|
|
19
|
+
}
|
|
20
|
+
type MarkdownHeadingStyle = 'atx' | 'setext';
|
|
21
|
+
type MarkdownBulletListMarker = '-' | '*' | '+';
|
|
22
|
+
type MarkdownOrderedListDelimiter = '.' | ')';
|
|
23
|
+
type MarkdownEmphasisMarker = '_' | '*';
|
|
24
|
+
type MarkdownCodeFenceChar = '`' | '~';
|
|
25
|
+
type MarkdownThematicBreakChar = '-' | '_' | '*';
|
|
26
|
+
type MarkdownLineEnding = 'lf' | 'crlf';
|
|
27
|
+
interface WriteMarkdownStyleOptions {
|
|
28
|
+
readonly headingStyle?: MarkdownHeadingStyle;
|
|
29
|
+
readonly bulletListMarker?: MarkdownBulletListMarker;
|
|
30
|
+
readonly orderedListDelimiter?: MarkdownOrderedListDelimiter;
|
|
31
|
+
readonly emphasisMarker?: MarkdownEmphasisMarker;
|
|
32
|
+
readonly codeFenceChar?: MarkdownCodeFenceChar;
|
|
33
|
+
readonly thematicBreakChar?: MarkdownThematicBreakChar;
|
|
34
|
+
}
|
|
35
|
+
interface WriteMarkdownOptions extends WriteMarkdownStyleOptions {
|
|
36
|
+
readonly sink?: MarkdownDiagnosticSink;
|
|
37
|
+
readonly signal?: AbortSignal;
|
|
38
|
+
readonly images?: boolean;
|
|
39
|
+
readonly lineEnding?: MarkdownLineEnding;
|
|
40
|
+
readonly frontMatter?: boolean;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { MarkdownBulletListMarker, MarkdownCodeFenceChar, MarkdownEmphasisMarker, MarkdownHeadingStyle, MarkdownLineEnding, MarkdownOrderedListDelimiter, MarkdownThematicBreakChar, ReadMarkdownOptions, WriteMarkdownOptions, WriteMarkdownStyleOptions };
|
|
File without changes
|
package/dist/read.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_lower_lower = require("./lower/lower.cjs");
|
|
3
|
+
//#region src/read.ts
|
|
4
|
+
function readMarkdown(text, options = {}) {
|
|
5
|
+
options.signal?.throwIfAborted();
|
|
6
|
+
const diagnostics = [];
|
|
7
|
+
const callerSink = options.sink;
|
|
8
|
+
return {
|
|
9
|
+
document: require_lower_lower.lowerMarkdown(text, {
|
|
10
|
+
...options,
|
|
11
|
+
sink: (diagnostic) => {
|
|
12
|
+
diagnostics.push(diagnostic);
|
|
13
|
+
callerSink?.(diagnostic);
|
|
14
|
+
}
|
|
15
|
+
}),
|
|
16
|
+
diagnostics
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.readMarkdown = readMarkdown;
|
package/dist/read.d.cts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as MarkdownDiagnostic } from "./diagnostics-DmuWc7d8.cjs";
|
|
2
|
+
import { ReadMarkdownOptions } from "./options/options.cjs";
|
|
3
|
+
import { ContentDocument } from "document-schema.js";
|
|
4
|
+
//#region src/read.d.ts
|
|
5
|
+
interface ReadMarkdownResult {
|
|
6
|
+
readonly document: ContentDocument;
|
|
7
|
+
readonly diagnostics: readonly MarkdownDiagnostic[];
|
|
8
|
+
}
|
|
9
|
+
declare function readMarkdown(text: string, options?: ReadMarkdownOptions): ReadMarkdownResult;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ReadMarkdownResult, readMarkdown };
|
package/dist/read.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as MarkdownDiagnostic } from "./diagnostics-DmuWc7d8.js";
|
|
2
|
+
import { ReadMarkdownOptions } from "./options/options.js";
|
|
3
|
+
import { ContentDocument } from "document-schema.js";
|
|
4
|
+
//#region src/read.d.ts
|
|
5
|
+
interface ReadMarkdownResult {
|
|
6
|
+
readonly document: ContentDocument;
|
|
7
|
+
readonly diagnostics: readonly MarkdownDiagnostic[];
|
|
8
|
+
}
|
|
9
|
+
declare function readMarkdown(text: string, options?: ReadMarkdownOptions): ReadMarkdownResult;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ReadMarkdownResult, readMarkdown };
|
package/dist/read.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { lowerMarkdown } from "./lower/lower.js";
|
|
2
|
+
//#region src/read.ts
|
|
3
|
+
function readMarkdown(text, options = {}) {
|
|
4
|
+
options.signal?.throwIfAborted();
|
|
5
|
+
const diagnostics = [];
|
|
6
|
+
const callerSink = options.sink;
|
|
7
|
+
return {
|
|
8
|
+
document: lowerMarkdown(text, {
|
|
9
|
+
...options,
|
|
10
|
+
sink: (diagnostic) => {
|
|
11
|
+
diagnostics.push(diagnostic);
|
|
12
|
+
callerSink?.(diagnostic);
|
|
13
|
+
}
|
|
14
|
+
}),
|
|
15
|
+
diagnostics
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { readMarkdown };
|