@driftsys/markspec 0.10.2 → 0.10.3
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/esm/decl/mod.d.ts +18 -0
- package/esm/decl/mod.d.ts.map +1 -0
- package/esm/decl/mod.js +14 -0
- package/esm/decl/resolve.d.ts +104 -0
- package/esm/decl/resolve.d.ts.map +1 -0
- package/esm/decl/resolve.js +66 -0
- package/esm/decl/surfaces.d.ts +96 -0
- package/esm/decl/surfaces.d.ts.map +1 -0
- package/esm/decl/surfaces.js +122 -0
- package/esm/decl/table.d.ts +50 -0
- package/esm/decl/table.d.ts.map +1 -0
- package/esm/decl/table.js +124 -0
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/parser/directives.d.ts +6 -0
- package/esm/parser/directives.d.ts.map +1 -1
- package/esm/parser/directives.js +17 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +9 -0
- package/esm/typl/bullet.d.ts +13 -23
- package/esm/typl/bullet.d.ts.map +1 -1
- package/esm/typl/bullet.js +6 -40
- package/esm/typl/fence.d.ts +12 -21
- package/esm/typl/fence.d.ts.map +1 -1
- package/esm/typl/fence.js +5 -20
- package/esm/typl/inline.d.ts +15 -24
- package/esm/typl/inline.d.ts.map +1 -1
- package/esm/typl/inline.js +6 -44
- package/esm/typl/recognize.d.ts +14 -0
- package/esm/typl/recognize.d.ts.map +1 -0
- package/esm/typl/recognize.js +19 -0
- package/esm/validator/body_blocks.d.ts.map +1 -1
- package/esm/validator/body_blocks.js +3 -9
- package/package.json +1 -1
- package/script/decl/mod.d.ts +18 -0
- package/script/decl/mod.d.ts.map +1 -0
- package/script/decl/mod.js +24 -0
- package/script/decl/resolve.d.ts +104 -0
- package/script/decl/resolve.d.ts.map +1 -0
- package/script/decl/resolve.js +70 -0
- package/script/decl/surfaces.d.ts +96 -0
- package/script/decl/surfaces.d.ts.map +1 -0
- package/script/decl/surfaces.js +128 -0
- package/script/decl/table.d.ts +50 -0
- package/script/decl/table.d.ts.map +1 -0
- package/script/decl/table.js +127 -0
- package/script/mod.d.ts +1 -1
- package/script/mod.js +1 -1
- package/script/parser/directives.d.ts +6 -0
- package/script/parser/directives.d.ts.map +1 -1
- package/script/parser/directives.js +18 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +9 -0
- package/script/typl/bullet.d.ts +13 -23
- package/script/typl/bullet.d.ts.map +1 -1
- package/script/typl/bullet.js +6 -40
- package/script/typl/fence.d.ts +12 -21
- package/script/typl/fence.d.ts.map +1 -1
- package/script/typl/fence.js +5 -20
- package/script/typl/inline.d.ts +15 -24
- package/script/typl/inline.d.ts.map +1 -1
- package/script/typl/inline.js +6 -44
- package/script/typl/recognize.d.ts +14 -0
- package/script/typl/recognize.d.ts.map +1 -0
- package/script/typl/recognize.js +22 -0
- package/script/validator/body_blocks.d.ts.map +1 -1
- package/script/validator/body_blocks.js +3 -9
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module core/decl/resolve
|
|
4
|
+
*
|
|
5
|
+
* Entry-local base-resolution engine (uxil epic #717 §A). The DSL-agnostic
|
|
6
|
+
* *normative rule set* for resolving a relative reference against the base
|
|
7
|
+
* an enclosing declaration established. typl's published tier and uxil both
|
|
8
|
+
* consume it; the engine knows nothing about either vocabulary.
|
|
9
|
+
*
|
|
10
|
+
* The six rules from #722, and where each lives:
|
|
11
|
+
*
|
|
12
|
+
* 1. Only *declarations* create bases; *citations* never do. — The caller
|
|
13
|
+
* sets {@linkcode BaseScope.base} only for declaration scopes; a scope
|
|
14
|
+
* built from a citation leaves it `undefined`.
|
|
15
|
+
* 2. Bases are entry-local (no document-ambient scope). — The engine only
|
|
16
|
+
* ever walks the `parent` chain it is given; there is no global lookup.
|
|
17
|
+
* 3. Innermost base wins. — {@linkcode resolveRef} returns on the first
|
|
18
|
+
* ancestor (nearest first) that carries a base.
|
|
19
|
+
* 4. Scope is structural, never sequential. — The engine follows `parent`
|
|
20
|
+
* links only; siblings are unreachable, so reordering declarations can
|
|
21
|
+
* never rebind a ref.
|
|
22
|
+
* 5. Exactly one root declaration per declaring entry. —
|
|
23
|
+
* {@linkcode checkSingleRoot}.
|
|
24
|
+
* 6. Declarations/citations sit in code spans. — A surface concern
|
|
25
|
+
* (core/decl/surfaces + the DSL recognizer); the engine sees only the
|
|
26
|
+
* already-extracted ref token.
|
|
27
|
+
*
|
|
28
|
+
* The caller builds the {@linkcode BaseScope} chain from the entry's
|
|
29
|
+
* structural nesting (list membership, table membership) — that mapping is
|
|
30
|
+
* DSL- and surface-specific and lands with the table surface (S3) and the
|
|
31
|
+
* DSL consumers (S5/S7).
|
|
32
|
+
*/
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.resolveRef = resolveRef;
|
|
35
|
+
exports.checkSingleRoot = checkSingleRoot;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve `ref` at `scope`. An absolute ref passes through unchanged. A
|
|
38
|
+
* relative ref is joined with the base of the nearest enclosing scope that
|
|
39
|
+
* carries one (innermost wins, rule 3); a single join with that base only —
|
|
40
|
+
* bases are not accumulated up the chain, because each scope's `base` is
|
|
41
|
+
* already its fully-qualified prefix. A relative ref with no base in any
|
|
42
|
+
* ancestor yields `{ ok: false, reason: "no-base-in-scope" }`.
|
|
43
|
+
*
|
|
44
|
+
* `scope` may be `undefined` (a ref at the very top with no enclosing
|
|
45
|
+
* declaration); a relative ref there is likewise `no-base-in-scope`.
|
|
46
|
+
*/
|
|
47
|
+
function resolveRef(ref, scope, ops) {
|
|
48
|
+
if (ops.isAbsolute(ref))
|
|
49
|
+
return { ok: true, ref };
|
|
50
|
+
for (let s = scope; s !== undefined; s = s.parent) {
|
|
51
|
+
if (s.base !== undefined)
|
|
52
|
+
return { ok: true, ref: ops.join(s.base, ref) };
|
|
53
|
+
}
|
|
54
|
+
return { ok: false, reason: "no-base-in-scope" };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Enforce the one-root invariant (rule 5): a declaring entry must have
|
|
58
|
+
* exactly one root declaration. Returns the sole root on success, or a
|
|
59
|
+
* `no-root` / `multiple-roots` failure carrying the offending set. Generic
|
|
60
|
+
* over the DSL's root-declaration type — the engine only counts.
|
|
61
|
+
*/
|
|
62
|
+
function checkSingleRoot(roots) {
|
|
63
|
+
if (roots.length === 1)
|
|
64
|
+
return { ok: true, root: roots[0] };
|
|
65
|
+
return {
|
|
66
|
+
ok: false,
|
|
67
|
+
reason: roots.length === 0 ? "no-root" : "multiple-roots",
|
|
68
|
+
roots,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/decl/surfaces
|
|
3
|
+
*
|
|
4
|
+
* DSL-agnostic declaration-surface machinery. Walks a MarkSpec entry body
|
|
5
|
+
* and extracts every *declaration site* on each of the three embedding
|
|
6
|
+
* surfaces, returning a common declaration node:
|
|
7
|
+
*
|
|
8
|
+
* - **fence** — a fenced code block whose info-string a DSL claims
|
|
9
|
+
* (e.g. ```typl). {@linkcode extractFenceDeclarations}
|
|
10
|
+
* - **bullet** — a list item whose first paragraph is a declaration.
|
|
11
|
+
* {@linkcode extractBulletDeclarations}
|
|
12
|
+
* - **inline** — a CommonMark code span whose text is a declaration.
|
|
13
|
+
* {@linkcode extractInlineDeclarations}
|
|
14
|
+
*
|
|
15
|
+
* Each walker is parameterized by a *recognizer* — the only DSL-specific
|
|
16
|
+
* input — and knows nothing about typl, uxil, or any concrete vocabulary.
|
|
17
|
+
* A DSL host (typl today; uxil and the table surface later) supplies the
|
|
18
|
+
* recognizer and consumes the returned {@linkcode BlockDeclaration} /
|
|
19
|
+
* {@linkcode InlineDeclaration} nodes.
|
|
20
|
+
*
|
|
21
|
+
* Extracted from the typl surface adapters (ADR-019) so §A of the uxil
|
|
22
|
+
* epic (#717) can share one substrate. typl's fence / bullet / inline
|
|
23
|
+
* modules are thin adapters over these functions and their observable
|
|
24
|
+
* output is unchanged.
|
|
25
|
+
*/
|
|
26
|
+
import type { BodyBlock, SourceRange } from "../ast/nodes.js";
|
|
27
|
+
import type { BodyToken, SourceLocation } from "../model/mod.js";
|
|
28
|
+
/**
|
|
29
|
+
* A declaration found on a block surface (fenced code block or bullet
|
|
30
|
+
* paragraph). Carries the raw DSL `source` and the node's body-relative
|
|
31
|
+
* {@linkcode SourceRange} — the anchor a DSL host uses to bridge parse
|
|
32
|
+
* diagnostics back to file positions.
|
|
33
|
+
*/
|
|
34
|
+
export interface BlockDeclaration {
|
|
35
|
+
/** Raw DSL source: the fence body, or the bullet's paragraph text. */
|
|
36
|
+
readonly source: string;
|
|
37
|
+
/** Source range of the fence, or of the bullet's first paragraph. */
|
|
38
|
+
readonly range: SourceRange;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A declaration found in an inline code span. Carries the raw DSL
|
|
42
|
+
* `source` (backtick delimiters stripped) and the span's file-relative
|
|
43
|
+
* {@linkcode SourceLocation} (the position `Entry.bodyTokens` records).
|
|
44
|
+
*/
|
|
45
|
+
export interface InlineDeclaration {
|
|
46
|
+
/** Raw DSL source: the code span's inner text, backticks stripped. */
|
|
47
|
+
readonly source: string;
|
|
48
|
+
/** File-relative location of the code span. */
|
|
49
|
+
readonly location: SourceLocation;
|
|
50
|
+
}
|
|
51
|
+
/** Recognizer for the fence surface: does this info-string host the DSL? */
|
|
52
|
+
export type FenceRecognizer = (lang: string | undefined) => boolean;
|
|
53
|
+
/** Recognizer for the bullet / inline surfaces: is this text a declaration? */
|
|
54
|
+
export type TextRecognizer = (text: string) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Walk a body AST and return every fenced code block whose info-string
|
|
57
|
+
* satisfies `matchLang`. Recurses into container nodes (ListNode via
|
|
58
|
+
* ListItemNode.blocks) so fences nested inside list items are found.
|
|
59
|
+
*
|
|
60
|
+
* BlockquoteNode and NoteNode carry only InlineContent (not nested
|
|
61
|
+
* BodyBlock[]), so they are not recursed into. Returns declarations in
|
|
62
|
+
* source order (depth-first traversal).
|
|
63
|
+
*/
|
|
64
|
+
export declare function extractFenceDeclarations(blocks: readonly BodyBlock[], matchLang: FenceRecognizer): readonly BlockDeclaration[];
|
|
65
|
+
/**
|
|
66
|
+
* Walk a body AST and return every bullet-list item whose first paragraph
|
|
67
|
+
* satisfies `matchText`. Recurses through ListNode → ListItemNode.blocks
|
|
68
|
+
* for nested lists. Mixed lists are supported: items whose first paragraph
|
|
69
|
+
* matches are extracted; non-matching bullets are left alone.
|
|
70
|
+
*
|
|
71
|
+
* Returns declarations in source order (depth-first).
|
|
72
|
+
*/
|
|
73
|
+
export declare function extractBulletDeclarations(blocks: readonly BodyBlock[], matchText: TextRecognizer): readonly BlockDeclaration[];
|
|
74
|
+
/**
|
|
75
|
+
* Strip the surrounding backtick delimiter(s) from an inline-code token's
|
|
76
|
+
* `text` field. `body_tokens.ts` stores inline-code text as `` `value` ``
|
|
77
|
+
* (with backtick delimiters); a DSL recognizer and parser need the inner
|
|
78
|
+
* value only.
|
|
79
|
+
*
|
|
80
|
+
* Handles both single-backtick (`` `…` ``) and double-backtick (` ``…`` `)
|
|
81
|
+
* delimiters. Returns the original string unchanged when it does not start
|
|
82
|
+
* and end with a matching backtick fence.
|
|
83
|
+
*/
|
|
84
|
+
export declare function stripCodeSpanDelimiters(text: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Filter `bodyTokens` to inline-code spans whose contents (backticks
|
|
87
|
+
* stripped) satisfy `matchText`. Returns declarations in source order
|
|
88
|
+
* (the bodyTokens contract guarantees source order).
|
|
89
|
+
*
|
|
90
|
+
* `inline-code` tokens store their `text` field with surrounding backtick
|
|
91
|
+
* delimiters (e.g. `` `$X : signal` ``). This function strips those
|
|
92
|
+
* delimiters via {@linkcode stripCodeSpanDelimiters} before recognizing
|
|
93
|
+
* and before setting `source`, so the DSL parser receives the raw source.
|
|
94
|
+
*/
|
|
95
|
+
export declare function extractInlineDeclarations(bodyTokens: readonly BodyToken[], matchText: TextRecognizer): readonly InlineDeclaration[];
|
|
96
|
+
//# sourceMappingURL=surfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surfaces.d.ts","sourceRoot":"","sources":["../../src/decl/surfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACnC;AAED,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC;AAEpE,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAEvD;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,SAAS,EAAE,EAC5B,SAAS,EAAE,eAAe,GACzB,SAAS,gBAAgB,EAAE,CAY7B;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,SAAS,EAAE,EAC5B,SAAS,EAAE,cAAc,GACxB,SAAS,gBAAgB,EAAE,CAwB7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,SAAS,EAAE,cAAc,GACxB,SAAS,iBAAiB,EAAE,CAS9B"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module core/decl/surfaces
|
|
4
|
+
*
|
|
5
|
+
* DSL-agnostic declaration-surface machinery. Walks a MarkSpec entry body
|
|
6
|
+
* and extracts every *declaration site* on each of the three embedding
|
|
7
|
+
* surfaces, returning a common declaration node:
|
|
8
|
+
*
|
|
9
|
+
* - **fence** — a fenced code block whose info-string a DSL claims
|
|
10
|
+
* (e.g. ```typl). {@linkcode extractFenceDeclarations}
|
|
11
|
+
* - **bullet** — a list item whose first paragraph is a declaration.
|
|
12
|
+
* {@linkcode extractBulletDeclarations}
|
|
13
|
+
* - **inline** — a CommonMark code span whose text is a declaration.
|
|
14
|
+
* {@linkcode extractInlineDeclarations}
|
|
15
|
+
*
|
|
16
|
+
* Each walker is parameterized by a *recognizer* — the only DSL-specific
|
|
17
|
+
* input — and knows nothing about typl, uxil, or any concrete vocabulary.
|
|
18
|
+
* A DSL host (typl today; uxil and the table surface later) supplies the
|
|
19
|
+
* recognizer and consumes the returned {@linkcode BlockDeclaration} /
|
|
20
|
+
* {@linkcode InlineDeclaration} nodes.
|
|
21
|
+
*
|
|
22
|
+
* Extracted from the typl surface adapters (ADR-019) so §A of the uxil
|
|
23
|
+
* epic (#717) can share one substrate. typl's fence / bullet / inline
|
|
24
|
+
* modules are thin adapters over these functions and their observable
|
|
25
|
+
* output is unchanged.
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.extractFenceDeclarations = extractFenceDeclarations;
|
|
29
|
+
exports.extractBulletDeclarations = extractBulletDeclarations;
|
|
30
|
+
exports.stripCodeSpanDelimiters = stripCodeSpanDelimiters;
|
|
31
|
+
exports.extractInlineDeclarations = extractInlineDeclarations;
|
|
32
|
+
/**
|
|
33
|
+
* Walk a body AST and return every fenced code block whose info-string
|
|
34
|
+
* satisfies `matchLang`. Recurses into container nodes (ListNode via
|
|
35
|
+
* ListItemNode.blocks) so fences nested inside list items are found.
|
|
36
|
+
*
|
|
37
|
+
* BlockquoteNode and NoteNode carry only InlineContent (not nested
|
|
38
|
+
* BodyBlock[]), so they are not recursed into. Returns declarations in
|
|
39
|
+
* source order (depth-first traversal).
|
|
40
|
+
*/
|
|
41
|
+
function extractFenceDeclarations(blocks, matchLang) {
|
|
42
|
+
const results = [];
|
|
43
|
+
for (const block of blocks) {
|
|
44
|
+
if (block.kind === "code" && matchLang(block.lang)) {
|
|
45
|
+
results.push({ source: block.text, range: block.range });
|
|
46
|
+
}
|
|
47
|
+
else if (block.kind === "list") {
|
|
48
|
+
for (const item of block.items) {
|
|
49
|
+
results.push(...extractFenceDeclarations(item.blocks, matchLang));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return results;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Walk a body AST and return every bullet-list item whose first paragraph
|
|
57
|
+
* satisfies `matchText`. Recurses through ListNode → ListItemNode.blocks
|
|
58
|
+
* for nested lists. Mixed lists are supported: items whose first paragraph
|
|
59
|
+
* matches are extracted; non-matching bullets are left alone.
|
|
60
|
+
*
|
|
61
|
+
* Returns declarations in source order (depth-first).
|
|
62
|
+
*/
|
|
63
|
+
function extractBulletDeclarations(blocks, matchText) {
|
|
64
|
+
const results = [];
|
|
65
|
+
for (const block of blocks) {
|
|
66
|
+
if (block.kind === "list") {
|
|
67
|
+
for (const item of block.items) {
|
|
68
|
+
if (item.blocks.length === 0)
|
|
69
|
+
continue;
|
|
70
|
+
const first = item.blocks[0];
|
|
71
|
+
if (first.kind === "paragraph") {
|
|
72
|
+
if (matchText(first.content.text)) {
|
|
73
|
+
results.push({ source: first.content.text, range: first.range });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Recurse into nested blocks (the item may itself contain a list).
|
|
77
|
+
if (item.blocks.length > 1) {
|
|
78
|
+
results.push(...extractBulletDeclarations(item.blocks.slice(1), matchText));
|
|
79
|
+
}
|
|
80
|
+
else if (first.kind === "list") {
|
|
81
|
+
results.push(...extractBulletDeclarations([first], matchText));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return results;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Strip the surrounding backtick delimiter(s) from an inline-code token's
|
|
90
|
+
* `text` field. `body_tokens.ts` stores inline-code text as `` `value` ``
|
|
91
|
+
* (with backtick delimiters); a DSL recognizer and parser need the inner
|
|
92
|
+
* value only.
|
|
93
|
+
*
|
|
94
|
+
* Handles both single-backtick (`` `…` ``) and double-backtick (` ``…`` `)
|
|
95
|
+
* delimiters. Returns the original string unchanged when it does not start
|
|
96
|
+
* and end with a matching backtick fence.
|
|
97
|
+
*/
|
|
98
|
+
function stripCodeSpanDelimiters(text) {
|
|
99
|
+
if (text.startsWith("``") && text.endsWith("``") && text.length > 4) {
|
|
100
|
+
return text.slice(2, -2);
|
|
101
|
+
}
|
|
102
|
+
if (text.startsWith("`") && text.endsWith("`") && text.length > 2) {
|
|
103
|
+
return text.slice(1, -1);
|
|
104
|
+
}
|
|
105
|
+
return text;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Filter `bodyTokens` to inline-code spans whose contents (backticks
|
|
109
|
+
* stripped) satisfy `matchText`. Returns declarations in source order
|
|
110
|
+
* (the bodyTokens contract guarantees source order).
|
|
111
|
+
*
|
|
112
|
+
* `inline-code` tokens store their `text` field with surrounding backtick
|
|
113
|
+
* delimiters (e.g. `` `$X : signal` ``). This function strips those
|
|
114
|
+
* delimiters via {@linkcode stripCodeSpanDelimiters} before recognizing
|
|
115
|
+
* and before setting `source`, so the DSL parser receives the raw source.
|
|
116
|
+
*/
|
|
117
|
+
function extractInlineDeclarations(bodyTokens, matchText) {
|
|
118
|
+
const results = [];
|
|
119
|
+
for (const token of bodyTokens) {
|
|
120
|
+
if (token.kind !== "inline-code")
|
|
121
|
+
continue;
|
|
122
|
+
const inner = stripCodeSpanDelimiters(token.text);
|
|
123
|
+
if (!matchText(inner))
|
|
124
|
+
continue;
|
|
125
|
+
results.push({ source: inner, location: token.location });
|
|
126
|
+
}
|
|
127
|
+
return results;
|
|
128
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/decl/table
|
|
3
|
+
*
|
|
4
|
+
* Table declaration surface (uxil epic #717 §A / S3). A fourth embedding
|
|
5
|
+
* surface on the shared declaration machinery (alongside fence, bullet, and
|
|
6
|
+
* inline): each **data row** of a GFM table is one declaration, and the
|
|
7
|
+
* table's `Table:` caption may carry a base that the entry-local resolver
|
|
8
|
+
* (S4) consumes.
|
|
9
|
+
*
|
|
10
|
+
* DSL-agnostic, like its siblings: the caller supplies a `rowToSource`
|
|
11
|
+
* recognizer that maps a row's cell texts to a declaration source (or
|
|
12
|
+
* `undefined` to skip a non-declaration / malformed row), and parses the
|
|
13
|
+
* actual base ref out of the surfaced {@linkcode TableRowDeclaration.captionText}
|
|
14
|
+
* itself — the caption's ref grammar is DSL-specific.
|
|
15
|
+
*
|
|
16
|
+
* Row positions: a {@linkcode TableNode} carries one range for the whole
|
|
17
|
+
* table and its verbatim `raw` source, but rows have no individual range
|
|
18
|
+
* (cells are stored as text only). Per-row ranges are therefore derived
|
|
19
|
+
* from the table's start line plus the row's index, past the GFM header and
|
|
20
|
+
* delimiter lines.
|
|
21
|
+
*/
|
|
22
|
+
import type { BodyBlock } from "../ast/nodes.js";
|
|
23
|
+
import type { BlockDeclaration } from "./surfaces.js";
|
|
24
|
+
/**
|
|
25
|
+
* A declaration found on one data row of a table. Extends the shared
|
|
26
|
+
* {@linkcode BlockDeclaration} (`source` = the row reduced to a declaration
|
|
27
|
+
* by the DSL's recognizer; `range` = the row's line-precise span) with
|
|
28
|
+
* `captionText`: the enclosing table's `Table:` caption text, when the table
|
|
29
|
+
* has an adjacent one — the DSL parses a base ref out of it and hands that
|
|
30
|
+
* to the resolver (S4).
|
|
31
|
+
*/
|
|
32
|
+
export interface TableRowDeclaration extends BlockDeclaration {
|
|
33
|
+
/** The enclosing table's `Table:` caption text, if any. */
|
|
34
|
+
readonly captionText?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Maps a data row's cell texts to a declaration source, or returns
|
|
38
|
+
* `undefined` to skip the row (not a declaration, or malformed). The only
|
|
39
|
+
* DSL-specific input to {@linkcode extractTableDeclarations}.
|
|
40
|
+
*/
|
|
41
|
+
export type RowRecognizer = (cells: readonly string[]) => string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Walk a body AST and return a declaration for every table data row the
|
|
44
|
+
* `rowToSource` recognizer accepts, in source order. Recurses into
|
|
45
|
+
* container nodes (ListNode via ListItemNode.blocks) so tables nested
|
|
46
|
+
* inside list items are found. Rows the recognizer skips (`undefined`)
|
|
47
|
+
* contribute nothing — the malformed-row case.
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractTableDeclarations(blocks: readonly BodyBlock[], rowToSource: RowRecognizer): readonly TableRowDeclaration[];
|
|
50
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/decl/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,SAAS,EAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,MAAM,GAAG,SAAS,CAAC;AAM7E;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,SAAS,EAAE,EAC5B,WAAW,EAAE,aAAa,GACzB,SAAS,mBAAmB,EAAE,CAIhC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module core/decl/table
|
|
4
|
+
*
|
|
5
|
+
* Table declaration surface (uxil epic #717 §A / S3). A fourth embedding
|
|
6
|
+
* surface on the shared declaration machinery (alongside fence, bullet, and
|
|
7
|
+
* inline): each **data row** of a GFM table is one declaration, and the
|
|
8
|
+
* table's `Table:` caption may carry a base that the entry-local resolver
|
|
9
|
+
* (S4) consumes.
|
|
10
|
+
*
|
|
11
|
+
* DSL-agnostic, like its siblings: the caller supplies a `rowToSource`
|
|
12
|
+
* recognizer that maps a row's cell texts to a declaration source (or
|
|
13
|
+
* `undefined` to skip a non-declaration / malformed row), and parses the
|
|
14
|
+
* actual base ref out of the surfaced {@linkcode TableRowDeclaration.captionText}
|
|
15
|
+
* itself — the caption's ref grammar is DSL-specific.
|
|
16
|
+
*
|
|
17
|
+
* Row positions: a {@linkcode TableNode} carries one range for the whole
|
|
18
|
+
* table and its verbatim `raw` source, but rows have no individual range
|
|
19
|
+
* (cells are stored as text only). Per-row ranges are therefore derived
|
|
20
|
+
* from the table's start line plus the row's index, past the GFM header and
|
|
21
|
+
* delimiter lines.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.extractTableDeclarations = extractTableDeclarations;
|
|
25
|
+
/** GFM layout offset: a data row at `rows[i]` sits `i` lines past the
|
|
26
|
+
* header (line 0) and delimiter (line 1) rows in the table's raw source. */
|
|
27
|
+
const HEADER_AND_DELIMITER_LINES = 2;
|
|
28
|
+
/**
|
|
29
|
+
* Walk a body AST and return a declaration for every table data row the
|
|
30
|
+
* `rowToSource` recognizer accepts, in source order. Recurses into
|
|
31
|
+
* container nodes (ListNode via ListItemNode.blocks) so tables nested
|
|
32
|
+
* inside list items are found. Rows the recognizer skips (`undefined`)
|
|
33
|
+
* contribute nothing — the malformed-row case.
|
|
34
|
+
*/
|
|
35
|
+
function extractTableDeclarations(blocks, rowToSource) {
|
|
36
|
+
const results = [];
|
|
37
|
+
walk(blocks, rowToSource, results);
|
|
38
|
+
return results;
|
|
39
|
+
}
|
|
40
|
+
function walk(blocks, rowToSource, out) {
|
|
41
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
42
|
+
const block = blocks[i];
|
|
43
|
+
if (block.kind === "table") {
|
|
44
|
+
const captionText = adjacentTableCaption(blocks, i);
|
|
45
|
+
const rawLines = block.raw.split("\n");
|
|
46
|
+
for (let r = 0; r < block.rows.length; r++) {
|
|
47
|
+
const cells = block.rows[r].map((cell) => cell.text);
|
|
48
|
+
const source = rowToSource(cells);
|
|
49
|
+
if (source === undefined)
|
|
50
|
+
continue;
|
|
51
|
+
out.push({
|
|
52
|
+
source,
|
|
53
|
+
range: rowRange(block, rawLines, r),
|
|
54
|
+
...(captionText !== undefined ? { captionText } : {}),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (block.kind === "list") {
|
|
59
|
+
for (const item of block.items)
|
|
60
|
+
walk(item.blocks, rowToSource, out);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Return the text of the `Table:` caption that captions the table at
|
|
66
|
+
* `blocks[index]`, or `undefined` when there is none.
|
|
67
|
+
*
|
|
68
|
+
* Pairing is by local adjacency, re-deriving the above/below rule from the
|
|
69
|
+
* neighbours rather than trusting `CaptionNode.position`: the builder assigns
|
|
70
|
+
* `position` only for top-level blocks (`assignCaptionPositions` in
|
|
71
|
+
* core/ast/build.ts), so a caption inside a list item keeps the default
|
|
72
|
+
* `"below"` and cannot be trusted. A `Table:` caption immediately before the
|
|
73
|
+
* table captions it (the table is the caption's next captionable block); one
|
|
74
|
+
* immediately after captions it only when no captionable block follows the
|
|
75
|
+
* caption — otherwise that caption belongs to the following block.
|
|
76
|
+
*/
|
|
77
|
+
function adjacentTableCaption(blocks, index) {
|
|
78
|
+
const prev = blocks[index - 1];
|
|
79
|
+
if (isTableCaption(prev))
|
|
80
|
+
return prev.text;
|
|
81
|
+
const next = blocks[index + 1];
|
|
82
|
+
if (isTableCaption(next) && !isCaptionable(blocks[index + 2])) {
|
|
83
|
+
return next.text;
|
|
84
|
+
}
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
function isTableCaption(block) {
|
|
88
|
+
return block?.kind === "caption" && block.keyword === "Table";
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Block kinds a caption can caption (mirrors the captionable set in
|
|
92
|
+
* `assignCaptionPositions`, core/ast/build.ts). Used to decide whether a
|
|
93
|
+
* caption that follows a table belongs to that table or to a later
|
|
94
|
+
* captionable block.
|
|
95
|
+
*/
|
|
96
|
+
function isCaptionable(block) {
|
|
97
|
+
if (block === undefined)
|
|
98
|
+
return false;
|
|
99
|
+
switch (block.kind) {
|
|
100
|
+
case "figure":
|
|
101
|
+
case "table":
|
|
102
|
+
case "code":
|
|
103
|
+
case "feature":
|
|
104
|
+
case "math":
|
|
105
|
+
case "list":
|
|
106
|
+
return true;
|
|
107
|
+
default:
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The line-precise range of data row `rowIndex`. The table's `range.start`
|
|
113
|
+
* is the header line; the data row sits `HEADER_AND_DELIMITER_LINES +
|
|
114
|
+
* rowIndex` lines below it, at the table's start column. `raw` is de-indented
|
|
115
|
+
* by `verbatimSlice`, so adding the de-indented row length to the table's
|
|
116
|
+
* column yields the true source span — correct for both top-level (column 1)
|
|
117
|
+
* and list-nested (indented) tables.
|
|
118
|
+
*/
|
|
119
|
+
function rowRange(table, rawLines, rowIndex) {
|
|
120
|
+
const line = table.range.start.line + HEADER_AND_DELIMITER_LINES + rowIndex;
|
|
121
|
+
const column = table.range.start.column;
|
|
122
|
+
const rawLine = rawLines[HEADER_AND_DELIMITER_LINES + rowIndex] ?? "";
|
|
123
|
+
return {
|
|
124
|
+
start: { line, column },
|
|
125
|
+
end: { line, column: column + rawLine.length },
|
|
126
|
+
};
|
|
127
|
+
}
|
package/script/mod.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* from core/mod.ts, never from internal paths.
|
|
9
9
|
*/
|
|
10
10
|
import "./_dnt.polyfills.js";
|
|
11
|
-
export declare const VERSION = "0.10.
|
|
11
|
+
export declare const VERSION = "0.10.3";
|
|
12
12
|
export declare const CORE_SCHEMA_VERSION = 1;
|
|
13
13
|
export { ConfigError, CORE_DISCIPLINE_REGISTRY, CORE_KINDS, CORE_RELATIONS, DEFAULT_PROJECT_CONFIG, descendantsOf, formatEntryOrigin, KNOWN_LINK_KINDS, LOCK_EXTRA_INVERSE_KEYS, makeDisplayId, makeUlid, MIXED_DISCIPLINE, PALETTE_HUES, REFHUB_URL, } from "./model/mod.js";
|
|
14
14
|
export type { Attribute, BodyToken, BodyTokenKind, Caption, CaptionConventions, CaptionPosition, ConfigFieldError, DeliveredDocument, Diagnostic, Directive, Discipline, DisciplineRegistry, DisplayId, EarsTrigger, EffectiveProfile, EffectiveTypeDef, EntityRefConvention, Entry, EntryOrigin, EntryShape, EntrySource, ExtractorRule, InlineRef, KindDecl, LabelConcern, LabelConcernKind, LabelValue, Link, LinkKind, LoadedProfile, ModalCase, PaletteHue, ProfileChain, ProfileConvention, ProjectConfig, ProvenancedMap, ProvenancedMapEntry, ProvenancedValue, RelationDef, Severity, SourceLocation, Ulid, } from "./model/mod.js";
|
package/script/mod.js
CHANGED
|
@@ -46,7 +46,7 @@ exports.collectProjectEntries = exports.SOURCE_EXTENSIONS = exports.RELEVANT_EXT
|
|
|
46
46
|
* from core/mod.ts, never from internal paths.
|
|
47
47
|
*/
|
|
48
48
|
require("./_dnt.polyfills.js");
|
|
49
|
-
exports.VERSION = "0.10.
|
|
49
|
+
exports.VERSION = "0.10.3";
|
|
50
50
|
exports.CORE_SCHEMA_VERSION = 1;
|
|
51
51
|
// Model types
|
|
52
52
|
var mod_js_1 = require("./model/mod.js");
|
|
@@ -13,6 +13,12 @@ export interface DetectDirectivesOptions {
|
|
|
13
13
|
/** File path used in source locations. */
|
|
14
14
|
readonly file?: string;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Return `true` when `line` is a standalone `<!-- markspec:* -->` directive
|
|
18
|
+
* comment. Accepts the line trimmed or with surrounding whitespace, and both
|
|
19
|
+
* the spaced (`<!-- markspec:`) and no-space (`<!--markspec:`) forms.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isMarkspecDirectiveComment(line: string): boolean;
|
|
16
22
|
/**
|
|
17
23
|
* Detect MarkSpec directives in a Markdown string.
|
|
18
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../../src/parser/directives.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AAGjE,gDAAgD;AAChD,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../../src/parser/directives.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AAGjE,gDAAgD;AAChD,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAkBD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,uBAAuB,GAChC,SAAS,EAAE,CAqEb"}
|
|
@@ -9,12 +9,30 @@
|
|
|
9
9
|
* notices, or slide layout declarations.
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.isMarkspecDirectiveComment = isMarkspecDirectiveComment;
|
|
12
13
|
exports.detectDirectives = detectDirectives;
|
|
13
14
|
const remark_js_1 = require("./remark.js");
|
|
14
15
|
/** Matches the opening and closing of an HTML comment. */
|
|
15
16
|
const COMMENT_RE = /^<!--([\s\S]*?)-->$/;
|
|
16
17
|
/** Matches a `markspec:` directive line within a comment body. */
|
|
17
18
|
const DIRECTIVE_RE = /^markspec:(\S+)\s?(.*)?$/;
|
|
19
|
+
/**
|
|
20
|
+
* A whole-line markspec directive comment: `<!-- markspec:<rest> -->`
|
|
21
|
+
* occupying the line on its own (optional surrounding whitespace, and
|
|
22
|
+
* optional whitespace after `<!--`). This is the single definition the
|
|
23
|
+
* validator's body carve-out (spec §2.4.1) and the parser's trailer
|
|
24
|
+
* heuristics both consult, so they can never disagree on what a directive
|
|
25
|
+
* comment is (#687).
|
|
26
|
+
*/
|
|
27
|
+
const DIRECTIVE_COMMENT_LINE_RE = /^\s*<!--\s*markspec:[\s\S]*?-->\s*$/;
|
|
28
|
+
/**
|
|
29
|
+
* Return `true` when `line` is a standalone `<!-- markspec:* -->` directive
|
|
30
|
+
* comment. Accepts the line trimmed or with surrounding whitespace, and both
|
|
31
|
+
* the spaced (`<!-- markspec:`) and no-space (`<!--markspec:`) forms.
|
|
32
|
+
*/
|
|
33
|
+
function isMarkspecDirectiveComment(line) {
|
|
34
|
+
return DIRECTIVE_COMMENT_LINE_RE.test(line);
|
|
35
|
+
}
|
|
18
36
|
/**
|
|
19
37
|
* Detect MarkSpec directives in a Markdown string.
|
|
20
38
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/parser/markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAa,UAAU,EAAE,KAAK,EAAc,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/parser/markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAa,UAAU,EAAE,KAAK,EAAc,MAAM,iBAAiB,CAAC;AAmBhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAwB7C,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAsDD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,mBAAmB,CA8CrB"}
|
|
@@ -10,6 +10,7 @@ exports.parseMarkdown = parseMarkdown;
|
|
|
10
10
|
const mod_js_1 = require("../model/mod.js");
|
|
11
11
|
const attributes_js_1 = require("./attributes.js");
|
|
12
12
|
const body_tokens_js_1 = require("./body_tokens.js");
|
|
13
|
+
const directives_js_1 = require("./directives.js");
|
|
13
14
|
const remark_js_1 = require("./remark.js");
|
|
14
15
|
const build_js_1 = require("../ast/build.js");
|
|
15
16
|
const translate_js_1 = require("./translate.js");
|
|
@@ -338,6 +339,14 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
|
|
|
338
339
|
const trimmed = bodyLines[i].trim();
|
|
339
340
|
if (!trimmed)
|
|
340
341
|
continue; // skip trailing blanks
|
|
342
|
+
// A `<!-- markspec:* -->` directive comment is legitimate body
|
|
343
|
+
// content (spec §2.4.1), not a trailer line — skip it so its
|
|
344
|
+
// `<!--markspec` colon-prefix is never mistaken for a malformed
|
|
345
|
+
// trailer key. `continue` (not `break`) keeps scanning earlier lines,
|
|
346
|
+
// so a genuine leaked-trailer typo sitting above a directive comment
|
|
347
|
+
// still fires MSL-P022 (#687, preserves #697).
|
|
348
|
+
if ((0, directives_js_1.isMarkspecDirectiveComment)(trimmed))
|
|
349
|
+
continue;
|
|
341
350
|
const colonMatch = COLON_SPLIT_RE.exec(trimmed);
|
|
342
351
|
if (!colonMatch)
|
|
343
352
|
break; // stop at non-colon line
|
package/script/typl/bullet.d.ts
CHANGED
|
@@ -2,33 +2,23 @@
|
|
|
2
2
|
* @module typl/bullet
|
|
3
3
|
*
|
|
4
4
|
* Bullet-glossary surface adapter — recognises CommonMark bullet list
|
|
5
|
-
* items whose first paragraph
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* integration calls parseTyplBlock on each `source` independently.
|
|
12
|
-
* Per-item position-bridging uses the item's range and formula
|
|
13
|
-
* documented in bridgeTyplDiagnostic.
|
|
5
|
+
* items whose first paragraph is a typl declaration (`$X : …` binding or
|
|
6
|
+
* `type X = …` typedef). A thin wrapper over the shared
|
|
7
|
+
* declaration-surface machinery (core/decl): it supplies typl's text
|
|
8
|
+
* recognizer and re-exports the common declaration node as
|
|
9
|
+
* {@linkcode TyplBulletExtraction}. Mixed lists are supported — matching
|
|
10
|
+
* items are extracted, non-matching bullets are left alone.
|
|
14
11
|
*
|
|
15
12
|
* See ADR-019.
|
|
16
13
|
*/
|
|
17
|
-
import type { BodyBlock
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly source: string;
|
|
22
|
-
/** Source range of the bullet's first paragraph. */
|
|
23
|
-
readonly range: SourceRange;
|
|
24
|
-
}
|
|
14
|
+
import type { BodyBlock } from "../ast/nodes.js";
|
|
15
|
+
import { type BlockDeclaration } from "../decl/mod.js";
|
|
16
|
+
/** A single typl bullet item found inside a body: `{ source, range }`. */
|
|
17
|
+
export type TyplBulletExtraction = BlockDeclaration;
|
|
25
18
|
/**
|
|
26
|
-
* Walk a body AST and return every bullet-list item whose first
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* list are picked up).
|
|
30
|
-
*
|
|
31
|
-
* Returns matches in source order (depth-first).
|
|
19
|
+
* Walk a body AST and return every bullet-list item whose first paragraph
|
|
20
|
+
* is a typl declaration, in source order (depth-first, recursing into
|
|
21
|
+
* nested lists). Delegates traversal to {@linkcode extractBulletDeclarations}.
|
|
32
22
|
*/
|
|
33
23
|
export declare function extractTyplBullets(blocks: readonly BodyBlock[]): readonly TyplBulletExtraction[];
|
|
34
24
|
//# sourceMappingURL=bullet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bullet.d.ts","sourceRoot":"","sources":["../../src/typl/bullet.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"bullet.d.ts","sourceRoot":"","sources":["../../src/typl/bullet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,gBAAgB,CAAC;AAGxB,0EAA0E;AAC1E,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,oBAAoB,EAAE,CAEjC"}
|