@descent-vtt/spec-graph 0.7.0 → 0.9.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/CHANGELOG.md +477 -0
- package/README.md +109 -17
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +38 -19
- package/dist/cli.js.map +1 -1
- package/dist/directives.d.ts +9 -2
- package/dist/directives.js +15 -4
- package/dist/directives.js.map +1 -1
- package/dist/extract.d.ts +1 -1
- package/dist/extract.js +50 -16
- package/dist/extract.js.map +1 -1
- package/dist/glob.d.ts +44 -44
- package/dist/glob.js +152 -116
- package/dist/glob.js.map +1 -1
- package/dist/identity.d.ts +12 -4
- package/dist/identity.js +32 -8
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.js +10 -2
- package/dist/lifecycle.js.map +1 -1
- package/dist/markdown.d.ts +53 -161
- package/dist/markdown.js +42 -864
- package/dist/markdown.js.map +1 -1
- package/dist/report.d.ts +23 -0
- package/dist/report.js +80 -0
- package/dist/report.js.map +1 -1
- package/dist/rules.js +48 -14
- package/dist/rules.js.map +1 -1
- package/dist/sections.d.ts +1 -1
- package/dist/sections.js +18 -4
- package/dist/sections.js.map +1 -1
- package/dist/select.d.ts +2 -2
- package/dist/select.js +3 -3
- package/dist/select.js.map +1 -1
- package/dist/source.d.ts +6 -19
- package/dist/source.js +4 -70
- package/dist/source.js.map +1 -1
- package/dist/types.d.ts +23 -3
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vendor/spec-core/markdown/frontmatter.d.ts +103 -0
- package/dist/vendor/spec-core/markdown/frontmatter.js +459 -0
- package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -0
- package/dist/vendor/spec-core/markdown/headings.d.ts +45 -0
- package/dist/vendor/spec-core/markdown/headings.js +199 -0
- package/dist/vendor/spec-core/markdown/headings.js.map +1 -0
- package/dist/vendor/spec-core/markdown/index.d.ts +5 -0
- package/dist/vendor/spec-core/markdown/index.js +4 -0
- package/dist/vendor/spec-core/markdown/index.js.map +1 -0
- package/dist/vendor/spec-core/markdown/layout.d.ts +39 -0
- package/dist/vendor/spec-core/markdown/layout.js +28 -0
- package/dist/vendor/spec-core/markdown/layout.js.map +1 -0
- package/dist/vendor/spec-core/markdown/links.d.ts +22 -0
- package/dist/vendor/spec-core/markdown/links.js +364 -0
- package/dist/vendor/spec-core/markdown/links.js.map +1 -0
- package/dist/vendor/spec-core/markdown/lists.d.ts +22 -0
- package/dist/vendor/spec-core/markdown/lists.js +127 -0
- package/dist/vendor/spec-core/markdown/lists.js.map +1 -0
- package/dist/vendor/spec-core/markdown/scan.d.ts +36 -0
- package/dist/vendor/spec-core/markdown/scan.js +439 -0
- package/dist/vendor/spec-core/markdown/scan.js.map +1 -0
- package/dist/vendor/spec-core/markdown/syntax.d.ts +75 -0
- package/dist/vendor/spec-core/markdown/syntax.js +181 -0
- package/dist/vendor/spec-core/markdown/syntax.js.map +1 -0
- package/dist/vendor/spec-core/markdown/tables.d.ts +18 -0
- package/dist/vendor/spec-core/markdown/tables.js +86 -0
- package/dist/vendor/spec-core/markdown/tables.js.map +1 -0
- package/dist/vendor/spec-core/markdown/types.d.ts +287 -0
- package/dist/vendor/spec-core/markdown/types.js +9 -0
- package/dist/vendor/spec-core/markdown/types.js.map +1 -0
- package/dist/vendor/spec-core/path/index.d.ts +1 -0
- package/dist/vendor/spec-core/path/index.js +2 -0
- package/dist/vendor/spec-core/path/index.js.map +1 -0
- package/dist/vendor/spec-core/path/posix.d.ts +83 -0
- package/dist/vendor/spec-core/path/posix.js +150 -0
- package/dist/vendor/spec-core/path/posix.js.map +1 -0
- package/dist/vendor/spec-core/pattern/automaton.d.ts +129 -0
- package/dist/vendor/spec-core/pattern/automaton.js +340 -0
- package/dist/vendor/spec-core/pattern/automaton.js.map +1 -0
- package/dist/vendor/spec-core/pattern/charset.d.ts +58 -0
- package/dist/vendor/spec-core/pattern/charset.js +116 -0
- package/dist/vendor/spec-core/pattern/charset.js.map +1 -0
- package/dist/vendor/spec-core/pattern/glob.d.ts +121 -0
- package/dist/vendor/spec-core/pattern/glob.js +481 -0
- package/dist/vendor/spec-core/pattern/glob.js.map +1 -0
- package/dist/vendor/spec-core/pattern/index.d.ts +6 -0
- package/dist/vendor/spec-core/pattern/index.js +4 -0
- package/dist/vendor/spec-core/pattern/index.js.map +1 -0
- package/dist/{regex.d.ts → vendor/spec-core/pattern/regex.d.ts} +20 -29
- package/dist/{regex.js → vendor/spec-core/pattern/regex.js} +40 -49
- package/dist/vendor/spec-core/pattern/regex.js.map +1 -0
- package/dist/vendor/spec-core/text/index.d.ts +2 -0
- package/dist/vendor/spec-core/text/index.js +2 -0
- package/dist/vendor/spec-core/text/index.js.map +1 -0
- package/dist/vendor/spec-core/text/lines.d.ts +72 -0
- package/dist/vendor/spec-core/text/lines.js +156 -0
- package/dist/vendor/spec-core/text/lines.js.map +1 -0
- package/dist/yaml.d.ts +44 -12
- package/dist/yaml.js +115 -206
- package/dist/yaml.js.map +1 -1
- package/package.json +3 -2
- package/src/vendor/spec-core/LICENSE +21 -0
- package/src/vendor/spec-core/README.md +8 -0
- package/dist/regex.js.map +0 -1
package/dist/markdown.d.ts
CHANGED
|
@@ -1,166 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* What spec-graph reads out of a Markdown document.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* The scan is spec-core's, copied into `src/vendor/spec-core/markdown/`: one
|
|
5
|
+
* pass that is exact about code and comments, as CommonMark is, and simple about
|
|
6
|
+
* the rest (ADR-0001). It started as this file, and the guarantees it was
|
|
7
|
+
* written for came with it: code never counts, items are blocks and not lines,
|
|
8
|
+
* and everything carries absolute offsets.
|
|
9
9
|
*
|
|
10
|
-
* What
|
|
11
|
-
*
|
|
10
|
+
* What stays here is what spec-graph decides about the scan, which no other
|
|
11
|
+
* tool has to agree with: which links cite something, which anchors a heading
|
|
12
|
+
* answers to, and which lines are Markdown at all.
|
|
13
|
+
*/
|
|
14
|
+
import type { FrontMatterBlock, Heading, Link, MarkdownScan, ScannedLine } from './vendor/spec-core/markdown/index.js';
|
|
15
|
+
export { scanMarkdown, slugify } from './vendor/spec-core/markdown/index.js';
|
|
16
|
+
export type { Heading, HtmlComment, Link, LinkForm, ListItem, ScannedLine, Table, TableCell, TableRow, } from './vendor/spec-core/markdown/index.js';
|
|
17
|
+
export type { Range } from './vendor/spec-core/text/index.js';
|
|
18
|
+
/** A scanned document, under the name the API has always given it. */
|
|
19
|
+
export type ScannedDocument = MarkdownScan;
|
|
20
|
+
/** The front-matter block at the top of a document, under the name the API has always given it. */
|
|
21
|
+
export type FrontMatter = FrontMatterBlock;
|
|
22
|
+
/**
|
|
23
|
+
* Whether a line's content is Markdown.
|
|
24
|
+
*
|
|
25
|
+
* Code, the four raw-text HTML elements and front matter are not, for the same
|
|
26
|
+
* reason: a heading, a status or an item written in one is an example or data,
|
|
27
|
+
* and never a statement the document makes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isMarkdownLine(line: ScannedLine): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether a line holds a comment and nothing else.
|
|
32
|
+
*
|
|
33
|
+
* For a reader that takes the first line of a section as its value, which is
|
|
34
|
+
* what a status section is. A template's hint written above the value - `<!--
|
|
35
|
+
* proposed | accepted -->` - is not the value, and neither is a directive. A
|
|
36
|
+
* line that goes on past its comment, `<!-- hint --> Accepted`, is still read.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isOnlyComment(scanned: ScannedDocument, line: ScannedLine): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The links that cite something.
|
|
41
|
+
*
|
|
42
|
+
* An image shows a file and cites nothing: a diagram of a decision is not a
|
|
43
|
+
* dependency on it, and a missing picture is a broken page, not a broken
|
|
44
|
+
* relation. So images are not references, as they never were. A wiki embed,
|
|
45
|
+
* `![[0007-sharding]]`, is the exception - it transcludes the note it names,
|
|
46
|
+
* which is the strongest citation a wiki can write - and spec-graph has always
|
|
47
|
+
* read it as one.
|
|
48
|
+
*/
|
|
49
|
+
export declare function referenceLinks(scanned: ScannedDocument): Link[];
|
|
50
|
+
/**
|
|
51
|
+
* The anchors a set of headings answers to.
|
|
12
52
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* lines and its nested content, so a resolution written on the second line of
|
|
18
|
-
* a bullet is found instead of missed.
|
|
19
|
-
* - **Everything carries absolute offsets.** No re-scanning, no drift between
|
|
20
|
-
* the text a rule matched and the position it reports.
|
|
53
|
+
* Each heading's slug, and the anchor GitHub gives it, which is the slug with
|
|
54
|
+
* `-1`, `-2` and so on for the second and later headings that slug alike. A
|
|
55
|
+
* link written against the rendered page uses the anchor; one written by hand
|
|
56
|
+
* uses the slug, and for any heading but a repeat the two are one.
|
|
21
57
|
*/
|
|
22
|
-
|
|
23
|
-
export interface Range {
|
|
24
|
-
readonly start: number;
|
|
25
|
-
readonly end: number;
|
|
26
|
-
}
|
|
27
|
-
export interface FrontMatter {
|
|
28
|
-
/** The body between the delimiters, exclusive. */
|
|
29
|
-
readonly raw: string;
|
|
30
|
-
/** Offset of the first character of `raw`. */
|
|
31
|
-
readonly start: number;
|
|
32
|
-
readonly end: number;
|
|
33
|
-
/** Offset just past the closing delimiter line. */
|
|
34
|
-
readonly bodyStart: number;
|
|
35
|
-
}
|
|
36
|
-
export interface ScannedLine {
|
|
37
|
-
/** 1-based. */
|
|
38
|
-
readonly line: number;
|
|
39
|
-
/** Offset of the raw line start. */
|
|
40
|
-
readonly start: number;
|
|
41
|
-
/** Offset just past the line, excluding its terminator. */
|
|
42
|
-
readonly end: number;
|
|
43
|
-
/** Offset of the first character after any block-quote markers. */
|
|
44
|
-
readonly contentStart: number;
|
|
45
|
-
/** Line text after block-quote markers, indentation intact. */
|
|
46
|
-
readonly content: string;
|
|
47
|
-
/** Indentation of `content`, tabs counted as four columns. */
|
|
48
|
-
readonly indent: number;
|
|
49
|
-
readonly blank: boolean;
|
|
50
|
-
readonly quoteDepth: number;
|
|
51
|
-
/** Inside a fenced or indented code block, fence delimiters included. */
|
|
52
|
-
readonly code: boolean;
|
|
53
|
-
}
|
|
54
|
-
export interface Heading {
|
|
55
|
-
readonly level: number;
|
|
56
|
-
readonly text: string;
|
|
57
|
-
/** GitHub-compatible anchor slug. */
|
|
58
|
-
readonly slug: string;
|
|
59
|
-
readonly start: number;
|
|
60
|
-
readonly end: number;
|
|
61
|
-
readonly line: number;
|
|
62
|
-
}
|
|
63
|
-
export interface ListItem {
|
|
64
|
-
/** The whole block: marker line plus continuations and nested content. */
|
|
65
|
-
readonly start: number;
|
|
66
|
-
readonly end: number;
|
|
67
|
-
/** Offset of the list marker itself. */
|
|
68
|
-
readonly markerStart: number;
|
|
69
|
-
readonly marker: string;
|
|
70
|
-
/** Offset where the item text begins, after marker and any checkbox. */
|
|
71
|
-
readonly textStart: number;
|
|
72
|
-
/** The character inside `[ ]`, or `null` when the item has no checkbox. */
|
|
73
|
-
readonly checkbox: string | null;
|
|
74
|
-
readonly checkboxStart: number | null;
|
|
75
|
-
/** First line of item text, trimmed. */
|
|
76
|
-
readonly firstLine: string;
|
|
77
|
-
/** Full item text including continuations and nested content. */
|
|
78
|
-
readonly body: string;
|
|
79
|
-
/**
|
|
80
|
-
* `body` with code and comments blanked out, same length and offsets.
|
|
81
|
-
*
|
|
82
|
-
* Anything that searches item text for meaning - resolution markers above
|
|
83
|
-
* all - must read this rather than `body`, or a fenced example nested under
|
|
84
|
-
* the item will close it.
|
|
85
|
-
*/
|
|
86
|
-
readonly maskedBody: string;
|
|
87
|
-
readonly line: number;
|
|
88
|
-
/** How many list items enclose this one. Top-level items are `0`. */
|
|
89
|
-
readonly depth: number;
|
|
90
|
-
readonly indent: number;
|
|
91
|
-
}
|
|
92
|
-
export interface HtmlComment {
|
|
93
|
-
readonly start: number;
|
|
94
|
-
readonly end: number;
|
|
95
|
-
/** Text between `<!--` and `-->`. */
|
|
96
|
-
readonly inner: string;
|
|
97
|
-
readonly innerStart: number;
|
|
98
|
-
readonly line: number;
|
|
99
|
-
}
|
|
100
|
-
export type LinkForm = 'inline' | 'reference' | 'shortcut' | 'autolink' | 'wiki' | 'definition';
|
|
101
|
-
export interface Link {
|
|
102
|
-
/** Visible label. Empty for autolinks and definitions. */
|
|
103
|
-
readonly text: string;
|
|
104
|
-
/** Destination as written: a path or a URL. */
|
|
105
|
-
readonly target: string;
|
|
106
|
-
/** Offset of the whole construct. */
|
|
107
|
-
readonly start: number;
|
|
108
|
-
readonly end: number;
|
|
109
|
-
/**
|
|
110
|
-
* Offset of `target` inside the source, for precise diagnostics.
|
|
111
|
-
*
|
|
112
|
-
* For a reference link this is inside the definition, not inside the use:
|
|
113
|
-
* `[design][one]` has no destination of its own, and the line a human edits
|
|
114
|
-
* to fix it is the one that says what `one` points at.
|
|
115
|
-
*/
|
|
116
|
-
readonly targetStart: number;
|
|
117
|
-
/**
|
|
118
|
-
* The reference label, for the two forms written with one.
|
|
119
|
-
*
|
|
120
|
-
* `null` everywhere else. Kept because `target` is the destination the label
|
|
121
|
-
* stands for, and a report quoting `[design][docs/gone.md]` would be quoting
|
|
122
|
-
* something the author never wrote.
|
|
123
|
-
*/
|
|
124
|
-
readonly label: string | null;
|
|
125
|
-
readonly form: LinkForm;
|
|
126
|
-
readonly line: number;
|
|
127
|
-
}
|
|
128
|
-
export interface TableCell {
|
|
129
|
-
/** Cell text as written, trimmed. */
|
|
130
|
-
readonly text: string;
|
|
131
|
-
/** Offset of the trimmed text, so a finding can point at the cell itself. */
|
|
132
|
-
readonly start: number;
|
|
133
|
-
readonly end: number;
|
|
134
|
-
}
|
|
135
|
-
export interface TableRow {
|
|
136
|
-
readonly cells: readonly TableCell[];
|
|
137
|
-
readonly start: number;
|
|
138
|
-
readonly end: number;
|
|
139
|
-
readonly line: number;
|
|
140
|
-
}
|
|
141
|
-
export interface Table {
|
|
142
|
-
readonly start: number;
|
|
143
|
-
readonly end: number;
|
|
144
|
-
/** Header cells, trimmed. A table without a header row is not a table. */
|
|
145
|
-
readonly headers: readonly TableCell[];
|
|
146
|
-
readonly rows: readonly TableRow[];
|
|
147
|
-
}
|
|
148
|
-
export interface ScannedDocument {
|
|
149
|
-
readonly text: string;
|
|
150
|
-
readonly index: LineIndex;
|
|
151
|
-
readonly frontMatter: FrontMatter | null;
|
|
152
|
-
/** Offset where the body starts, after any front matter. */
|
|
153
|
-
readonly bodyStart: number;
|
|
154
|
-
readonly lines: readonly ScannedLine[];
|
|
155
|
-
readonly headings: readonly Heading[];
|
|
156
|
-
readonly listItems: readonly ListItem[];
|
|
157
|
-
readonly comments: readonly HtmlComment[];
|
|
158
|
-
readonly links: readonly Link[];
|
|
159
|
-
readonly tables: readonly Table[];
|
|
160
|
-
/** Code and comments blanked out, offsets and line breaks preserved. */
|
|
161
|
-
readonly masked: string;
|
|
162
|
-
/** True when the offset falls inside code, a comment, or front matter. */
|
|
163
|
-
isMasked(offset: number): boolean;
|
|
164
|
-
}
|
|
165
|
-
export declare function scanMarkdown(source: string): ScannedDocument;
|
|
166
|
-
export declare function slugify(text: string): string;
|
|
58
|
+
export declare function anchorsOf(headings: readonly Heading[]): Set<string>;
|