@effected/markdown 0.19.0 → 0.21.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/Frontmatter.js +4 -5
- package/FrontmatterResolver.js +4 -6
- package/FrontmatterSource.js +1 -2
- package/JsonFrontmatter.js +1 -2
- package/Markdown.js +1 -2
- package/MarkdownDiagnostic.js +1 -2
- package/MarkdownDocument.js +23 -15
- package/MarkdownEdit.js +1 -2
- package/MarkdownFormat.js +1 -2
- package/MarkdownNode.js +1 -2
- package/MarkdownTransform.js +1 -2
- package/MarkdownVisitor.js +58 -19
- package/Mdast.js +28 -13
- package/README.md +26 -8
- package/TomlFrontmatter.js +1 -2
- package/YamlFrontmatter.js +1 -2
- package/index.d.ts +87 -54
- package/internal/blockParser.js +1 -2
- package/internal/blockRegistry.js +1 -2
- package/internal/blockTypes.js +1 -2
- package/internal/blocks/atxHeading.js +1 -2
- package/internal/blocks/blockquote.js +1 -2
- package/internal/blocks/code.js +1 -2
- package/internal/blocks/document.js +1 -2
- package/internal/blocks/fencedCode.js +1 -2
- package/internal/blocks/footnoteDefinition.js +1 -2
- package/internal/blocks/frontmatter.js +1 -2
- package/internal/blocks/htmlBlock.js +1 -2
- package/internal/blocks/indentedCode.js +1 -2
- package/internal/blocks/linkReferenceDefinition.js +1 -2
- package/internal/blocks/list.js +1 -2
- package/internal/blocks/paragraph.js +1 -2
- package/internal/blocks/setextHeading.js +1 -2
- package/internal/blocks/table.js +1 -2
- package/internal/blocks/taskListItem.js +1 -2
- package/internal/blocks/thematicBreak.js +1 -2
- package/internal/carriers.js +1 -2
- package/internal/entities.js +1 -2
- package/internal/entityMap.js +1 -2
- package/internal/htmlTags.js +1 -2
- package/internal/inlineNode.js +1 -2
- package/internal/inlineParser.js +1 -2
- package/internal/inlineRegistry.js +1 -2
- package/internal/inlines/autolink.js +1 -2
- package/internal/inlines/autolinkLiteral.js +1 -2
- package/internal/inlines/codeSpan.js +1 -2
- package/internal/inlines/emphasis.js +1 -2
- package/internal/inlines/entity.js +1 -2
- package/internal/inlines/escape.js +1 -2
- package/internal/inlines/footnoteReference.js +1 -2
- package/internal/inlines/lineBreak.js +1 -2
- package/internal/inlines/link.js +1 -2
- package/internal/inlines/rawHtml.js +1 -2
- package/internal/inlines/strikethrough.js +1 -2
- package/internal/inlines/text.js +1 -2
- package/internal/lineIndex.js +1 -2
- package/internal/patterns.js +1 -2
- package/internal/phrasing.js +1 -2
- package/internal/preprocess.js +1 -2
- package/internal/rawInline.js +1 -2
- package/internal/references.js +1 -2
- package/internal/sectionBounds.js +1 -2
- package/internal/segments.js +1 -2
- package/internal/stringify.js +1 -2
- package/internal/unescape.js +1 -2
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Data, Effect, Result, Schema, Stream } from "effect";
|
|
2
|
-
//#region src/MarkdownNode.d.ts
|
|
1
|
+
import { Data, Effect, Option, Result, Schema, Stream } from "effect";
|
|
3
2
|
declare const Point_base: Schema.Class<Point, Schema.Struct<{
|
|
4
3
|
readonly line: Schema.Number;
|
|
5
4
|
readonly column: Schema.Number;
|
|
@@ -941,8 +940,6 @@ type MarkdownNodeType = MarkdownNode["type"];
|
|
|
941
940
|
type MarkdownNodeOfType<T extends MarkdownNodeType> = Extract<MarkdownNode, {
|
|
942
941
|
readonly type: T;
|
|
943
942
|
}>;
|
|
944
|
-
//#endregion
|
|
945
|
-
//#region src/MarkdownDiagnostic.d.ts
|
|
946
943
|
/**
|
|
947
944
|
* Error codes `Markdown.parse`/`MarkdownDocument.parse` can fail with.
|
|
948
945
|
* Currently exactly one, `"NestingDepthExceeded"`, the hardening-guard trip;
|
|
@@ -999,8 +996,6 @@ export declare class MarkdownDiagnostic extends MarkdownDiagnostic_base {
|
|
|
999
996
|
readonly length: number;
|
|
1000
997
|
}): MarkdownDiagnostic;
|
|
1001
998
|
}
|
|
1002
|
-
//#endregion
|
|
1003
|
-
//#region src/Markdown.d.ts
|
|
1004
999
|
/**
|
|
1005
1000
|
* The markdown dialects the parser can be pointed at. `"gfm"` — CommonMark
|
|
1006
1001
|
* 0.31.2 plus the GitHub extensions (tables, strikethrough, autolink
|
|
@@ -1354,8 +1349,6 @@ export declare class Markdown {
|
|
|
1354
1349
|
*/
|
|
1355
1350
|
static readonly MarkdownFromString: Schema.Codec<Root, string>;
|
|
1356
1351
|
}
|
|
1357
|
-
//#endregion
|
|
1358
|
-
//#region src/MarkdownEdit.d.ts
|
|
1359
1352
|
/**
|
|
1360
1353
|
* A single path segment: a `number` for child indices in the node tree, or a
|
|
1361
1354
|
* `string` for named addressing (reserved, e.g. for definition identifiers).
|
|
@@ -1412,8 +1405,6 @@ export declare class MarkdownEdit extends MarkdownEdit_base {
|
|
|
1412
1405
|
*/
|
|
1413
1406
|
static applyAll(text: string, edits: ReadonlyArray<MarkdownEdit>): string;
|
|
1414
1407
|
}
|
|
1415
|
-
//#endregion
|
|
1416
|
-
//#region src/MarkdownDocument.d.ts
|
|
1417
1408
|
/**
|
|
1418
1409
|
* A heading entry from {@link MarkdownDocument.headings}: the {@link Heading}
|
|
1419
1410
|
* node plus the derivations navigation wants — its `depth` and its plain-text
|
|
@@ -1598,27 +1589,34 @@ declare const MarkdownDocument_base: Schema.Class<MarkdownDocument, Schema.Struc
|
|
|
1598
1589
|
*/
|
|
1599
1590
|
export declare class MarkdownDocument extends MarkdownDocument_base {
|
|
1600
1591
|
/**
|
|
1601
|
-
* The document's frontmatter capture, or `
|
|
1592
|
+
* The document's frontmatter capture, or `Option.none()` when there is
|
|
1593
|
+
* none.
|
|
1602
1594
|
*
|
|
1603
1595
|
* @remarks
|
|
1604
1596
|
* Derived from the tree rather than stored: a {@link Frontmatter} node can
|
|
1605
1597
|
* only ever sit at the head of `root.children` (the capture fires at most
|
|
1606
1598
|
* once, at offset 0), so the tree is the single source of truth and the
|
|
1607
|
-
* accessor can never disagree with it. `
|
|
1608
|
-
* with no frontmatter block and one parsed with the capture toggle
|
|
1609
|
-
* {@link MarkdownDocument.hasFrontmatterBlock} tells the two apart.
|
|
1599
|
+
* accessor can never disagree with it. `Option.none()` covers both a
|
|
1600
|
+
* document with no frontmatter block and one parsed with the capture toggle
|
|
1601
|
+
* off — {@link MarkdownDocument.hasFrontmatterBlock} tells the two apart.
|
|
1602
|
+
*
|
|
1603
|
+
* An `Option` rather than `Frontmatter | undefined` because this is a
|
|
1604
|
+
* lookup that can miss, and the kit's lookups return `Option` — the same
|
|
1605
|
+
* shape as the sibling format packages' tree lookups (`JsoncNode.find`,
|
|
1606
|
+
* `YamlNode.find`). A derived getter is a lookup, not a data field: it
|
|
1607
|
+
* recomputes from the tree on every access.
|
|
1610
1608
|
*/
|
|
1611
|
-
get frontmatter(): Frontmatter
|
|
1609
|
+
get frontmatter(): Option.Option<Frontmatter>;
|
|
1612
1610
|
/**
|
|
1613
1611
|
* Whether the source opens with a well-formed frontmatter block —
|
|
1614
1612
|
* regardless of how the document was parsed.
|
|
1615
1613
|
*
|
|
1616
1614
|
* @remarks
|
|
1617
1615
|
* The structural signal that disambiguates the `frontmatter` accessor's
|
|
1618
|
-
* `
|
|
1616
|
+
* `Option.none()`: capture is opt-in (`MarkdownParseOptions.frontmatter`
|
|
1619
1617
|
* defaults off), so a document whose source visibly starts with `---` can
|
|
1620
1618
|
* still carry no capture node — spec-correct CommonMark reads the fences as
|
|
1621
|
-
* a thematic break plus content.
|
|
1619
|
+
* a thematic break plus content. An empty `frontmatter` with
|
|
1622
1620
|
* `hasFrontmatterBlock === true` means exactly "parsed with capture off";
|
|
1623
1621
|
* with `false` it means the source genuinely has no block.
|
|
1624
1622
|
*
|
|
@@ -1665,9 +1663,10 @@ export declare class MarkdownDocument extends MarkdownDocument_base {
|
|
|
1665
1663
|
* document repeatedly should bind `document.sections` once instead.
|
|
1666
1664
|
*
|
|
1667
1665
|
* @param options - Depth restriction.
|
|
1668
|
-
* @returns The first matching section, or `
|
|
1666
|
+
* @returns The first matching section, or `Option.none()` when no section
|
|
1667
|
+
* matches.
|
|
1669
1668
|
*/
|
|
1670
|
-
firstSection(options?: SectionQueryOptions): DocumentSection
|
|
1669
|
+
firstSection(options?: SectionQueryOptions): Option.Option<DocumentSection>;
|
|
1671
1670
|
/**
|
|
1672
1671
|
* The first section whose heading matches, in document order.
|
|
1673
1672
|
*
|
|
@@ -1683,9 +1682,10 @@ export declare class MarkdownDocument extends MarkdownDocument_base {
|
|
|
1683
1682
|
*
|
|
1684
1683
|
* @param match - A string, a RegExp, or a predicate.
|
|
1685
1684
|
* @param options - Depth restriction, applied before matching.
|
|
1686
|
-
* @returns The first matching section, or `
|
|
1685
|
+
* @returns The first matching section, or `Option.none()` when no section
|
|
1686
|
+
* matches.
|
|
1687
1687
|
*/
|
|
1688
|
-
sectionByHeading(match: SectionHeadingMatch, options?: SectionQueryOptions): DocumentSection
|
|
1688
|
+
sectionByHeading(match: SectionHeadingMatch, options?: SectionQueryOptions): Option.Option<DocumentSection>;
|
|
1689
1689
|
/**
|
|
1690
1690
|
* Every link-bearing node in the document, in document order: links,
|
|
1691
1691
|
* images, definitions, and the reference forms resolved through the
|
|
@@ -1706,7 +1706,7 @@ export declare class MarkdownDocument extends MarkdownDocument_base {
|
|
|
1706
1706
|
*
|
|
1707
1707
|
* @remarks
|
|
1708
1708
|
* A string selector matches on the node's `type` tag and narrows the
|
|
1709
|
-
* result (`find("heading")` is `Heading
|
|
1709
|
+
* result (`find("heading")` is `Option<Heading>`); a type-guard
|
|
1710
1710
|
* predicate narrows the same way, and a plain predicate returns the wide
|
|
1711
1711
|
* `MarkdownNode` union. The returned node is the document's own — matched
|
|
1712
1712
|
* and returnable by identity, so it feeds `MarkdownFormat.modify`
|
|
@@ -1715,11 +1715,12 @@ export declare class MarkdownDocument extends MarkdownDocument_base {
|
|
|
1715
1715
|
* hand-built or foreign decoded tree) is a thrown defect.
|
|
1716
1716
|
*
|
|
1717
1717
|
* @param selector - A node `type` tag or a predicate over nodes.
|
|
1718
|
-
* @returns The first matching node in document order, or `
|
|
1718
|
+
* @returns The first matching node in document order, or `Option.none()`
|
|
1719
|
+
* when none matches.
|
|
1719
1720
|
*/
|
|
1720
|
-
find<T extends MarkdownNodeType>(selector: T): MarkdownNodeOfType<T
|
|
1721
|
-
find<T extends MarkdownNode>(selector: (node: MarkdownNode) => node is T): T
|
|
1722
|
-
find(selector: (node: MarkdownNode) => boolean): MarkdownNode
|
|
1721
|
+
find<T extends MarkdownNodeType>(selector: T): Option.Option<MarkdownNodeOfType<T>>;
|
|
1722
|
+
find<T extends MarkdownNode>(selector: (node: MarkdownNode) => node is T): Option.Option<T>;
|
|
1723
|
+
find(selector: (node: MarkdownNode) => boolean): Option.Option<MarkdownNode>;
|
|
1723
1724
|
/**
|
|
1724
1725
|
* Find every node matching a selector, in document pre-order — the same
|
|
1725
1726
|
* order {@link MarkdownVisitor} enters nodes, starting at the root itself.
|
|
@@ -1767,8 +1768,6 @@ export declare class MarkdownDocument extends MarkdownDocument_base {
|
|
|
1767
1768
|
*/
|
|
1768
1769
|
static readonly parse: (text: string, options?: MarkdownParseOptions | undefined) => Effect.Effect<MarkdownDocument, MarkdownParseError, never>;
|
|
1769
1770
|
}
|
|
1770
|
-
//#endregion
|
|
1771
|
-
//#region src/Frontmatter.d.ts
|
|
1772
1771
|
declare const FrontmatterFormatMismatchError_base: Schema.Class<FrontmatterFormatMismatchError, Schema.TaggedStruct<"FrontmatterFormatMismatchError", {
|
|
1773
1772
|
/** The format the codec decodes. */
|
|
1774
1773
|
readonly expected: Schema.Literals<readonly ["yaml", "toml", "json"]>;
|
|
@@ -2061,8 +2060,6 @@ export declare class MarkdownFrontmatter {
|
|
|
2061
2060
|
*/
|
|
2062
2061
|
static setToString<T, E, RD = never, RE = never>(schema: Schema.Codec<T, E, RD, RE>, codec: FrontmatterCodec): (document: MarkdownDocument, data: T) => Effect.Effect<string, FrontmatterWriteError, RE>;
|
|
2063
2062
|
}
|
|
2064
|
-
//#endregion
|
|
2065
|
-
//#region src/FrontmatterResolver.d.ts
|
|
2066
2063
|
declare const SchemaDeclarationByUrl_base: Schema.Class<SchemaDeclarationByUrl, Schema.TaggedStruct<"ByUrl", {
|
|
2067
2064
|
/** The URL as written in the declaration. */
|
|
2068
2065
|
readonly url: Schema.String;
|
|
@@ -2292,8 +2289,6 @@ export declare class SchemaResolver {
|
|
|
2292
2289
|
*/
|
|
2293
2290
|
static fromRegistry(registrations: Readonly<Record<string, Schema.Top>>): FrontmatterSchemaResolver;
|
|
2294
2291
|
}
|
|
2295
|
-
//#endregion
|
|
2296
|
-
//#region src/FrontmatterSource.d.ts
|
|
2297
2292
|
/**
|
|
2298
2293
|
* The three line-terminator spellings a fence line may end with. Recorded by
|
|
2299
2294
|
* {@link FrontmatterSource.split} as fidelity — what the source's fence
|
|
@@ -2430,8 +2425,6 @@ export declare class FrontmatterSource {
|
|
|
2430
2425
|
*/
|
|
2431
2426
|
static join(split: FrontmatterSourceSplit): string;
|
|
2432
2427
|
}
|
|
2433
|
-
//#endregion
|
|
2434
|
-
//#region src/JsonFrontmatter.d.ts
|
|
2435
2428
|
/**
|
|
2436
2429
|
* The json frontmatter codec, over `@effected/jsonc`.
|
|
2437
2430
|
*
|
|
@@ -2457,8 +2450,6 @@ export declare class FrontmatterSource {
|
|
|
2457
2450
|
* @public
|
|
2458
2451
|
*/
|
|
2459
2452
|
export declare const JsonFrontmatter: FrontmatterCodec;
|
|
2460
|
-
//#endregion
|
|
2461
|
-
//#region src/MarkdownFormat.d.ts
|
|
2462
2453
|
/**
|
|
2463
2454
|
* A range accepted at the `format`/`formatToString` call sites: either a
|
|
2464
2455
|
* {@link MarkdownRange} instance or a plain `{ offset, length }` literal (the
|
|
@@ -2672,8 +2663,6 @@ export declare class MarkdownFormat {
|
|
|
2672
2663
|
*/
|
|
2673
2664
|
static readonly modifyToString: (document: MarkdownDocument, target: MarkdownNode, replacement: string | MarkdownNode) => Effect.Effect<string, MarkdownModificationError, never>;
|
|
2674
2665
|
}
|
|
2675
|
-
//#endregion
|
|
2676
|
-
//#region src/MarkdownTransform.d.ts
|
|
2677
2666
|
/**
|
|
2678
2667
|
* The node `type` tags whose handler may change the node's type — the
|
|
2679
2668
|
* phrasing-only types, i.e. every member of `PhrasingContent` that is
|
|
@@ -2917,15 +2906,13 @@ export declare class MarkdownTransform {
|
|
|
2917
2906
|
*/
|
|
2918
2907
|
static sections(root: Root, options: SectionSpanOptions): ReadonlyArray<SectionSpan>;
|
|
2919
2908
|
}
|
|
2920
|
-
//#endregion
|
|
2921
|
-
//#region src/MarkdownVisitor.d.ts
|
|
2922
2909
|
/**
|
|
2923
2910
|
* The discriminated union of markdown visitor events, in document pre-order.
|
|
2924
2911
|
* `Enter` fires when the walk reaches a node, `Exit` when it leaves — for a
|
|
2925
2912
|
* leaf the two fire back to back. Every variant carries `path` (child
|
|
2926
2913
|
* indexes from the root; the root's own path is empty) and `depth`
|
|
2927
2914
|
* (zero-based; the root is 0). `Error` is terminal: it carries the
|
|
2928
|
-
* depth-guard diagnostic for a
|
|
2915
|
+
* depth-guard diagnostic for a hand-constructed tree nested past
|
|
2929
2916
|
* `MAX_NESTING_DEPTH` and nothing follows it.
|
|
2930
2917
|
*
|
|
2931
2918
|
* @public
|
|
@@ -3069,8 +3056,9 @@ export declare const MarkdownVisitorEvent: {
|
|
|
3069
3056
|
}, "_tag">;
|
|
3070
3057
|
};
|
|
3071
3058
|
/**
|
|
3072
|
-
* Walks a parsed markdown tree as a lazy
|
|
3073
|
-
* document pre-order.
|
|
3059
|
+
* Walks a parsed markdown tree as a lazy sequence of `Enter`/`Exit` events in
|
|
3060
|
+
* document pre-order — synchronously with {@link MarkdownVisitor.walk}, or as
|
|
3061
|
+
* a `Stream` with {@link MarkdownVisitor.visit}. Not instantiable.
|
|
3074
3062
|
*
|
|
3075
3063
|
* @example
|
|
3076
3064
|
* ```ts
|
|
@@ -3092,6 +3080,45 @@ export declare const MarkdownVisitorEvent: {
|
|
|
3092
3080
|
*/
|
|
3093
3081
|
export declare class MarkdownVisitor {
|
|
3094
3082
|
private constructor();
|
|
3083
|
+
/**
|
|
3084
|
+
* Walk `root` synchronously, as a lazy `Iterable` of `MarkdownVisitorEvent`
|
|
3085
|
+
* in document pre-order: `Enter` and `Exit` for every node including the
|
|
3086
|
+
* root and every leaf. The primitive {@link MarkdownVisitor.visit} is
|
|
3087
|
+
* defined in terms of, so the two yield the same events in the same order.
|
|
3088
|
+
*
|
|
3089
|
+
* @remarks
|
|
3090
|
+
* For callers that cannot suspend — a lint rule whose host calls it
|
|
3091
|
+
* synchronously, a getter, a non-Effect adapter. Events are produced on
|
|
3092
|
+
* demand: a `for…of` that `break`s stops the walk without visiting the
|
|
3093
|
+
* rest of the tree. The iterable is re-iterable — every `[Symbol.iterator]()`
|
|
3094
|
+
* call starts a fresh walk from the root, so binding the result once and
|
|
3095
|
+
* iterating it twice walks the tree twice, independently.
|
|
3096
|
+
*
|
|
3097
|
+
* Not named `walkResult`: it returns no `Result`, and the walk has no
|
|
3098
|
+
* failure channel to put in one. A hand-constructed tree nested past the
|
|
3099
|
+
* depth cap surfaces as a terminal `MarkdownVisitorEvent` `Error` event
|
|
3100
|
+
* carrying a `NestingDepthExceeded` {@link MarkdownDiagnostic}, after which
|
|
3101
|
+
* nothing is yielded — the same posture as `visit`. A tree produced by
|
|
3102
|
+
* `Markdown.parse` or decoded by `Mdast.fromMdast` can never trip it.
|
|
3103
|
+
*
|
|
3104
|
+
* @example
|
|
3105
|
+
* ```ts
|
|
3106
|
+
* import { Markdown, MarkdownVisitor } from "@effected/markdown";
|
|
3107
|
+
* import { Result } from "effect";
|
|
3108
|
+
*
|
|
3109
|
+
* const root = Result.getOrThrow(Markdown.parseResult("# Hi\n\ntext\n"));
|
|
3110
|
+
* const entered: Array<string> = [];
|
|
3111
|
+
* for (const event of MarkdownVisitor.walk(root)) {
|
|
3112
|
+
* if (event._tag === "Enter") entered.push(event.node.type);
|
|
3113
|
+
* }
|
|
3114
|
+
* console.log(entered);
|
|
3115
|
+
* // => ["root", "heading", "text", "paragraph", "text"]
|
|
3116
|
+
* ```
|
|
3117
|
+
*
|
|
3118
|
+
* @param root - The tree to walk.
|
|
3119
|
+
* @returns A lazy, re-iterable `Iterable` of `MarkdownVisitorEvent`.
|
|
3120
|
+
*/
|
|
3121
|
+
static walk(root: Root): Iterable<MarkdownVisitorEvent>;
|
|
3095
3122
|
/**
|
|
3096
3123
|
* Create a lazy `Stream` of `MarkdownVisitorEvent` walking `root` in
|
|
3097
3124
|
* document pre-order: `Enter` and `Exit` for every node including the
|
|
@@ -3102,10 +3129,15 @@ export declare class MarkdownVisitor {
|
|
|
3102
3129
|
* @remarks
|
|
3103
3130
|
* Infallible at the type level. A tree produced by `Markdown.parse` can
|
|
3104
3131
|
* never trip the walk's depth guard — the parser refuses deeper input —
|
|
3105
|
-
*
|
|
3106
|
-
*
|
|
3107
|
-
*
|
|
3108
|
-
*
|
|
3132
|
+
* and neither can a decoded foreign tree (`Mdast.fromMdast`), because the
|
|
3133
|
+
* decode boundary refuses it first; only a hand-constructed tree can trip
|
|
3134
|
+
* the guard. The trip surfaces as a terminal `MarkdownVisitorEvent`
|
|
3135
|
+
* `Error` event carrying a `NestingDepthExceeded` {@link MarkdownDiagnostic},
|
|
3136
|
+
* mirroring the typed failure `Markdown.stringify` produces for the same
|
|
3137
|
+
* tree.
|
|
3138
|
+
*
|
|
3139
|
+
* Defined as `Stream.fromIterable(MarkdownVisitor.walk(root))`: every run
|
|
3140
|
+
* of the stream walks afresh, and the two forms never diverge.
|
|
3109
3141
|
*
|
|
3110
3142
|
* @param root - The tree to walk.
|
|
3111
3143
|
* @returns A lazy `Stream` of `MarkdownVisitorEvent`, infallible at the type
|
|
@@ -3113,8 +3145,6 @@ export declare class MarkdownVisitor {
|
|
|
3113
3145
|
*/
|
|
3114
3146
|
static visit(root: Root): Stream.Stream<MarkdownVisitorEvent>;
|
|
3115
3147
|
}
|
|
3116
|
-
//#endregion
|
|
3117
|
-
//#region src/Mdast.d.ts
|
|
3118
3148
|
/**
|
|
3119
3149
|
* A plain mdast node: a `type` tag plus whatever fields that type carries.
|
|
3120
3150
|
*
|
|
@@ -3246,6 +3276,14 @@ export declare class Mdast {
|
|
|
3246
3276
|
* plain tree built for `Markdown.stringify` can carry it straight in. A
|
|
3247
3277
|
* value outside `"canonical" | "literal"` fails the decode typed.
|
|
3248
3278
|
*
|
|
3279
|
+
* **Nesting is capped at 256 levels below the root**, the same cap the
|
|
3280
|
+
* parser and `Markdown.stringify` enforce. A tree with any node deeper
|
|
3281
|
+
* than that, leaves included, fails typed with a `SchemaIssue.InvalidValue`
|
|
3282
|
+
* issue before the schema decode runs, so hostile depth is never a defect.
|
|
3283
|
+
* Because leaves count, a document the parser accepts can still be
|
|
3284
|
+
* refused here: `"> ".repeat(255) + "x"` parses, but its `text` leaf sits
|
|
3285
|
+
* at depth 257, and `Markdown.stringify` refuses that tree too.
|
|
3286
|
+
*
|
|
3249
3287
|
* @param input - A plain mdast tree, typically a `root`.
|
|
3250
3288
|
* @returns A `Result` succeeding with the decoded {@link Root}, or
|
|
3251
3289
|
* failing with {@link MdastDecodeError} carrying the structured issue.
|
|
@@ -3295,8 +3333,6 @@ export declare class Mdast {
|
|
|
3295
3333
|
*/
|
|
3296
3334
|
static toText(node: MarkdownNode, options?: MdastToTextOptions): string;
|
|
3297
3335
|
}
|
|
3298
|
-
//#endregion
|
|
3299
|
-
//#region src/TomlFrontmatter.d.ts
|
|
3300
3336
|
/**
|
|
3301
3337
|
* The toml frontmatter codec, over `@effected/toml`.
|
|
3302
3338
|
*
|
|
@@ -3320,8 +3356,6 @@ export declare class Mdast {
|
|
|
3320
3356
|
* @public
|
|
3321
3357
|
*/
|
|
3322
3358
|
export declare const TomlFrontmatter: FrontmatterCodec;
|
|
3323
|
-
//#endregion
|
|
3324
|
-
//#region src/YamlFrontmatter.d.ts
|
|
3325
3359
|
/**
|
|
3326
3360
|
* The yaml frontmatter codec, over `@effected/yaml`.
|
|
3327
3361
|
*
|
|
@@ -3346,6 +3380,5 @@ export declare const TomlFrontmatter: FrontmatterCodec;
|
|
|
3346
3380
|
* @public
|
|
3347
3381
|
*/
|
|
3348
3382
|
export declare const YamlFrontmatter: FrontmatterCodec;
|
|
3349
|
-
//#endregion
|
|
3350
3383
|
export type { DocumentHeading, DocumentLink, FrontmatterCodec, FrontmatterResolveError, FrontmatterSchemaError, FrontmatterSchemaResolver, FrontmatterWriteError, LinkBearingNode, MarkdownNodeOfType, MarkdownNodeType, MarkdownPath, MarkdownPhrasingOnlyType, MarkdownRangeLike, MarkdownSegment, MarkdownTransformHandlers, MarkdownTransformResult, MdastNode, MdastToTextOptions, SectionHeadingMatch, SectionQueryOptions, SectionSpan, SectionSpanOptions, ShiftHeadingsOptions };
|
|
3351
3384
|
//# sourceMappingURL=index.d.ts.map
|
package/internal/blockParser.js
CHANGED
|
@@ -8,7 +8,7 @@ import { GuardExceeded } from "./carriers.js";
|
|
|
8
8
|
import { LineIndex } from "./lineIndex.js";
|
|
9
9
|
import { prepareInline } from "./rawInline.js";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// src/internal/blockParser.ts
|
|
12
12
|
/** Upstream's cheap pre-filter: a line that cannot start any block. */
|
|
13
13
|
const reMaybeSpecial = /^[#`~*+_=<>0-9-]/;
|
|
14
14
|
var BlockParser = class {
|
|
@@ -415,5 +415,4 @@ var BlockParser = class {
|
|
|
415
415
|
*/
|
|
416
416
|
const parseBlocks = (text, dialect = "commonmark", frontmatter = false) => new BlockParser(text, blockDialect(dialect), dialect, frontmatter).parse();
|
|
417
417
|
|
|
418
|
-
//#endregion
|
|
419
418
|
export { parseBlocks };
|
|
@@ -14,7 +14,7 @@ import { tableCellConstruct, tableConstruct, tableHeaderStart, tableRowConstruct
|
|
|
14
14
|
import { taskListItemStart } from "./blocks/taskListItem.js";
|
|
15
15
|
import { thematicBreakConstruct, thematicBreakStart } from "./blocks/thematicBreak.js";
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// src/internal/blockRegistry.ts
|
|
18
18
|
const constructTable = (constructs) => new Map(constructs.map((construct) => [construct.type, construct]));
|
|
19
19
|
const commonmarkDialect = {
|
|
20
20
|
constructs: constructTable([
|
|
@@ -86,5 +86,4 @@ const blockDialect = (dialect) => {
|
|
|
86
86
|
return found;
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
//#endregion
|
|
90
89
|
export { blockDialect };
|
package/internal/blockTypes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/blockTypes.ts
|
|
2
2
|
/** Narrow materialized children to the flow content most constructs contain. */
|
|
3
3
|
const flowChildren = (children) => children.filter((child) => child.type !== "root" && child.type !== "listItem" && child.type !== "tableRow" && child.type !== "tableCell");
|
|
4
4
|
/** Narrow materialized children to the list items a list contains. */
|
|
@@ -23,5 +23,4 @@ const makeBlockNode = (type, startOffset, startLine, depth = 0) => ({
|
|
|
23
23
|
data: {}
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
//#endregion
|
|
27
26
|
export { flowChildren, listItemChildren, makeBlockNode, tableCellChildren, tableRowChildren };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Heading } from "../../MarkdownNode.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/blocks/atxHeading.ts
|
|
4
4
|
const reATXHeadingMarker = /^#{1,6}(?:[ \t]+|$)/;
|
|
5
5
|
const reOnlyTrailingHashes = /^[ \t]*#+[ \t]*$/;
|
|
6
6
|
const reClosingHashes = /[ \t]+#+[ \t]*$/;
|
|
@@ -50,5 +50,4 @@ const atxHeadingStart = {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
//#endregion
|
|
54
53
|
export { atxHeadingStart, headingConstruct };
|
|
@@ -2,7 +2,7 @@ import { Blockquote } from "../../MarkdownNode.js";
|
|
|
2
2
|
import { flowChildren } from "../blockTypes.js";
|
|
3
3
|
import { isSpaceOrTab, peekCode } from "../preprocess.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/internal/blocks/blockquote.ts
|
|
6
6
|
const C_GREATERTHAN = 62;
|
|
7
7
|
/** Blockquote: continues while each line carries its `>` marker. */
|
|
8
8
|
const blockquoteConstruct = {
|
|
@@ -36,5 +36,4 @@ const blockquoteStart = {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
//#endregion
|
|
40
39
|
export { blockquoteConstruct, blockquoteStart };
|
package/internal/blocks/code.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Code } from "../../MarkdownNode.js";
|
|
|
2
2
|
import { isSpaceOrTab, peekCode } from "../preprocess.js";
|
|
3
3
|
import { unescapeString } from "../unescape.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/internal/blocks/code.ts
|
|
6
6
|
const reBlankLine = /^[ \t]*$/;
|
|
7
7
|
const reClosingCodeFence = /^(?:`{3,}|~{3,})(?=[ \t]*$)/;
|
|
8
8
|
/**
|
|
@@ -86,5 +86,4 @@ const codeConstruct = {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
//#endregion
|
|
90
89
|
export { codeConstruct };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Root } from "../../MarkdownNode.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/blocks/document.ts
|
|
4
4
|
/** The document root: contains everything except a bare list item. */
|
|
5
5
|
const documentConstruct = {
|
|
6
6
|
type: "document",
|
|
@@ -13,5 +13,4 @@ const documentConstruct = {
|
|
|
13
13
|
})
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
//#endregion
|
|
17
16
|
export { documentConstruct };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/blocks/fencedCode.ts
|
|
2
2
|
const reCodeFence = /^`{3,}(?!.*`)|^~{3,}/;
|
|
3
3
|
const fenceCharOf = (char) => char === "`" || char === "~" ? char : void 0;
|
|
4
4
|
/** The fenced-code block start: three or more backticks or tildes. */
|
|
@@ -22,5 +22,4 @@ const fencedCodeStart = {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
//#endregion
|
|
26
25
|
export { fencedCodeStart };
|
|
@@ -3,7 +3,7 @@ import { flowChildren } from "../blockTypes.js";
|
|
|
3
3
|
import { stickyOf } from "../patterns.js";
|
|
4
4
|
import { normalizeLabelText } from "../references.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/internal/blocks/footnoteDefinition.ts
|
|
7
7
|
/**
|
|
8
8
|
* `_scan_footnote_definition` from `src/scanners.re`:
|
|
9
9
|
*
|
|
@@ -80,5 +80,4 @@ const footnoteDefinitionStart = {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
//#endregion
|
|
84
83
|
export { footnoteDefinitionConstruct, footnoteDefinitionStart };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/blocks/frontmatter.ts
|
|
2
2
|
const FENCES = /* @__PURE__ */ new Map([
|
|
3
3
|
["---", {
|
|
4
4
|
format: "yaml",
|
|
@@ -98,5 +98,4 @@ const scanRawFrontmatter = (source) => {
|
|
|
98
98
|
return null;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
//#endregion
|
|
102
101
|
export { scanFrontmatter, scanRawFrontmatter };
|
|
@@ -2,7 +2,7 @@ import { Html } from "../../MarkdownNode.js";
|
|
|
2
2
|
import { peekCode } from "../preprocess.js";
|
|
3
3
|
import { CLOSETAG, OPENTAG } from "../htmlTags.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/internal/blocks/htmlBlock.ts
|
|
6
6
|
const C_LESSTHAN = 60;
|
|
7
7
|
const reHtmlBlockOpen = [
|
|
8
8
|
/./,
|
|
@@ -68,5 +68,4 @@ const htmlBlockStart = {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
//#endregion
|
|
72
71
|
export { htmlBlockConstruct, htmlBlockStart, isHtmlBlockEnd };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/blocks/indentedCode.ts
|
|
2
2
|
/** The indented-code block start: four columns of indentation. */
|
|
3
3
|
const indentedCodeStart = {
|
|
4
4
|
name: "indentedCode",
|
|
@@ -12,5 +12,4 @@ const indentedCodeStart = {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
//#endregion
|
|
16
15
|
export { indentedCodeStart };
|
|
@@ -3,7 +3,7 @@ import { makeBlockNode } from "../blockTypes.js";
|
|
|
3
3
|
import { parseReference } from "../references.js";
|
|
4
4
|
import { sliceWithSegments, sourceOffsetAt } from "../segments.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/internal/blocks/linkReferenceDefinition.ts
|
|
7
7
|
const C_OPEN_BRACKET = 91;
|
|
8
8
|
/**
|
|
9
9
|
* Split every leading link reference definition out of `block`, inserting one
|
|
@@ -68,5 +68,4 @@ const definitionConstruct = {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
//#endregion
|
|
72
71
|
export { definitionConstruct, extractDefinitions };
|
package/internal/blocks/list.js
CHANGED
|
@@ -2,7 +2,7 @@ import { List, ListItem } from "../../MarkdownNode.js";
|
|
|
2
2
|
import { flowChildren, listItemChildren } from "../blockTypes.js";
|
|
3
3
|
import { isSpaceOrTab, peekCode } from "../preprocess.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/internal/blocks/list.ts
|
|
6
6
|
const reBulletListMarker = /^[*+-]/;
|
|
7
7
|
const reOrderedListMarker = /^(\d{1,9})([.)])/;
|
|
8
8
|
const reNonSpace = /[^ \t\f\v\r\n]/;
|
|
@@ -155,5 +155,4 @@ const listItemStart = {
|
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
-
//#endregion
|
|
159
158
|
export { listConstruct, listItemConstruct, listItemStart };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Paragraph } from "../../MarkdownNode.js";
|
|
2
2
|
import { extractDefinitions } from "./linkReferenceDefinition.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/internal/blocks/paragraph.ts
|
|
5
5
|
/** Paragraph: absorbs lines until a blank one, and contains nothing. */
|
|
6
6
|
const paragraphConstruct = {
|
|
7
7
|
type: "paragraph",
|
|
@@ -23,5 +23,4 @@ const paragraphConstruct = {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
//#endregion
|
|
27
26
|
export { paragraphConstruct };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { extractDefinitions } from "./linkReferenceDefinition.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/blocks/setextHeading.ts
|
|
4
4
|
const reSetextHeadingLine = /^(?:=+|-+)[ \t]*$/;
|
|
5
5
|
/** The setext heading block start: a run of `=` or `-` under a paragraph. */
|
|
6
6
|
const setextHeadingStart = {
|
|
@@ -20,5 +20,4 @@ const setextHeadingStart = {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
//#endregion
|
|
24
23
|
export { setextHeadingStart };
|
package/internal/blocks/table.js
CHANGED
|
@@ -3,7 +3,7 @@ import { tableCellChildren, tableRowChildren } from "../blockTypes.js";
|
|
|
3
3
|
import { ESCAPABLE } from "../unescape.js";
|
|
4
4
|
import { sliceWithSegments } from "../segments.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/internal/blocks/table.ts
|
|
7
7
|
/**
|
|
8
8
|
* Upstream's `MAX_AUTOCOMPLETED_CELLS`: the ceiling on cells the parser
|
|
9
9
|
* invents to pad short rows, which is what stops a wide header followed by a
|
|
@@ -374,5 +374,4 @@ const tableCellConstruct = {
|
|
|
374
374
|
}
|
|
375
375
|
};
|
|
376
376
|
|
|
377
|
-
//#endregion
|
|
378
377
|
export { tableCellConstruct, tableConstruct, tableHeaderStart, tableRowConstruct, tableRowStart };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/blocks/taskListItem.ts
|
|
2
2
|
/**
|
|
3
3
|
* `_scan_tasklist`, as the generated scanner accepts it.
|
|
4
4
|
*
|
|
@@ -32,5 +32,4 @@ const taskListItemStart = {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
//#endregion
|
|
36
35
|
export { taskListItemStart };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ThematicBreak } from "../../MarkdownNode.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/blocks/thematicBreak.ts
|
|
4
4
|
const reThematicBreak = /^(?:\*[ \t]*){3,}$|^(?:_[ \t]*){3,}$|^(?:-[ \t]*){3,}$/;
|
|
5
5
|
const markerCharOf = (char) => char === "-" || char === "_" || char === "*" ? char : void 0;
|
|
6
6
|
/** Thematic break: one line, no children. */
|
|
@@ -31,5 +31,4 @@ const thematicBreakStart = {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
//#endregion
|
|
35
34
|
export { thematicBreakConstruct, thematicBreakStart };
|
package/internal/carriers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/carriers.ts
|
|
2
2
|
/**
|
|
3
3
|
* The engine's error-code vocabulary: currently exactly one, the
|
|
4
4
|
* hardening-guard trip. Widens as new parse-error kinds are added.
|
|
@@ -38,5 +38,4 @@ var GuardExceeded = class extends Error {
|
|
|
38
38
|
/** Narrows `unknown` to {@link GuardExceeded}; never a bare `instanceof` at a call site. */
|
|
39
39
|
const isGuardExceeded = (u) => u instanceof GuardExceeded;
|
|
40
40
|
|
|
41
|
-
//#endregion
|
|
42
41
|
export { GuardExceeded, MARKDOWN_PARSE_ERROR_CODES, RawMarkdownError, isGuardExceeded, isRawMarkdownError };
|
package/internal/entities.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ENTITY_MAP } from "./entityMap.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/entities.ts
|
|
4
4
|
/** The largest code point Unicode defines. */
|
|
5
5
|
const MAX_CODE_POINT = 1114111;
|
|
6
6
|
/**
|
|
@@ -22,5 +22,4 @@ const decodeEntity = (entity) => {
|
|
|
22
22
|
return String.fromCodePoint(code);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
//#endregion
|
|
26
25
|
export { decodeEntity };
|