markdown-codec 11.1.12 → 11.1.14
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/dist/block/block.cjs +23 -612
- package/dist/block/block.d.cts +22 -3
- package/dist/block/block.d.ts +22 -3
- package/dist/block/block.js +2 -607
- package/dist/block/definitions.d.cts +1 -1
- package/dist/block/definitions.d.ts +1 -1
- package/dist/block/list.d.cts +1 -1
- package/dist/block/list.d.ts +1 -1
- package/dist/block/node.d.cts +1 -45
- package/dist/block/node.d.ts +1 -45
- package/dist/block/parser.cjs +3 -0
- package/dist/block/parser.d.cts +57 -0
- package/dist/block/parser.d.ts +57 -0
- package/dist/block/parser.js +2 -0
- package/dist/block-C3ftt8qO.js +610 -0
- package/dist/block-DsxTiUms.cjs +747 -0
- package/dist/defaults/defaults.d.cts +1 -1
- package/dist/defaults/defaults.d.ts +1 -1
- package/dist/emit/emit.cjs +7 -647
- package/dist/emit/emit.d.cts +22 -3
- package/dist/emit/emit.d.ts +22 -3
- package/dist/emit/emit.js +2 -646
- package/dist/emit/html-table.d.cts +1 -1
- package/dist/emit/html-table.d.ts +1 -1
- package/dist/emit/inline.cjs +1 -1
- package/dist/emit/inline.js +1 -1
- package/dist/emit/list-render.cjs +29 -0
- package/dist/emit/list-render.d.cts +81 -0
- package/dist/emit/list-render.d.ts +81 -0
- package/dist/emit/list-render.js +2 -0
- package/dist/emit/setext.cjs +143 -0
- package/dist/emit/setext.d.cts +30 -0
- package/dist/emit/setext.d.ts +30 -0
- package/dist/emit/setext.js +119 -0
- package/dist/emit/table.d.cts +1 -11
- package/dist/emit/table.d.ts +1 -11
- package/dist/emit-CCOoudJW.cjs +734 -0
- package/dist/emit-Do1KMQHB.js +537 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/inline/entity.cjs +1 -1
- package/dist/inline/entity.js +1 -1
- package/dist/inline/inline.cjs +2 -2
- package/dist/inline/inline.d.cts +1 -1
- package/dist/inline/inline.d.ts +1 -1
- package/dist/inline/inline.js +2 -2
- package/dist/{inline-CArcArOD.d.ts → inline-BG6ge5m2.d.ts} +1 -1
- package/dist/{inline-GzD5QtFh.d.cts → inline-BxX0iOy6.d.cts} +1 -1
- package/dist/lower/lower.cjs +3 -3
- package/dist/lower/lower.d.cts +1 -1
- package/dist/lower/lower.d.ts +1 -1
- package/dist/lower/lower.js +2 -2
- package/dist/node-DcxnTjF0.d.cts +46 -0
- package/dist/node-w8dVfAUD.d.ts +46 -0
- package/dist/options/options.d.cts +1 -43
- package/dist/options/options.d.ts +1 -43
- package/dist/options-CZoMEGL8.d.ts +44 -0
- package/dist/options-ZnZOMG3X.d.cts +44 -0
- package/dist/read.d.cts +1 -1
- package/dist/read.d.ts +1 -1
- package/dist/scan/entity-table-n-z.cjs +207 -0
- package/dist/scan/entity-table-n-z.d.cts +4 -0
- package/dist/scan/entity-table-n-z.d.ts +4 -0
- package/dist/scan/entity-table-n-z.js +206 -0
- package/dist/scan/entity-table-t-z.cjs +28 -0
- package/dist/scan/entity-table-t-z.d.cts +4 -0
- package/dist/scan/entity-table-t-z.d.ts +4 -0
- package/dist/scan/entity-table-t-z.js +27 -0
- package/dist/scan/entity-table-u-z.cjs +59 -0
- package/dist/scan/entity-table-u-z.d.cts +4 -0
- package/dist/scan/entity-table-u-z.d.ts +4 -0
- package/dist/scan/entity-table-u-z.js +58 -0
- package/dist/scan/entity-table-w-z.cjs +11 -0
- package/dist/scan/entity-table-w-z.d.cts +4 -0
- package/dist/scan/entity-table-w-z.d.ts +4 -0
- package/dist/scan/entity-table-w-z.js +10 -0
- package/dist/scan/entity-table-x-z.cjs +10 -0
- package/dist/scan/entity-table-x-z.d.cts +4 -0
- package/dist/scan/entity-table-x-z.d.ts +4 -0
- package/dist/scan/entity-table-x-z.js +9 -0
- package/dist/scan/entity-table-y-z-2.cjs +780 -0
- package/dist/scan/entity-table-y-z-2.d.cts +4 -0
- package/dist/scan/entity-table-y-z-2.d.ts +4 -0
- package/dist/scan/entity-table-y-z-2.js +779 -0
- package/dist/scan/entity-table-y-z.cjs +779 -0
- package/dist/scan/entity-table-y-z.d.cts +4 -0
- package/dist/scan/entity-table-y-z.d.ts +4 -0
- package/dist/scan/entity-table-y-z.js +778 -0
- package/dist/scan/entity-table.cjs +20 -1834
- package/dist/scan/entity-table.d.cts +2 -1
- package/dist/scan/entity-table.d.ts +2 -1
- package/dist/scan/entity-table.js +20 -1835
- package/dist/table-BFbOhm0R.d.ts +12 -0
- package/dist/table-PtkYEYdL.d.cts +12 -0
- package/dist/write.cjs +2 -2
- package/dist/write.d.cts +1 -1
- package/dist/write.d.ts +1 -1
- package/dist/write.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_emit = require("../emit-CCOoudJW.cjs");
|
|
3
|
+
exports.BULLET_GLYPH_CANDIDATES = require_emit.BULLET_GLYPH_CANDIDATES;
|
|
4
|
+
exports.FOOTNOTE_CONTINUATION_INDENT = require_emit.FOOTNOTE_CONTINUATION_INDENT;
|
|
5
|
+
exports.ORDERED_GLYPH_CANDIDATES = require_emit.ORDERED_GLYPH_CANDIDATES;
|
|
6
|
+
exports.UNINDENTED_PT = require_emit.UNINDENTED_PT;
|
|
7
|
+
exports.collectListItem = require_emit.collectListItem;
|
|
8
|
+
exports.constructCarriesListItemId = require_emit.constructCarriesListItemId;
|
|
9
|
+
exports.consumeSameItemRun = require_emit.consumeSameItemRun;
|
|
10
|
+
exports.emitItemCanInterrupt = require_emit.emitItemCanInterrupt;
|
|
11
|
+
exports.firstBlockCheckbox = require_emit.firstBlockCheckbox;
|
|
12
|
+
exports.groupConstructItems = require_emit.groupConstructItems;
|
|
13
|
+
exports.isConstructItem = require_emit.isConstructItem;
|
|
14
|
+
exports.isInheritedListMembership = require_emit.isInheritedListMembership;
|
|
15
|
+
exports.isMaterialisedDivision = require_emit.isMaterialisedDivision;
|
|
16
|
+
exports.lastStyleIdOf = require_emit.lastStyleIdOf;
|
|
17
|
+
exports.lastStyleIdOfRegionItem = require_emit.lastStyleIdOfRegionItem;
|
|
18
|
+
exports.listInfoFor = require_emit.listInfoFor;
|
|
19
|
+
exports.listRegionItemBody = require_emit.listRegionItemBody;
|
|
20
|
+
exports.regionItemCanInterrupt = require_emit.regionItemCanInterrupt;
|
|
21
|
+
exports.renderConstruct = require_emit.renderConstruct;
|
|
22
|
+
exports.renderFootnoteDefinition = require_emit.renderFootnoteDefinition;
|
|
23
|
+
exports.renderItems = require_emit.renderItems;
|
|
24
|
+
exports.renderListItemMarker = require_emit.renderListItemMarker;
|
|
25
|
+
exports.renderListRegion = require_emit.renderListRegion;
|
|
26
|
+
exports.requiresBlankLineBefore = require_emit.requiresBlankLineBefore;
|
|
27
|
+
exports.resolveListGlyph = require_emit.resolveListGlyph;
|
|
28
|
+
exports.stripCheckboxRun = require_emit.stripCheckboxRun;
|
|
29
|
+
exports.toEmitItem = require_emit.toEmitItem;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { EmitContext, RenderableBlock } from "./emit.cjs";
|
|
2
|
+
import { ListNumIdInfo } from "../shared/list-id.cjs";
|
|
3
|
+
import { ConstructDescriptor, ContentBlock, ContentListMembership, ContentParagraph } from "document-schema.js";
|
|
4
|
+
//#region src/emit/list-render.d.ts
|
|
5
|
+
declare function listInfoFor(numId: string | undefined, context: EmitContext): ListNumIdInfo | undefined;
|
|
6
|
+
declare function stripCheckboxRun(item: ContentParagraph): ContentParagraph;
|
|
7
|
+
type ListRegionItem = {
|
|
8
|
+
readonly kind: "paragraph";
|
|
9
|
+
readonly block: ContentParagraph;
|
|
10
|
+
readonly list: ContentListMembership;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "construct";
|
|
13
|
+
readonly item: ConstructItem;
|
|
14
|
+
readonly list: ContentListMembership;
|
|
15
|
+
};
|
|
16
|
+
declare function toEmitItem(item: ListRegionItem): EmitItem;
|
|
17
|
+
interface FirstBlockCheckbox {
|
|
18
|
+
readonly checkboxText: string;
|
|
19
|
+
readonly strippedFirstBlock: ContentParagraph | undefined;
|
|
20
|
+
}
|
|
21
|
+
declare function firstBlockCheckbox(first: ListRegionItem, taskNumId: boolean): FirstBlockCheckbox;
|
|
22
|
+
interface RenderedListMarker {
|
|
23
|
+
readonly full: string;
|
|
24
|
+
readonly bareLength: number;
|
|
25
|
+
}
|
|
26
|
+
declare function renderListItemMarker(numId: string | undefined, info: ListNumIdInfo | undefined, glyph: string, checkboxText: string, context: EmitContext): RenderedListMarker;
|
|
27
|
+
declare const BULLET_GLYPH_CANDIDATES: readonly ["-", "+", "*"];
|
|
28
|
+
declare const ORDERED_GLYPH_CANDIDATES: readonly [".", ")"];
|
|
29
|
+
interface ListSiblingSignature {
|
|
30
|
+
readonly numId: string;
|
|
31
|
+
readonly type: "bullet" | "ordered";
|
|
32
|
+
readonly glyph: string;
|
|
33
|
+
}
|
|
34
|
+
declare function resolveListGlyph(numId: string, type: "bullet" | "ordered", previousSibling: ListSiblingSignature | undefined, context: EmitContext): string;
|
|
35
|
+
interface ListItemPart {
|
|
36
|
+
readonly numId: string | undefined;
|
|
37
|
+
readonly text: string;
|
|
38
|
+
}
|
|
39
|
+
interface ItemOwnSegment {
|
|
40
|
+
readonly kind: "own";
|
|
41
|
+
readonly blocks: readonly ListRegionItem[];
|
|
42
|
+
}
|
|
43
|
+
interface ItemNestedSegment {
|
|
44
|
+
readonly kind: "nested";
|
|
45
|
+
readonly blocks: readonly ListRegionItem[];
|
|
46
|
+
}
|
|
47
|
+
type ItemSegment = ItemOwnSegment | ItemNestedSegment;
|
|
48
|
+
declare function consumeSameItemRun(items: readonly ListRegionItem[], from: number, level: number, itemId: string): number;
|
|
49
|
+
declare function collectListItem(items: readonly ListRegionItem[], start: number, level: number, itemId: string | undefined): {
|
|
50
|
+
readonly segments: readonly ItemSegment[];
|
|
51
|
+
readonly next: number;
|
|
52
|
+
};
|
|
53
|
+
declare function emitItemCanInterrupt(item: EmitItem, context: EmitContext): boolean;
|
|
54
|
+
declare function lastStyleIdOf(item: EmitItem): string | undefined;
|
|
55
|
+
declare function regionItemCanInterrupt(item: ListRegionItem, context: EmitContext): boolean;
|
|
56
|
+
declare function lastStyleIdOfRegionItem(item: ListRegionItem): string | undefined;
|
|
57
|
+
declare function listRegionItemBody(item: ListRegionItem, context: EmitContext, overrideParagraph: ContentParagraph | undefined): string;
|
|
58
|
+
declare function requiresBlankLineBefore(next: ListRegionItem, previousStyleId: string | undefined, context: EmitContext): boolean;
|
|
59
|
+
declare function renderListRegion(items: readonly ListRegionItem[], context: EmitContext): string;
|
|
60
|
+
type EmitItem = {
|
|
61
|
+
readonly block: RenderableBlock;
|
|
62
|
+
} | ConstructItem;
|
|
63
|
+
interface ConstructItem {
|
|
64
|
+
readonly descriptor: ConstructDescriptor;
|
|
65
|
+
readonly children: readonly EmitItem[];
|
|
66
|
+
}
|
|
67
|
+
declare function isConstructItem(item: EmitItem): item is ConstructItem;
|
|
68
|
+
declare const UNINDENTED_PT = 0;
|
|
69
|
+
declare function isMaterialisedDivision(item: ConstructItem): boolean;
|
|
70
|
+
declare function groupConstructItems(blocks: readonly ContentBlock[], start: number): {
|
|
71
|
+
readonly items: EmitItem[];
|
|
72
|
+
readonly next: number;
|
|
73
|
+
};
|
|
74
|
+
declare const FOOTNOTE_CONTINUATION_INDENT = 4;
|
|
75
|
+
declare function renderFootnoteDefinition(name: string, body: string): string;
|
|
76
|
+
declare function renderConstruct(item: ConstructItem, context: EmitContext): string;
|
|
77
|
+
declare function constructCarriesListItemId(item: ConstructItem, itemId: string): boolean;
|
|
78
|
+
declare function isInheritedListMembership(list: Readonly<ContentListMembership>, context: EmitContext): boolean;
|
|
79
|
+
declare function renderItems(items: readonly EmitItem[], context: EmitContext): string;
|
|
80
|
+
//#endregion
|
|
81
|
+
export { BULLET_GLYPH_CANDIDATES, ConstructItem, EmitItem, FOOTNOTE_CONTINUATION_INDENT, FirstBlockCheckbox, ItemNestedSegment, ItemOwnSegment, ItemSegment, ListItemPart, ListRegionItem, ListSiblingSignature, ORDERED_GLYPH_CANDIDATES, RenderedListMarker, UNINDENTED_PT, collectListItem, constructCarriesListItemId, consumeSameItemRun, emitItemCanInterrupt, firstBlockCheckbox, groupConstructItems, isConstructItem, isInheritedListMembership, isMaterialisedDivision, lastStyleIdOf, lastStyleIdOfRegionItem, listInfoFor, listRegionItemBody, regionItemCanInterrupt, renderConstruct, renderFootnoteDefinition, renderItems, renderListItemMarker, renderListRegion, requiresBlankLineBefore, resolveListGlyph, stripCheckboxRun, toEmitItem };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { EmitContext, RenderableBlock } from "./emit.js";
|
|
2
|
+
import { ListNumIdInfo } from "../shared/list-id.js";
|
|
3
|
+
import { ConstructDescriptor, ContentBlock, ContentListMembership, ContentParagraph } from "document-schema.js";
|
|
4
|
+
//#region src/emit/list-render.d.ts
|
|
5
|
+
declare function listInfoFor(numId: string | undefined, context: EmitContext): ListNumIdInfo | undefined;
|
|
6
|
+
declare function stripCheckboxRun(item: ContentParagraph): ContentParagraph;
|
|
7
|
+
type ListRegionItem = {
|
|
8
|
+
readonly kind: "paragraph";
|
|
9
|
+
readonly block: ContentParagraph;
|
|
10
|
+
readonly list: ContentListMembership;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "construct";
|
|
13
|
+
readonly item: ConstructItem;
|
|
14
|
+
readonly list: ContentListMembership;
|
|
15
|
+
};
|
|
16
|
+
declare function toEmitItem(item: ListRegionItem): EmitItem;
|
|
17
|
+
interface FirstBlockCheckbox {
|
|
18
|
+
readonly checkboxText: string;
|
|
19
|
+
readonly strippedFirstBlock: ContentParagraph | undefined;
|
|
20
|
+
}
|
|
21
|
+
declare function firstBlockCheckbox(first: ListRegionItem, taskNumId: boolean): FirstBlockCheckbox;
|
|
22
|
+
interface RenderedListMarker {
|
|
23
|
+
readonly full: string;
|
|
24
|
+
readonly bareLength: number;
|
|
25
|
+
}
|
|
26
|
+
declare function renderListItemMarker(numId: string | undefined, info: ListNumIdInfo | undefined, glyph: string, checkboxText: string, context: EmitContext): RenderedListMarker;
|
|
27
|
+
declare const BULLET_GLYPH_CANDIDATES: readonly ["-", "+", "*"];
|
|
28
|
+
declare const ORDERED_GLYPH_CANDIDATES: readonly [".", ")"];
|
|
29
|
+
interface ListSiblingSignature {
|
|
30
|
+
readonly numId: string;
|
|
31
|
+
readonly type: "bullet" | "ordered";
|
|
32
|
+
readonly glyph: string;
|
|
33
|
+
}
|
|
34
|
+
declare function resolveListGlyph(numId: string, type: "bullet" | "ordered", previousSibling: ListSiblingSignature | undefined, context: EmitContext): string;
|
|
35
|
+
interface ListItemPart {
|
|
36
|
+
readonly numId: string | undefined;
|
|
37
|
+
readonly text: string;
|
|
38
|
+
}
|
|
39
|
+
interface ItemOwnSegment {
|
|
40
|
+
readonly kind: "own";
|
|
41
|
+
readonly blocks: readonly ListRegionItem[];
|
|
42
|
+
}
|
|
43
|
+
interface ItemNestedSegment {
|
|
44
|
+
readonly kind: "nested";
|
|
45
|
+
readonly blocks: readonly ListRegionItem[];
|
|
46
|
+
}
|
|
47
|
+
type ItemSegment = ItemOwnSegment | ItemNestedSegment;
|
|
48
|
+
declare function consumeSameItemRun(items: readonly ListRegionItem[], from: number, level: number, itemId: string): number;
|
|
49
|
+
declare function collectListItem(items: readonly ListRegionItem[], start: number, level: number, itemId: string | undefined): {
|
|
50
|
+
readonly segments: readonly ItemSegment[];
|
|
51
|
+
readonly next: number;
|
|
52
|
+
};
|
|
53
|
+
declare function emitItemCanInterrupt(item: EmitItem, context: EmitContext): boolean;
|
|
54
|
+
declare function lastStyleIdOf(item: EmitItem): string | undefined;
|
|
55
|
+
declare function regionItemCanInterrupt(item: ListRegionItem, context: EmitContext): boolean;
|
|
56
|
+
declare function lastStyleIdOfRegionItem(item: ListRegionItem): string | undefined;
|
|
57
|
+
declare function listRegionItemBody(item: ListRegionItem, context: EmitContext, overrideParagraph: ContentParagraph | undefined): string;
|
|
58
|
+
declare function requiresBlankLineBefore(next: ListRegionItem, previousStyleId: string | undefined, context: EmitContext): boolean;
|
|
59
|
+
declare function renderListRegion(items: readonly ListRegionItem[], context: EmitContext): string;
|
|
60
|
+
type EmitItem = {
|
|
61
|
+
readonly block: RenderableBlock;
|
|
62
|
+
} | ConstructItem;
|
|
63
|
+
interface ConstructItem {
|
|
64
|
+
readonly descriptor: ConstructDescriptor;
|
|
65
|
+
readonly children: readonly EmitItem[];
|
|
66
|
+
}
|
|
67
|
+
declare function isConstructItem(item: EmitItem): item is ConstructItem;
|
|
68
|
+
declare const UNINDENTED_PT = 0;
|
|
69
|
+
declare function isMaterialisedDivision(item: ConstructItem): boolean;
|
|
70
|
+
declare function groupConstructItems(blocks: readonly ContentBlock[], start: number): {
|
|
71
|
+
readonly items: EmitItem[];
|
|
72
|
+
readonly next: number;
|
|
73
|
+
};
|
|
74
|
+
declare const FOOTNOTE_CONTINUATION_INDENT = 4;
|
|
75
|
+
declare function renderFootnoteDefinition(name: string, body: string): string;
|
|
76
|
+
declare function renderConstruct(item: ConstructItem, context: EmitContext): string;
|
|
77
|
+
declare function constructCarriesListItemId(item: ConstructItem, itemId: string): boolean;
|
|
78
|
+
declare function isInheritedListMembership(list: Readonly<ContentListMembership>, context: EmitContext): boolean;
|
|
79
|
+
declare function renderItems(items: readonly EmitItem[], context: EmitContext): string;
|
|
80
|
+
//#endregion
|
|
81
|
+
export { BULLET_GLYPH_CANDIDATES, ConstructItem, EmitItem, FOOTNOTE_CONTINUATION_INDENT, FirstBlockCheckbox, ItemNestedSegment, ItemOwnSegment, ItemSegment, ListItemPart, ListRegionItem, ListSiblingSignature, ORDERED_GLYPH_CANDIDATES, RenderedListMarker, UNINDENTED_PT, collectListItem, constructCarriesListItemId, consumeSameItemRun, emitItemCanInterrupt, firstBlockCheckbox, groupConstructItems, isConstructItem, isInheritedListMembership, isMaterialisedDivision, lastStyleIdOf, lastStyleIdOfRegionItem, listInfoFor, listRegionItemBody, regionItemCanInterrupt, renderConstruct, renderFootnoteDefinition, renderItems, renderListItemMarker, renderListRegion, requiresBlankLineBefore, resolveListGlyph, stripCheckboxRun, toEmitItem };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as requiresBlankLineBefore, C as listRegionItemBody, D as renderItems, E as renderFootnoteDefinition, M as stripCheckboxRun, N as toEmitItem, O as renderListItemMarker, S as listInfoFor, T as renderConstruct, _ as isConstructItem, b as lastStyleIdOf, c as FOOTNOTE_CONTINUATION_INDENT, d as collectListItem, f as constructCarriesListItemId, g as groupConstructItems, h as firstBlockCheckbox, j as resolveListGlyph, k as renderListRegion, l as ORDERED_GLYPH_CANDIDATES, m as emitItemCanInterrupt, p as consumeSameItemRun, s as BULLET_GLYPH_CANDIDATES, u as UNINDENTED_PT, v as isInheritedListMembership, w as regionItemCanInterrupt, x as lastStyleIdOfRegionItem, y as isMaterialisedDivision } from "../emit-Do1KMQHB.js";
|
|
2
|
+
export { BULLET_GLYPH_CANDIDATES, FOOTNOTE_CONTINUATION_INDENT, ORDERED_GLYPH_CANDIDATES, UNINDENTED_PT, collectListItem, constructCarriesListItemId, consumeSameItemRun, emitItemCanInterrupt, firstBlockCheckbox, groupConstructItems, isConstructItem, isInheritedListMembership, isMaterialisedDivision, lastStyleIdOf, lastStyleIdOfRegionItem, listInfoFor, listRegionItemBody, regionItemCanInterrupt, renderConstruct, renderFootnoteDefinition, renderItems, renderListItemMarker, renderListRegion, requiresBlankLineBefore, resolveListGlyph, stripCheckboxRun, toEmitItem };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_diagnostics_diagnostics = require("../diagnostics/diagnostics.cjs");
|
|
3
|
+
const require_html_html = require("../html/html.cjs");
|
|
4
|
+
const require_shared_line_ending = require("../shared/line-ending.cjs");
|
|
5
|
+
const require_block_line = require("../block/line.cjs");
|
|
6
|
+
const require_block_list = require("../block/list.cjs");
|
|
7
|
+
const require_block_table = require("../block/table.cjs");
|
|
8
|
+
const require_block = require("../block-DsxTiUms.cjs");
|
|
9
|
+
const require_shared_style_constants = require("../shared/style-constants.cjs");
|
|
10
|
+
const require_emit_inline = require("./inline.cjs");
|
|
11
|
+
//#region src/emit/setext.ts
|
|
12
|
+
const MAX_SETEXT_LEVEL = 2;
|
|
13
|
+
const SETEXT_LEVEL_1_CHAR = "=";
|
|
14
|
+
const SETEXT_LEVEL_2_CHAR = "-";
|
|
15
|
+
const MIN_SETEXT_UNDERLINE_LENGTH = 1;
|
|
16
|
+
function splitLines(text, pattern) {
|
|
17
|
+
const [first, ...rest] = text.split(pattern);
|
|
18
|
+
return [first, ...rest];
|
|
19
|
+
}
|
|
20
|
+
function renderSetextHeading(level, text) {
|
|
21
|
+
const underlineChar = level === 1 ? "=" : "-";
|
|
22
|
+
const [firstLine] = splitLines(text, require_shared_line_ending.LINE_ENDING_PATTERN);
|
|
23
|
+
return `${text}\n${underlineChar.repeat(Math.max(1, firstLine.length))}`;
|
|
24
|
+
}
|
|
25
|
+
function renderAtxHeading(level, text) {
|
|
26
|
+
const collapsed = text.replace(require_shared_line_ending.ESCAPED_HARD_BREAK_PATTERN, " ").split(require_shared_line_ending.LINE_ENDING_PATTERN).join(" ");
|
|
27
|
+
return `${"#".repeat(level)} ${collapsed}`;
|
|
28
|
+
}
|
|
29
|
+
const MIN_CODE_FENCE_LENGTH = 3;
|
|
30
|
+
const THEMATIC_BREAK_CHAR_COUNT = 3;
|
|
31
|
+
function longestRunLength(text, char) {
|
|
32
|
+
let longest = 0;
|
|
33
|
+
let current = 0;
|
|
34
|
+
for (const candidate of text) if (candidate === char) {
|
|
35
|
+
current += 1;
|
|
36
|
+
longest = Math.max(longest, current);
|
|
37
|
+
} else current = 0;
|
|
38
|
+
return longest;
|
|
39
|
+
}
|
|
40
|
+
function codeFenceFor(literal, fenceChar) {
|
|
41
|
+
return fenceChar.repeat(Math.max(3, longestRunLength(literal, fenceChar) + 1));
|
|
42
|
+
}
|
|
43
|
+
const QUOTABLE_STYLE_IDS = /* @__PURE__ */ new Set([
|
|
44
|
+
require_shared_style_constants.QUOTE_STYLE_ID,
|
|
45
|
+
require_shared_style_constants.CODE_BLOCK_STYLE_ID,
|
|
46
|
+
require_shared_style_constants.HORIZONTAL_RULE_STYLE_ID,
|
|
47
|
+
require_shared_style_constants.HTML_PREFORMATTED_STYLE_ID,
|
|
48
|
+
require_shared_style_constants.MATH_BLOCK_STYLE_ID
|
|
49
|
+
]);
|
|
50
|
+
function isQuotableStyle(styleId) {
|
|
51
|
+
if (styleId === void 0) return false;
|
|
52
|
+
return QUOTABLE_STYLE_IDS.has(styleId) || require_shared_style_constants.parseHeadingStyleId(styleId) !== void 0;
|
|
53
|
+
}
|
|
54
|
+
function terminatesCleanly(styleId) {
|
|
55
|
+
return styleId === "CodeBlock" || styleId === "MathBlock" || styleId === "HorizontalRule" || styleId !== void 0 && require_shared_style_constants.parseHeadingStyleId(styleId) !== void 0;
|
|
56
|
+
}
|
|
57
|
+
const BLANK_OR_WHITESPACE_ONLY_LINE = /^[ \t]*$/;
|
|
58
|
+
function firstContentLineIndex(text) {
|
|
59
|
+
return text.split(require_shared_line_ending.LINE_ENDING_PATTERN).findIndex((line) => !BLANK_OR_WHITESPACE_ONLY_LINE.test(line));
|
|
60
|
+
}
|
|
61
|
+
function leadingIndentReachesCodeThreshold(line) {
|
|
62
|
+
let column = 0;
|
|
63
|
+
while (line[column] === " ") column += 1;
|
|
64
|
+
if (column >= 4) return true;
|
|
65
|
+
return line[column] === " ";
|
|
66
|
+
}
|
|
67
|
+
const MAX_LEADING_BLANK_LINES_FOR_SETEXT = 1;
|
|
68
|
+
function interruptsSetextParagraph(line, atBlockStart) {
|
|
69
|
+
const cursor = new require_block_line.LineCursor(line);
|
|
70
|
+
if (cursor.indented) return false;
|
|
71
|
+
if (cursor.peekNextNonspace() === ">") return true;
|
|
72
|
+
const rest = cursor.restFromNextNonspace();
|
|
73
|
+
if (require_block.ATX_MARKER_PATTERN.test(rest) || require_block.CODE_FENCE_PATTERN.test(rest) || require_block.THEMATIC_BREAK_PATTERN.test(rest) || require_block.MATH_BLOCK_MARKER_PATTERN.test(rest) || require_html_html.matchHtmlBlockStart(rest, !atBlockStart) !== void 0) return true;
|
|
74
|
+
return require_block_list.parseListMarker(cursor, !atBlockStart) !== void 0;
|
|
75
|
+
}
|
|
76
|
+
function tableDelimiterRowPromotesPrecedingLine(line, precedingLine) {
|
|
77
|
+
const cursor = new require_block_line.LineCursor(line);
|
|
78
|
+
if (cursor.indented) return false;
|
|
79
|
+
return require_block_table.parseTableDelimiterRow(cursor.restFromNextNonspace())?.length === require_block_table.splitTableRow(precedingLine).length;
|
|
80
|
+
}
|
|
81
|
+
function unsafeSetextBreakReason(text) {
|
|
82
|
+
let leadingBlankLines = 0;
|
|
83
|
+
let precedingLine;
|
|
84
|
+
for (const line of text.split(require_shared_line_ending.LINE_ENDING_PATTERN)) {
|
|
85
|
+
const isBlank = BLANK_OR_WHITESPACE_ONLY_LINE.test(line);
|
|
86
|
+
if (precedingLine === void 0) {
|
|
87
|
+
if (isBlank) {
|
|
88
|
+
leadingBlankLines += 1;
|
|
89
|
+
if (leadingBlankLines > 1) return "blank-line";
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (leadingIndentReachesCodeThreshold(line)) return "leading-indentation";
|
|
93
|
+
if (interruptsSetextParagraph(line, true)) return "interrupting-line";
|
|
94
|
+
precedingLine = line;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (isBlank) return "blank-line";
|
|
98
|
+
if (interruptsSetextParagraph(line, false) || tableDelimiterRowPromotesPrecedingLine(line, precedingLine)) return "interrupting-line";
|
|
99
|
+
precedingLine = line;
|
|
100
|
+
}
|
|
101
|
+
return precedingLine === void 0 ? "blank-line" : void 0;
|
|
102
|
+
}
|
|
103
|
+
function embedsUnsafeBreakForSetext(text) {
|
|
104
|
+
return unsafeSetextBreakReason(text) !== void 0;
|
|
105
|
+
}
|
|
106
|
+
function unsafeSetextDiagnosticMessage(level, reason, embedsLineBreak) {
|
|
107
|
+
const hazard = reason === "leading-indentation" ? `the line that would become the setext heading's own first line of text opens with 4 or more columns of space/tab indentation — setext's own grammar (spec 0.31.2) requires the first line to have "not more than 3 spaces of indentation", so promoting would read that line back as an indented code block instead of heading text` : reason === "interrupting-line" ? `a line of the heading's own text — including possibly its first — would itself be interpretable as a code fence, ATX heading, block quote, thematic break, list item, HTML block, math block, or GFM table delimiter row — setext's own grammar (spec 0.31.2) requires every one of the heading's lines to instead read as ordinary paragraph text, so promoting would read that line back as the start of a fresh, unrelated block (or, for a table delimiter row, a conversion of the line before it) rather than more of the heading` : `promoting would leave the setext underline with no heading text of its own to attach to — either a blank line immediately before it (a trailing break), a blank line in the middle of the heading's own text (a genuinely interior break), or the heading's own rendered text being entirely blank to begin with — setext's own grammar requires "one or more lines of text, not interrupted by a blank line"`;
|
|
108
|
+
return embedsLineBreak ? `a level ${String(level)} heading's own content contains a line break, but ${hazard}; ATX collapses the break to a single space instead of promoting into a corrupt reparse` : `the effective WriteMarkdownOptions.headingStyle is 'setext' (an explicit caller choice — a break-free heading only reaches this path when requested outright), but ${hazard}; rendered as ATX instead of promoting into a corrupt reparse`;
|
|
109
|
+
}
|
|
110
|
+
function willRenderAsSetext(paragraph, level, context) {
|
|
111
|
+
if (level > 2) return false;
|
|
112
|
+
const text = require_emit_inline.emitRuns(paragraph.runs, {
|
|
113
|
+
sink: require_diagnostics_diagnostics.NOOP_MARKDOWN_DIAGNOSTIC_SINK,
|
|
114
|
+
emphasisMarker: context.emphasisMarker
|
|
115
|
+
}, paragraph.constructs);
|
|
116
|
+
if (embedsUnsafeBreakForSetext(text)) return false;
|
|
117
|
+
return context.headingStyle === "setext" || require_shared_line_ending.LINE_ENDING_PATTERN.test(text);
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
exports.BLANK_OR_WHITESPACE_ONLY_LINE = BLANK_OR_WHITESPACE_ONLY_LINE;
|
|
121
|
+
exports.MAX_LEADING_BLANK_LINES_FOR_SETEXT = MAX_LEADING_BLANK_LINES_FOR_SETEXT;
|
|
122
|
+
exports.MAX_SETEXT_LEVEL = MAX_SETEXT_LEVEL;
|
|
123
|
+
exports.MIN_CODE_FENCE_LENGTH = MIN_CODE_FENCE_LENGTH;
|
|
124
|
+
exports.MIN_SETEXT_UNDERLINE_LENGTH = MIN_SETEXT_UNDERLINE_LENGTH;
|
|
125
|
+
exports.QUOTABLE_STYLE_IDS = QUOTABLE_STYLE_IDS;
|
|
126
|
+
exports.SETEXT_LEVEL_1_CHAR = SETEXT_LEVEL_1_CHAR;
|
|
127
|
+
exports.SETEXT_LEVEL_2_CHAR = SETEXT_LEVEL_2_CHAR;
|
|
128
|
+
exports.THEMATIC_BREAK_CHAR_COUNT = THEMATIC_BREAK_CHAR_COUNT;
|
|
129
|
+
exports.codeFenceFor = codeFenceFor;
|
|
130
|
+
exports.embedsUnsafeBreakForSetext = embedsUnsafeBreakForSetext;
|
|
131
|
+
exports.firstContentLineIndex = firstContentLineIndex;
|
|
132
|
+
exports.interruptsSetextParagraph = interruptsSetextParagraph;
|
|
133
|
+
exports.isQuotableStyle = isQuotableStyle;
|
|
134
|
+
exports.leadingIndentReachesCodeThreshold = leadingIndentReachesCodeThreshold;
|
|
135
|
+
exports.longestRunLength = longestRunLength;
|
|
136
|
+
exports.renderAtxHeading = renderAtxHeading;
|
|
137
|
+
exports.renderSetextHeading = renderSetextHeading;
|
|
138
|
+
exports.splitLines = splitLines;
|
|
139
|
+
exports.tableDelimiterRowPromotesPrecedingLine = tableDelimiterRowPromotesPrecedingLine;
|
|
140
|
+
exports.terminatesCleanly = terminatesCleanly;
|
|
141
|
+
exports.unsafeSetextBreakReason = unsafeSetextBreakReason;
|
|
142
|
+
exports.unsafeSetextDiagnosticMessage = unsafeSetextDiagnosticMessage;
|
|
143
|
+
exports.willRenderAsSetext = willRenderAsSetext;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EmitContext } from "./emit.cjs";
|
|
2
|
+
import { ContentParagraph } from "document-schema.js";
|
|
3
|
+
//#region src/emit/setext.d.ts
|
|
4
|
+
declare const MAX_SETEXT_LEVEL = 2;
|
|
5
|
+
declare const SETEXT_LEVEL_1_CHAR = "=";
|
|
6
|
+
declare const SETEXT_LEVEL_2_CHAR = "-";
|
|
7
|
+
declare const MIN_SETEXT_UNDERLINE_LENGTH = 1;
|
|
8
|
+
declare function splitLines(text: string, pattern: string | RegExp): readonly [string, ...string[]];
|
|
9
|
+
declare function renderSetextHeading(level: number, text: string): string;
|
|
10
|
+
declare function renderAtxHeading(level: number, text: string): string;
|
|
11
|
+
declare const MIN_CODE_FENCE_LENGTH = 3;
|
|
12
|
+
declare const THEMATIC_BREAK_CHAR_COUNT = 3;
|
|
13
|
+
declare function longestRunLength(text: string, char: string): number;
|
|
14
|
+
declare function codeFenceFor(literal: string, fenceChar: string): string;
|
|
15
|
+
declare const QUOTABLE_STYLE_IDS: ReadonlySet<string>;
|
|
16
|
+
declare function isQuotableStyle(styleId: string | undefined): boolean;
|
|
17
|
+
declare function terminatesCleanly(styleId: string | undefined): boolean;
|
|
18
|
+
declare const BLANK_OR_WHITESPACE_ONLY_LINE: RegExp;
|
|
19
|
+
declare function firstContentLineIndex(text: string): number;
|
|
20
|
+
declare function leadingIndentReachesCodeThreshold(line: string): boolean;
|
|
21
|
+
declare const MAX_LEADING_BLANK_LINES_FOR_SETEXT = 1;
|
|
22
|
+
declare function interruptsSetextParagraph(line: string, atBlockStart: boolean): boolean;
|
|
23
|
+
declare function tableDelimiterRowPromotesPrecedingLine(line: string, precedingLine: string): boolean;
|
|
24
|
+
type UnsafeSetextBreakReason = "leading-indentation" | "blank-line" | "interrupting-line" | undefined;
|
|
25
|
+
declare function unsafeSetextBreakReason(text: string): UnsafeSetextBreakReason;
|
|
26
|
+
declare function embedsUnsafeBreakForSetext(text: string): boolean;
|
|
27
|
+
declare function unsafeSetextDiagnosticMessage(level: number, reason: UnsafeSetextBreakReason, embedsLineBreak: boolean): string;
|
|
28
|
+
declare function willRenderAsSetext(paragraph: ContentParagraph, level: number, context: EmitContext): boolean;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { BLANK_OR_WHITESPACE_ONLY_LINE, MAX_LEADING_BLANK_LINES_FOR_SETEXT, MAX_SETEXT_LEVEL, MIN_CODE_FENCE_LENGTH, MIN_SETEXT_UNDERLINE_LENGTH, QUOTABLE_STYLE_IDS, SETEXT_LEVEL_1_CHAR, SETEXT_LEVEL_2_CHAR, THEMATIC_BREAK_CHAR_COUNT, codeFenceFor, embedsUnsafeBreakForSetext, firstContentLineIndex, interruptsSetextParagraph, isQuotableStyle, leadingIndentReachesCodeThreshold, longestRunLength, renderAtxHeading, renderSetextHeading, splitLines, tableDelimiterRowPromotesPrecedingLine, terminatesCleanly, unsafeSetextBreakReason, unsafeSetextDiagnosticMessage, willRenderAsSetext };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EmitContext } from "./emit.js";
|
|
2
|
+
import { ContentParagraph } from "document-schema.js";
|
|
3
|
+
//#region src/emit/setext.d.ts
|
|
4
|
+
declare const MAX_SETEXT_LEVEL = 2;
|
|
5
|
+
declare const SETEXT_LEVEL_1_CHAR = "=";
|
|
6
|
+
declare const SETEXT_LEVEL_2_CHAR = "-";
|
|
7
|
+
declare const MIN_SETEXT_UNDERLINE_LENGTH = 1;
|
|
8
|
+
declare function splitLines(text: string, pattern: string | RegExp): readonly [string, ...string[]];
|
|
9
|
+
declare function renderSetextHeading(level: number, text: string): string;
|
|
10
|
+
declare function renderAtxHeading(level: number, text: string): string;
|
|
11
|
+
declare const MIN_CODE_FENCE_LENGTH = 3;
|
|
12
|
+
declare const THEMATIC_BREAK_CHAR_COUNT = 3;
|
|
13
|
+
declare function longestRunLength(text: string, char: string): number;
|
|
14
|
+
declare function codeFenceFor(literal: string, fenceChar: string): string;
|
|
15
|
+
declare const QUOTABLE_STYLE_IDS: ReadonlySet<string>;
|
|
16
|
+
declare function isQuotableStyle(styleId: string | undefined): boolean;
|
|
17
|
+
declare function terminatesCleanly(styleId: string | undefined): boolean;
|
|
18
|
+
declare const BLANK_OR_WHITESPACE_ONLY_LINE: RegExp;
|
|
19
|
+
declare function firstContentLineIndex(text: string): number;
|
|
20
|
+
declare function leadingIndentReachesCodeThreshold(line: string): boolean;
|
|
21
|
+
declare const MAX_LEADING_BLANK_LINES_FOR_SETEXT = 1;
|
|
22
|
+
declare function interruptsSetextParagraph(line: string, atBlockStart: boolean): boolean;
|
|
23
|
+
declare function tableDelimiterRowPromotesPrecedingLine(line: string, precedingLine: string): boolean;
|
|
24
|
+
type UnsafeSetextBreakReason = "leading-indentation" | "blank-line" | "interrupting-line" | undefined;
|
|
25
|
+
declare function unsafeSetextBreakReason(text: string): UnsafeSetextBreakReason;
|
|
26
|
+
declare function embedsUnsafeBreakForSetext(text: string): boolean;
|
|
27
|
+
declare function unsafeSetextDiagnosticMessage(level: number, reason: UnsafeSetextBreakReason, embedsLineBreak: boolean): string;
|
|
28
|
+
declare function willRenderAsSetext(paragraph: ContentParagraph, level: number, context: EmitContext): boolean;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { BLANK_OR_WHITESPACE_ONLY_LINE, MAX_LEADING_BLANK_LINES_FOR_SETEXT, MAX_SETEXT_LEVEL, MIN_CODE_FENCE_LENGTH, MIN_SETEXT_UNDERLINE_LENGTH, QUOTABLE_STYLE_IDS, SETEXT_LEVEL_1_CHAR, SETEXT_LEVEL_2_CHAR, THEMATIC_BREAK_CHAR_COUNT, codeFenceFor, embedsUnsafeBreakForSetext, firstContentLineIndex, interruptsSetextParagraph, isQuotableStyle, leadingIndentReachesCodeThreshold, longestRunLength, renderAtxHeading, renderSetextHeading, splitLines, tableDelimiterRowPromotesPrecedingLine, terminatesCleanly, unsafeSetextBreakReason, unsafeSetextDiagnosticMessage, willRenderAsSetext };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { NOOP_MARKDOWN_DIAGNOSTIC_SINK } from "../diagnostics/diagnostics.js";
|
|
2
|
+
import { matchHtmlBlockStart } from "../html/html.js";
|
|
3
|
+
import { ESCAPED_HARD_BREAK_PATTERN, LINE_ENDING_PATTERN } from "../shared/line-ending.js";
|
|
4
|
+
import { LineCursor } from "../block/line.js";
|
|
5
|
+
import { parseListMarker } from "../block/list.js";
|
|
6
|
+
import { parseTableDelimiterRow, splitTableRow } from "../block/table.js";
|
|
7
|
+
import { c as MATH_BLOCK_MARKER_PATTERN, h as THEMATIC_BREAK_PATTERN, n as ATX_MARKER_PATTERN, o as CODE_FENCE_PATTERN } from "../block-C3ftt8qO.js";
|
|
8
|
+
import { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MATH_BLOCK_STYLE_ID, QUOTE_STYLE_ID, parseHeadingStyleId } from "../shared/style-constants.js";
|
|
9
|
+
import { emitRuns } from "./inline.js";
|
|
10
|
+
//#region src/emit/setext.ts
|
|
11
|
+
const MAX_SETEXT_LEVEL = 2;
|
|
12
|
+
const SETEXT_LEVEL_1_CHAR = "=";
|
|
13
|
+
const SETEXT_LEVEL_2_CHAR = "-";
|
|
14
|
+
const MIN_SETEXT_UNDERLINE_LENGTH = 1;
|
|
15
|
+
function splitLines(text, pattern) {
|
|
16
|
+
const [first, ...rest] = text.split(pattern);
|
|
17
|
+
return [first, ...rest];
|
|
18
|
+
}
|
|
19
|
+
function renderSetextHeading(level, text) {
|
|
20
|
+
const underlineChar = level === 1 ? "=" : "-";
|
|
21
|
+
const [firstLine] = splitLines(text, LINE_ENDING_PATTERN);
|
|
22
|
+
return `${text}\n${underlineChar.repeat(Math.max(1, firstLine.length))}`;
|
|
23
|
+
}
|
|
24
|
+
function renderAtxHeading(level, text) {
|
|
25
|
+
const collapsed = text.replace(ESCAPED_HARD_BREAK_PATTERN, " ").split(LINE_ENDING_PATTERN).join(" ");
|
|
26
|
+
return `${"#".repeat(level)} ${collapsed}`;
|
|
27
|
+
}
|
|
28
|
+
const MIN_CODE_FENCE_LENGTH = 3;
|
|
29
|
+
const THEMATIC_BREAK_CHAR_COUNT = 3;
|
|
30
|
+
function longestRunLength(text, char) {
|
|
31
|
+
let longest = 0;
|
|
32
|
+
let current = 0;
|
|
33
|
+
for (const candidate of text) if (candidate === char) {
|
|
34
|
+
current += 1;
|
|
35
|
+
longest = Math.max(longest, current);
|
|
36
|
+
} else current = 0;
|
|
37
|
+
return longest;
|
|
38
|
+
}
|
|
39
|
+
function codeFenceFor(literal, fenceChar) {
|
|
40
|
+
return fenceChar.repeat(Math.max(3, longestRunLength(literal, fenceChar) + 1));
|
|
41
|
+
}
|
|
42
|
+
const QUOTABLE_STYLE_IDS = /* @__PURE__ */ new Set([
|
|
43
|
+
QUOTE_STYLE_ID,
|
|
44
|
+
CODE_BLOCK_STYLE_ID,
|
|
45
|
+
HORIZONTAL_RULE_STYLE_ID,
|
|
46
|
+
HTML_PREFORMATTED_STYLE_ID,
|
|
47
|
+
MATH_BLOCK_STYLE_ID
|
|
48
|
+
]);
|
|
49
|
+
function isQuotableStyle(styleId) {
|
|
50
|
+
if (styleId === void 0) return false;
|
|
51
|
+
return QUOTABLE_STYLE_IDS.has(styleId) || parseHeadingStyleId(styleId) !== void 0;
|
|
52
|
+
}
|
|
53
|
+
function terminatesCleanly(styleId) {
|
|
54
|
+
return styleId === "CodeBlock" || styleId === "MathBlock" || styleId === "HorizontalRule" || styleId !== void 0 && parseHeadingStyleId(styleId) !== void 0;
|
|
55
|
+
}
|
|
56
|
+
const BLANK_OR_WHITESPACE_ONLY_LINE = /^[ \t]*$/;
|
|
57
|
+
function firstContentLineIndex(text) {
|
|
58
|
+
return text.split(LINE_ENDING_PATTERN).findIndex((line) => !BLANK_OR_WHITESPACE_ONLY_LINE.test(line));
|
|
59
|
+
}
|
|
60
|
+
function leadingIndentReachesCodeThreshold(line) {
|
|
61
|
+
let column = 0;
|
|
62
|
+
while (line[column] === " ") column += 1;
|
|
63
|
+
if (column >= 4) return true;
|
|
64
|
+
return line[column] === " ";
|
|
65
|
+
}
|
|
66
|
+
const MAX_LEADING_BLANK_LINES_FOR_SETEXT = 1;
|
|
67
|
+
function interruptsSetextParagraph(line, atBlockStart) {
|
|
68
|
+
const cursor = new LineCursor(line);
|
|
69
|
+
if (cursor.indented) return false;
|
|
70
|
+
if (cursor.peekNextNonspace() === ">") return true;
|
|
71
|
+
const rest = cursor.restFromNextNonspace();
|
|
72
|
+
if (ATX_MARKER_PATTERN.test(rest) || CODE_FENCE_PATTERN.test(rest) || THEMATIC_BREAK_PATTERN.test(rest) || MATH_BLOCK_MARKER_PATTERN.test(rest) || matchHtmlBlockStart(rest, !atBlockStart) !== void 0) return true;
|
|
73
|
+
return parseListMarker(cursor, !atBlockStart) !== void 0;
|
|
74
|
+
}
|
|
75
|
+
function tableDelimiterRowPromotesPrecedingLine(line, precedingLine) {
|
|
76
|
+
const cursor = new LineCursor(line);
|
|
77
|
+
if (cursor.indented) return false;
|
|
78
|
+
return parseTableDelimiterRow(cursor.restFromNextNonspace())?.length === splitTableRow(precedingLine).length;
|
|
79
|
+
}
|
|
80
|
+
function unsafeSetextBreakReason(text) {
|
|
81
|
+
let leadingBlankLines = 0;
|
|
82
|
+
let precedingLine;
|
|
83
|
+
for (const line of text.split(LINE_ENDING_PATTERN)) {
|
|
84
|
+
const isBlank = BLANK_OR_WHITESPACE_ONLY_LINE.test(line);
|
|
85
|
+
if (precedingLine === void 0) {
|
|
86
|
+
if (isBlank) {
|
|
87
|
+
leadingBlankLines += 1;
|
|
88
|
+
if (leadingBlankLines > 1) return "blank-line";
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (leadingIndentReachesCodeThreshold(line)) return "leading-indentation";
|
|
92
|
+
if (interruptsSetextParagraph(line, true)) return "interrupting-line";
|
|
93
|
+
precedingLine = line;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (isBlank) return "blank-line";
|
|
97
|
+
if (interruptsSetextParagraph(line, false) || tableDelimiterRowPromotesPrecedingLine(line, precedingLine)) return "interrupting-line";
|
|
98
|
+
precedingLine = line;
|
|
99
|
+
}
|
|
100
|
+
return precedingLine === void 0 ? "blank-line" : void 0;
|
|
101
|
+
}
|
|
102
|
+
function embedsUnsafeBreakForSetext(text) {
|
|
103
|
+
return unsafeSetextBreakReason(text) !== void 0;
|
|
104
|
+
}
|
|
105
|
+
function unsafeSetextDiagnosticMessage(level, reason, embedsLineBreak) {
|
|
106
|
+
const hazard = reason === "leading-indentation" ? `the line that would become the setext heading's own first line of text opens with 4 or more columns of space/tab indentation — setext's own grammar (spec 0.31.2) requires the first line to have "not more than 3 spaces of indentation", so promoting would read that line back as an indented code block instead of heading text` : reason === "interrupting-line" ? `a line of the heading's own text — including possibly its first — would itself be interpretable as a code fence, ATX heading, block quote, thematic break, list item, HTML block, math block, or GFM table delimiter row — setext's own grammar (spec 0.31.2) requires every one of the heading's lines to instead read as ordinary paragraph text, so promoting would read that line back as the start of a fresh, unrelated block (or, for a table delimiter row, a conversion of the line before it) rather than more of the heading` : `promoting would leave the setext underline with no heading text of its own to attach to — either a blank line immediately before it (a trailing break), a blank line in the middle of the heading's own text (a genuinely interior break), or the heading's own rendered text being entirely blank to begin with — setext's own grammar requires "one or more lines of text, not interrupted by a blank line"`;
|
|
107
|
+
return embedsLineBreak ? `a level ${String(level)} heading's own content contains a line break, but ${hazard}; ATX collapses the break to a single space instead of promoting into a corrupt reparse` : `the effective WriteMarkdownOptions.headingStyle is 'setext' (an explicit caller choice — a break-free heading only reaches this path when requested outright), but ${hazard}; rendered as ATX instead of promoting into a corrupt reparse`;
|
|
108
|
+
}
|
|
109
|
+
function willRenderAsSetext(paragraph, level, context) {
|
|
110
|
+
if (level > 2) return false;
|
|
111
|
+
const text = emitRuns(paragraph.runs, {
|
|
112
|
+
sink: NOOP_MARKDOWN_DIAGNOSTIC_SINK,
|
|
113
|
+
emphasisMarker: context.emphasisMarker
|
|
114
|
+
}, paragraph.constructs);
|
|
115
|
+
if (embedsUnsafeBreakForSetext(text)) return false;
|
|
116
|
+
return context.headingStyle === "setext" || LINE_ENDING_PATTERN.test(text);
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { BLANK_OR_WHITESPACE_ONLY_LINE, MAX_LEADING_BLANK_LINES_FOR_SETEXT, MAX_SETEXT_LEVEL, MIN_CODE_FENCE_LENGTH, MIN_SETEXT_UNDERLINE_LENGTH, QUOTABLE_STYLE_IDS, SETEXT_LEVEL_1_CHAR, SETEXT_LEVEL_2_CHAR, THEMATIC_BREAK_CHAR_COUNT, codeFenceFor, embedsUnsafeBreakForSetext, firstContentLineIndex, interruptsSetextParagraph, isQuotableStyle, leadingIndentReachesCodeThreshold, longestRunLength, renderAtxHeading, renderSetextHeading, splitLines, tableDelimiterRowPromotesPrecedingLine, terminatesCleanly, unsafeSetextBreakReason, unsafeSetextDiagnosticMessage, willRenderAsSetext };
|
package/dist/emit/table.d.cts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as InlineEmitContext } from "../inline-DEF-eo9X.cjs";
|
|
3
|
-
import { ContentTable } from "document-schema.js";
|
|
4
|
-
//#region src/emit/table.d.ts
|
|
5
|
-
interface TableEmitContext extends InlineEmitContext {
|
|
6
|
-
readonly sink: MarkdownDiagnosticSink;
|
|
7
|
-
readonly embedImages: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare function emitTable(table: ContentTable, context: TableEmitContext): string;
|
|
10
|
-
declare function assertNeverAlignment(alignment: never): never;
|
|
11
|
-
//#endregion
|
|
1
|
+
import { n as assertNeverAlignment, r as emitTable, t as TableEmitContext } from "../table-PtkYEYdL.cjs";
|
|
12
2
|
export { TableEmitContext, assertNeverAlignment, emitTable };
|
package/dist/emit/table.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as InlineEmitContext } from "../inline-CGUpYV28.js";
|
|
3
|
-
import { ContentTable } from "document-schema.js";
|
|
4
|
-
//#region src/emit/table.d.ts
|
|
5
|
-
interface TableEmitContext extends InlineEmitContext {
|
|
6
|
-
readonly sink: MarkdownDiagnosticSink;
|
|
7
|
-
readonly embedImages: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare function emitTable(table: ContentTable, context: TableEmitContext): string;
|
|
10
|
-
declare function assertNeverAlignment(alignment: never): never;
|
|
11
|
-
//#endregion
|
|
1
|
+
import { n as assertNeverAlignment, r as emitTable, t as TableEmitContext } from "../table-BFbOhm0R.js";
|
|
12
2
|
export { TableEmitContext, assertNeverAlignment, emitTable };
|