@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
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recognisers for what one line of Markdown opens.
|
|
3
|
+
*
|
|
4
|
+
* Each takes a line's content - after any block-quote markers, without its
|
|
5
|
+
* terminator - and answers in time linear in the line. They are written as
|
|
6
|
+
* loops where a regular expression would have to backtrack: a line of forty
|
|
7
|
+
* thousand spaces is a document someone can commit.
|
|
8
|
+
*/
|
|
9
|
+
const TAB = 9;
|
|
10
|
+
const SPACE = 32;
|
|
11
|
+
const HASH = 35;
|
|
12
|
+
const GREATER_THAN = 62;
|
|
13
|
+
/** Columns of leading whitespace, a tab reaching the next multiple of four. */
|
|
14
|
+
export function measureIndent(content) {
|
|
15
|
+
return measureIndentAt(content, 0, content.length);
|
|
16
|
+
}
|
|
17
|
+
/** Columns of whitespace from an offset, stopping at the first other character or at `to`. */
|
|
18
|
+
export function measureIndentAt(text, from, to) {
|
|
19
|
+
let width = 0;
|
|
20
|
+
for (let i = from; i < to; i += 1) {
|
|
21
|
+
const ch = text.charCodeAt(i);
|
|
22
|
+
if (ch === SPACE)
|
|
23
|
+
width += 1;
|
|
24
|
+
else if (ch === TAB)
|
|
25
|
+
width += 4 - (width % 4);
|
|
26
|
+
else
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
return width;
|
|
30
|
+
}
|
|
31
|
+
/** Index of the first character that is not a space or a tab; the length when there is none. */
|
|
32
|
+
export function leadIndex(content) {
|
|
33
|
+
let i = 0;
|
|
34
|
+
while (content.charCodeAt(i) === SPACE || content.charCodeAt(i) === TAB)
|
|
35
|
+
i += 1;
|
|
36
|
+
return i;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Where what opens a line starts: just past up to three spaces. After four
|
|
40
|
+
* nothing opens there, and the answer is the end of the line, where every
|
|
41
|
+
* recogniser below finds nothing.
|
|
42
|
+
*/
|
|
43
|
+
function opening(content) {
|
|
44
|
+
let i = 0;
|
|
45
|
+
while (i < 4 && content.charCodeAt(i) === SPACE)
|
|
46
|
+
i += 1;
|
|
47
|
+
return i === 4 ? content.length : i;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Takes up to `maxDepth` block-quote markers off the line starting at
|
|
51
|
+
* `start`: up to three spaces, a `>`, and one optional space, as many times as
|
|
52
|
+
* they repeat. The line ends at a terminator or at the end of the text, and
|
|
53
|
+
* neither is a space or a `>`, so nothing here reads past it.
|
|
54
|
+
*/
|
|
55
|
+
export function stripQuotes(text, start, maxDepth) {
|
|
56
|
+
let at = start;
|
|
57
|
+
let depth = 0;
|
|
58
|
+
while (depth < maxDepth) {
|
|
59
|
+
let j = at;
|
|
60
|
+
while (j - at < 3 && (text.charCodeAt(j) === SPACE || text.charCodeAt(j) === TAB))
|
|
61
|
+
j += 1;
|
|
62
|
+
if (text.charCodeAt(j) !== GREATER_THAN)
|
|
63
|
+
break;
|
|
64
|
+
j += 1;
|
|
65
|
+
if (text.charCodeAt(j) === SPACE)
|
|
66
|
+
j += 1;
|
|
67
|
+
depth += 1;
|
|
68
|
+
at = j;
|
|
69
|
+
}
|
|
70
|
+
return { contentStart: at, depth };
|
|
71
|
+
}
|
|
72
|
+
// A line's content holds no terminator, so `.*` reaches its end unanchored.
|
|
73
|
+
const FENCE = /^([ \t]*)(`{3,}|~{3,})(.*)/;
|
|
74
|
+
const FENCE_CLOSE = /^([ \t]*)(`{3,}|~{3,})[ \t]*$/;
|
|
75
|
+
/**
|
|
76
|
+
* A code fence opening the line, at any indentation: a fence inside a list
|
|
77
|
+
* item is indented with the item.
|
|
78
|
+
*/
|
|
79
|
+
export function fenceOpen(content) {
|
|
80
|
+
const match = FENCE.exec(content);
|
|
81
|
+
if (match === null)
|
|
82
|
+
return null;
|
|
83
|
+
const run = match[2];
|
|
84
|
+
const info = match[3];
|
|
85
|
+
// CommonMark: a backtick fence's info string may not hold a backtick. The
|
|
86
|
+
// line is a paragraph whose backticks open code spans, not a fence that
|
|
87
|
+
// swallows the rest of the document.
|
|
88
|
+
if (run.charCodeAt(0) === 0x60 && info.includes('`'))
|
|
89
|
+
return null;
|
|
90
|
+
return { char: run.charAt(0), length: run.length, indent: measureIndent(match[1]), info: info.trim() };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether a line closes an open fence: the same character, at least as many
|
|
94
|
+
* of it, nothing but whitespace after, and no more than three columns deeper
|
|
95
|
+
* than the opening fence.
|
|
96
|
+
*/
|
|
97
|
+
export function fenceCloses(content, fence) {
|
|
98
|
+
const match = FENCE_CLOSE.exec(content);
|
|
99
|
+
if (match === null)
|
|
100
|
+
return false;
|
|
101
|
+
const run = match[2];
|
|
102
|
+
return run.charAt(0) === fence.char && run.length >= fence.length && measureIndent(match[1]) <= fence.indent + 3;
|
|
103
|
+
}
|
|
104
|
+
/** The level of an ATX heading opening the line, or 0. */
|
|
105
|
+
export function atxLevel(content) {
|
|
106
|
+
const at = opening(content);
|
|
107
|
+
let level = 0;
|
|
108
|
+
while (content.charCodeAt(at + level) === HASH)
|
|
109
|
+
level += 1;
|
|
110
|
+
// Seven are text. None is 0 whatever follows, which is what this returns.
|
|
111
|
+
if (level > 6)
|
|
112
|
+
return 0;
|
|
113
|
+
const next = at + level;
|
|
114
|
+
if (next === content.length)
|
|
115
|
+
return level;
|
|
116
|
+
const ch = content.charCodeAt(next);
|
|
117
|
+
return ch === SPACE || ch === TAB ? level : 0;
|
|
118
|
+
}
|
|
119
|
+
/** Three or more of one of `*`, `-` or `_`, with nothing but spaces and tabs between. */
|
|
120
|
+
export function isThematicBreak(content) {
|
|
121
|
+
const at = opening(content);
|
|
122
|
+
const mark = content.charAt(at);
|
|
123
|
+
if (mark !== '*' && mark !== '-' && mark !== '_')
|
|
124
|
+
return false;
|
|
125
|
+
let count = 0;
|
|
126
|
+
for (let i = at; i < content.length; i += 1) {
|
|
127
|
+
const ch = content.charAt(i);
|
|
128
|
+
if (ch === mark)
|
|
129
|
+
count += 1;
|
|
130
|
+
else if (ch !== ' ' && ch !== '\t')
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return count >= 3;
|
|
134
|
+
}
|
|
135
|
+
/** `=` or `-` for a line that could underline a setext heading, else `null`. */
|
|
136
|
+
export function setextUnderline(content) {
|
|
137
|
+
let at = opening(content);
|
|
138
|
+
const mark = content.charAt(at);
|
|
139
|
+
if (mark !== '=' && mark !== '-')
|
|
140
|
+
return null;
|
|
141
|
+
while (content.charAt(at) === mark)
|
|
142
|
+
at += 1;
|
|
143
|
+
while (content.charAt(at) === ' ' || content.charAt(at) === '\t')
|
|
144
|
+
at += 1;
|
|
145
|
+
return at === content.length ? mark : null;
|
|
146
|
+
}
|
|
147
|
+
const LIST_MARKER = /^([ \t]*)([-*+]|\d{1,9}[.)])([ \t]+|$)/;
|
|
148
|
+
/**
|
|
149
|
+
* A list marker opening the line, at any indentation. A thematic break that
|
|
150
|
+
* could also be read as one (`- - -`) is a thematic break.
|
|
151
|
+
*/
|
|
152
|
+
export function listMarker(content) {
|
|
153
|
+
const match = LIST_MARKER.exec(content);
|
|
154
|
+
if (match === null || isThematicBreak(content))
|
|
155
|
+
return null;
|
|
156
|
+
const marker = match[2];
|
|
157
|
+
return { offset: match[1].length, marker, width: marker.length + match[3].length };
|
|
158
|
+
}
|
|
159
|
+
const RAW_TEXT_OPEN = /^[ \t]*<(?:script|pre|style|textarea)(?:[ \t>]|$)/i;
|
|
160
|
+
const RAW_TEXT_CLOSE = /<\/(?:script|pre|style|textarea)>/i;
|
|
161
|
+
/**
|
|
162
|
+
* `<script>`, `<pre>`, `<style>` or `<textarea>` opening the line.
|
|
163
|
+
*
|
|
164
|
+
* These four are the HTML elements whose content CommonMark does not read as
|
|
165
|
+
* Markdown. A page explaining a directive puts an example inside one, and the
|
|
166
|
+
* example must not be read as the directive. `<div>` and `<details>` are not
|
|
167
|
+
* on the list: their content is Markdown, and a decision written inside a
|
|
168
|
+
* collapsed section is still a decision.
|
|
169
|
+
*/
|
|
170
|
+
export function isRawTextOpen(content) {
|
|
171
|
+
return RAW_TEXT_OPEN.test(content);
|
|
172
|
+
}
|
|
173
|
+
/** Whether a line holds the close tag of any of the four raw-text elements. */
|
|
174
|
+
export function hasRawTextClose(content) {
|
|
175
|
+
return RAW_TEXT_CLOSE.test(content);
|
|
176
|
+
}
|
|
177
|
+
/** `<!--` opening the line after up to three spaces. */
|
|
178
|
+
export function opensComment(content) {
|
|
179
|
+
return content.startsWith('<!--', opening(content));
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=syntax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syntax.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/syntax.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,M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C","sourcesContent":["/**\n * Recognisers for what one line of Markdown opens.\n *\n * Each takes a line's content - after any block-quote markers, without its\n * terminator - and answers in time linear in the line. They are written as\n * loops where a regular expression would have to backtrack: a line of forty\n * thousand spaces is a document someone can commit.\n */\n\nconst TAB = 9;\nconst SPACE = 32;\nconst HASH = 35;\nconst GREATER_THAN = 62;\n\n/** Columns of leading whitespace, a tab reaching the next multiple of four. */\nexport function measureIndent(content: string): number {\n return measureIndentAt(content, 0, content.length);\n}\n\n/** Columns of whitespace from an offset, stopping at the first other character or at `to`. */\nexport function measureIndentAt(text: string, from: number, to: number): number {\n let width = 0;\n for (let i = from; i < to; i += 1) {\n const ch = text.charCodeAt(i);\n if (ch === SPACE) width += 1;\n else if (ch === TAB) width += 4 - (width % 4);\n else break;\n }\n return width;\n}\n\n/** Index of the first character that is not a space or a tab; the length when there is none. */\nexport function leadIndex(content: string): number {\n let i = 0;\n while (content.charCodeAt(i) === SPACE || content.charCodeAt(i) === TAB) i += 1;\n return i;\n}\n\n/**\n * Where what opens a line starts: just past up to three spaces. After four\n * nothing opens there, and the answer is the end of the line, where every\n * recogniser below finds nothing.\n */\nfunction opening(content: string): number {\n let i = 0;\n while (i < 4 && content.charCodeAt(i) === SPACE) i += 1;\n return i === 4 ? content.length : i;\n}\n\n/**\n * Takes up to `maxDepth` block-quote markers off the line starting at\n * `start`: up to three spaces, a `>`, and one optional space, as many times as\n * they repeat. The line ends at a terminator or at the end of the text, and\n * neither is a space or a `>`, so nothing here reads past it.\n */\nexport function stripQuotes(text: string, start: number, maxDepth: number): { readonly contentStart: number; readonly depth: number } {\n let at = start;\n let depth = 0;\n while (depth < maxDepth) {\n let j = at;\n while (j - at < 3 && (text.charCodeAt(j) === SPACE || text.charCodeAt(j) === TAB)) j += 1;\n if (text.charCodeAt(j) !== GREATER_THAN) break;\n j += 1;\n if (text.charCodeAt(j) === SPACE) j += 1;\n depth += 1;\n at = j;\n }\n return { contentStart: at, depth };\n}\n\nexport interface FenceOpen {\n /** `` ` `` or `~`. */\n readonly char: string;\n readonly length: number;\n /** Columns before the fence. */\n readonly indent: number;\n readonly info: string;\n}\n\n// A line's content holds no terminator, so `.*` reaches its end unanchored.\nconst FENCE = /^([ \\t]*)(`{3,}|~{3,})(.*)/;\nconst FENCE_CLOSE = /^([ \\t]*)(`{3,}|~{3,})[ \\t]*$/;\n\n/**\n * A code fence opening the line, at any indentation: a fence inside a list\n * item is indented with the item.\n */\nexport function fenceOpen(content: string): FenceOpen | null {\n const match = FENCE.exec(content);\n if (match === null) return null;\n const run = match[2] as string;\n const info = match[3] as string;\n // CommonMark: a backtick fence's info string may not hold a backtick. The\n // line is a paragraph whose backticks open code spans, not a fence that\n // swallows the rest of the document.\n if (run.charCodeAt(0) === 0x60 && info.includes('`')) return null;\n return { char: run.charAt(0), length: run.length, indent: measureIndent(match[1] as string), info: info.trim() };\n}\n\n/**\n * Whether a line closes an open fence: the same character, at least as many\n * of it, nothing but whitespace after, and no more than three columns deeper\n * than the opening fence.\n */\nexport function fenceCloses(content: string, fence: FenceOpen): boolean {\n const match = FENCE_CLOSE.exec(content);\n if (match === null) return false;\n const run = match[2] as string;\n return run.charAt(0) === fence.char && run.length >= fence.length && measureIndent(match[1] as string) <= fence.indent + 3;\n}\n\n/** The level of an ATX heading opening the line, or 0. */\nexport function atxLevel(content: string): number {\n const at = opening(content);\n let level = 0;\n while (content.charCodeAt(at + level) === HASH) level += 1;\n // Seven are text. None is 0 whatever follows, which is what this returns.\n if (level > 6) return 0;\n const next = at + level;\n if (next === content.length) return level;\n const ch = content.charCodeAt(next);\n return ch === SPACE || ch === TAB ? level : 0;\n}\n\n/** Three or more of one of `*`, `-` or `_`, with nothing but spaces and tabs between. */\nexport function isThematicBreak(content: string): boolean {\n const at = opening(content);\n const mark = content.charAt(at);\n if (mark !== '*' && mark !== '-' && mark !== '_') return false;\n let count = 0;\n for (let i = at; i < content.length; i += 1) {\n const ch = content.charAt(i);\n if (ch === mark) count += 1;\n else if (ch !== ' ' && ch !== '\\t') return false;\n }\n return count >= 3;\n}\n\n/** `=` or `-` for a line that could underline a setext heading, else `null`. */\nexport function setextUnderline(content: string): '=' | '-' | null {\n let at = opening(content);\n const mark = content.charAt(at);\n if (mark !== '=' && mark !== '-') return null;\n while (content.charAt(at) === mark) at += 1;\n while (content.charAt(at) === ' ' || content.charAt(at) === '\\t') at += 1;\n return at === content.length ? mark : null;\n}\n\nexport interface ListMarker {\n /** Characters of whitespace before the marker. */\n readonly offset: number;\n readonly marker: string;\n /** Characters from the marker's start to the item's text. */\n readonly width: number;\n}\n\nconst LIST_MARKER = /^([ \\t]*)([-*+]|\\d{1,9}[.)])([ \\t]+|$)/;\n\n/**\n * A list marker opening the line, at any indentation. A thematic break that\n * could also be read as one (`- - -`) is a thematic break.\n */\nexport function listMarker(content: string): ListMarker | null {\n const match = LIST_MARKER.exec(content);\n if (match === null || isThematicBreak(content)) return null;\n const marker = match[2] as string;\n return { offset: (match[1] as string).length, marker, width: marker.length + (match[3] as string).length };\n}\n\nconst RAW_TEXT_OPEN = /^[ \\t]*<(?:script|pre|style|textarea)(?:[ \\t>]|$)/i;\nconst RAW_TEXT_CLOSE = /<\\/(?:script|pre|style|textarea)>/i;\n\n/**\n * `<script>`, `<pre>`, `<style>` or `<textarea>` opening the line.\n *\n * These four are the HTML elements whose content CommonMark does not read as\n * Markdown. A page explaining a directive puts an example inside one, and the\n * example must not be read as the directive. `<div>` and `<details>` are not\n * on the list: their content is Markdown, and a decision written inside a\n * collapsed section is still a decision.\n */\nexport function isRawTextOpen(content: string): boolean {\n return RAW_TEXT_OPEN.test(content);\n}\n\n/** Whether a line holds the close tag of any of the four raw-text elements. */\nexport function hasRawTextClose(content: string): boolean {\n return RAW_TEXT_CLOSE.test(content);\n}\n\n/** `<!--` opening the line after up to three spaces. */\nexport function opensComment(content: string): boolean {\n return content.startsWith('<!--', opening(content));\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GFM pipe tables, with an offset for every cell.
|
|
3
|
+
*
|
|
4
|
+
* Cell offsets are the point: a register kept as a table needs findings that
|
|
5
|
+
* name the cell declaring a relation, not the row and not the file. Rows are
|
|
6
|
+
* split on the structure mask, so a pipe inside a code span or a comment
|
|
7
|
+
* cannot invent a column, and the text of each cell comes from the original.
|
|
8
|
+
*
|
|
9
|
+
* Reading one line past the last, or one character past a line's end, finds
|
|
10
|
+
* no row and no pipe, so mutants that move those bounds are equivalent.
|
|
11
|
+
*/
|
|
12
|
+
import { type Layout } from './layout.js';
|
|
13
|
+
import type { Heading, Table } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* A header line, a delimiter row with as many cells, and the rows under them
|
|
16
|
+
* up to a line that is blank, holds no pipe, or is not Markdown.
|
|
17
|
+
*/
|
|
18
|
+
export declare function findTables(layout: Layout, atx: readonly Pick<Heading, 'line'>[]): Table[];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GFM pipe tables, with an offset for every cell.
|
|
3
|
+
*
|
|
4
|
+
* Cell offsets are the point: a register kept as a table needs findings that
|
|
5
|
+
* name the cell declaring a relation, not the row and not the file. Rows are
|
|
6
|
+
* split on the structure mask, so a pipe inside a code span or a comment
|
|
7
|
+
* cannot invent a column, and the text of each cell comes from the original.
|
|
8
|
+
*
|
|
9
|
+
* Reading one line past the last, or one character past a line's end, finds
|
|
10
|
+
* no row and no pipe, so mutants that move those bounds are equivalent.
|
|
11
|
+
*/
|
|
12
|
+
import { isMarkdown, leadOffset } from './layout.js';
|
|
13
|
+
const PIPE = 124;
|
|
14
|
+
const BACKSLASH = 92;
|
|
15
|
+
const DELIMITER_CELL = /^:?-+:?$/;
|
|
16
|
+
/**
|
|
17
|
+
* A header line, a delimiter row with as many cells, and the rows under them
|
|
18
|
+
* up to a line that is blank, holds no pipe, or is not Markdown.
|
|
19
|
+
*/
|
|
20
|
+
export function findTables(layout, atx) {
|
|
21
|
+
const { lines } = layout;
|
|
22
|
+
const heading = new Set(atx.map((h) => h.line));
|
|
23
|
+
// A line starting in a comment is not a row, and neither is one that
|
|
24
|
+
// continues a code span or comment from the line above.
|
|
25
|
+
const row = (i) => {
|
|
26
|
+
const line = lines[i];
|
|
27
|
+
if (line === undefined || !isMarkdown(line) || line.blank || line.comment)
|
|
28
|
+
return null;
|
|
29
|
+
return layout.covered.has(line.line) || heading.has(line.line) ? null : line;
|
|
30
|
+
};
|
|
31
|
+
const out = [];
|
|
32
|
+
for (let i = 0; i + 1 < lines.length; i += 1) {
|
|
33
|
+
const header = row(i);
|
|
34
|
+
const delimiter = row(i + 1);
|
|
35
|
+
if (header === null || delimiter === null)
|
|
36
|
+
continue;
|
|
37
|
+
const headers = splitRow(layout, header);
|
|
38
|
+
if (headers.length === 0)
|
|
39
|
+
continue;
|
|
40
|
+
const marks = splitRow(layout, delimiter);
|
|
41
|
+
if (marks.length !== headers.length || !marks.every((cell) => DELIMITER_CELL.test(cell.text)))
|
|
42
|
+
continue;
|
|
43
|
+
const rows = [];
|
|
44
|
+
let last = delimiter;
|
|
45
|
+
for (let line = row(i + 2); line !== null; line = row(line.line)) {
|
|
46
|
+
const cells = splitRow(layout, line);
|
|
47
|
+
if (cells.length === 0)
|
|
48
|
+
break;
|
|
49
|
+
rows.push({ cells, start: line.contentStart, end: line.end, line: line.line });
|
|
50
|
+
last = line;
|
|
51
|
+
}
|
|
52
|
+
out.push({ start: header.contentStart, end: last.end, line: header.line, endLine: last.line, headers, rows });
|
|
53
|
+
i = last.line - 1;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** Splits a row into cells, keeping each cell's offsets. A row without a pipe has none. */
|
|
58
|
+
function splitRow(layout, line) {
|
|
59
|
+
const { text, structure } = layout;
|
|
60
|
+
const bounds = [];
|
|
61
|
+
for (let at = line.contentStart; at < line.end; at += 1) {
|
|
62
|
+
// A pipe escaped with a backslash is content, not a column edge.
|
|
63
|
+
if (structure.charCodeAt(at) === PIPE && text.charCodeAt(at - 1) !== BACKSLASH)
|
|
64
|
+
bounds.push(at);
|
|
65
|
+
}
|
|
66
|
+
if (bounds.length === 0)
|
|
67
|
+
return [];
|
|
68
|
+
const cells = [];
|
|
69
|
+
// A pipe opening the row is a border, not the edge of an empty first cell.
|
|
70
|
+
let cursor = bounds[0] === leadOffset(line) ? bounds.shift() + 1 : line.contentStart;
|
|
71
|
+
for (const bound of bounds) {
|
|
72
|
+
cells.push(cell(text, cursor, bound));
|
|
73
|
+
cursor = bound + 1;
|
|
74
|
+
}
|
|
75
|
+
// What follows the last pipe is a cell unless the row ended with a border.
|
|
76
|
+
if (text.slice(cursor, line.end).trim().length > 0)
|
|
77
|
+
cells.push(cell(text, cursor, line.end));
|
|
78
|
+
return cells;
|
|
79
|
+
}
|
|
80
|
+
function cell(text, start, end) {
|
|
81
|
+
const raw = text.slice(start, end);
|
|
82
|
+
const leading = raw.length - raw.trimStart().length;
|
|
83
|
+
const trimmed = raw.trim();
|
|
84
|
+
return { text: trimmed, start: start + leading, end: start + leading + trimmed.length };
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAGlE,MAAM,IAAI,GAAG,GAAG,CAAC;AACjB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,GAAqC;IAC9E,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IACzB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAA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AAG,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;AAC1F,CAAC","sourcesContent":["/**\n * GFM pipe tables, with an offset for every cell.\n *\n * Cell offsets are the point: a register kept as a table needs findings that\n * name the cell declaring a relation, not the row and not the file. Rows are\n * split on the structure mask, so a pipe inside a code span or a comment\n * cannot invent a column, and the text of each cell comes from the original.\n *\n * Reading one line past the last, or one character past a line's end, finds\n * no row and no pipe, so mutants that move those bounds are equivalent.\n */\n\nimport { isMarkdown, leadOffset, type Layout } from './layout.js';\nimport type { Heading, ScannedLine, Table, TableCell, TableRow } from './types.js';\n\nconst PIPE = 124;\nconst BACKSLASH = 92;\nconst DELIMITER_CELL = /^:?-+:?$/;\n\n/**\n * A header line, a delimiter row with as many cells, and the rows under them\n * up to a line that is blank, holds no pipe, or is not Markdown.\n */\nexport function findTables(layout: Layout, atx: readonly Pick<Heading, 'line'>[]): Table[] {\n const { lines } = layout;\n const heading = new Set(atx.map((h) => h.line));\n // A line starting in a comment is not a row, and neither is one that\n // continues a code span or comment from the line above.\n const row = (i: number): ScannedLine | null => {\n const line = lines[i];\n if (line === undefined || !isMarkdown(line) || line.blank || line.comment) return null;\n return layout.covered.has(line.line) || heading.has(line.line) ? null : line;\n };\n\n const out: Table[] = [];\n for (let i = 0; i + 1 < lines.length; i += 1) {\n const header = row(i);\n const delimiter = row(i + 1);\n if (header === null || delimiter === null) continue;\n const headers = splitRow(layout, header);\n if (headers.length === 0) continue;\n const marks = splitRow(layout, delimiter);\n if (marks.length !== headers.length || !marks.every((cell) => DELIMITER_CELL.test(cell.text))) continue;\n\n const rows: TableRow[] = [];\n let last = delimiter;\n for (let line = row(i + 2); line !== null; line = row(line.line)) {\n const cells = splitRow(layout, line);\n if (cells.length === 0) break;\n rows.push({ cells, start: line.contentStart, end: line.end, line: line.line });\n last = line;\n }\n out.push({ start: header.contentStart, end: last.end, line: header.line, endLine: last.line, headers, rows });\n i = last.line - 1;\n }\n return out;\n}\n\n/** Splits a row into cells, keeping each cell's offsets. A row without a pipe has none. */\nfunction splitRow(layout: Layout, line: ScannedLine): TableCell[] {\n const { text, structure } = layout;\n const bounds: number[] = [];\n for (let at = line.contentStart; at < line.end; at += 1) {\n // A pipe escaped with a backslash is content, not a column edge.\n if (structure.charCodeAt(at) === PIPE && text.charCodeAt(at - 1) !== BACKSLASH) bounds.push(at);\n }\n if (bounds.length === 0) return [];\n\n const cells: TableCell[] = [];\n // A pipe opening the row is a border, not the edge of an empty first cell.\n let cursor = bounds[0] === leadOffset(line) ? (bounds.shift() as number) + 1 : line.contentStart;\n for (const bound of bounds) {\n cells.push(cell(text, cursor, bound));\n cursor = bound + 1;\n }\n // What follows the last pipe is a cell unless the row ended with a border.\n if (text.slice(cursor, line.end).trim().length > 0) cells.push(cell(text, cursor, line.end));\n return cells;\n}\n\nfunction cell(text: string, start: number, end: number): TableCell {\n const raw = text.slice(start, end);\n const leading = raw.length - raw.trimStart().length;\n const trimmed = raw.trim();\n return { text: trimmed, start: start + leading, end: start + leading + trimmed.length };\n}\n"]}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes a scan produces.
|
|
3
|
+
*
|
|
4
|
+
* Every structure carries absolute UTF-16 offsets into the scanned text - the
|
|
5
|
+
* text after any byte-order mark - and a 1-based line. Nothing holds a copy of
|
|
6
|
+
* the document that a rule could match against and then report somewhere else.
|
|
7
|
+
*/
|
|
8
|
+
import type { LineIndex, Range } from '../text/index.js';
|
|
9
|
+
/** The three masked copies of a document; see {@link Masks}. */
|
|
10
|
+
export type MaskKind = 'structure' | 'prose' | 'directives';
|
|
11
|
+
/**
|
|
12
|
+
* Copies of the text with some constructs blanked to spaces.
|
|
13
|
+
*
|
|
14
|
+
* Every copy has the length of the text and its line terminators at the same
|
|
15
|
+
* offsets, so a match at an offset of a mask is at that offset of the text, on
|
|
16
|
+
* the same line and in the same column.
|
|
17
|
+
*/
|
|
18
|
+
export interface Masks {
|
|
19
|
+
/**
|
|
20
|
+
* Front matter, block code, raw-text HTML, code spans and comments blanked:
|
|
21
|
+
* what counts as structure. Headings, list items, links and tables are read
|
|
22
|
+
* from this copy.
|
|
23
|
+
*/
|
|
24
|
+
readonly structure: string;
|
|
25
|
+
/**
|
|
26
|
+
* Front matter and comments blanked, code kept: what counts as content. A
|
|
27
|
+
* section holding only a template hint in a comment is empty; one holding
|
|
28
|
+
* only a code sample is not.
|
|
29
|
+
*/
|
|
30
|
+
readonly prose: string;
|
|
31
|
+
/**
|
|
32
|
+
* Front matter, block code, raw-text HTML and code spans blanked, comments
|
|
33
|
+
* kept: where a directive written in a comment is read, so that one shown in
|
|
34
|
+
* a code sample is not.
|
|
35
|
+
*/
|
|
36
|
+
readonly directives: string;
|
|
37
|
+
}
|
|
38
|
+
export type FrontMatterKind = 'yaml' | 'toml';
|
|
39
|
+
/** The metadata block at the top of a document. */
|
|
40
|
+
export interface FrontMatterBlock {
|
|
41
|
+
/** YAML between `---` lines, closed by `---` or `...`; TOML between `+++` lines. */
|
|
42
|
+
readonly kind: FrontMatterKind;
|
|
43
|
+
/** The text between the delimiter lines. */
|
|
44
|
+
readonly raw: string;
|
|
45
|
+
/** Offset of the first character of `raw`. */
|
|
46
|
+
readonly start: number;
|
|
47
|
+
/** Offset just past `raw`: the start of the closing delimiter line. */
|
|
48
|
+
readonly end: number;
|
|
49
|
+
/** Offset just past the closing delimiter line and its terminator. */
|
|
50
|
+
readonly bodyStart: number;
|
|
51
|
+
/** 1-based line of the closing delimiter. */
|
|
52
|
+
readonly closeLine: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* One line of the document. Every line has one, front matter included, so the
|
|
56
|
+
* record for line `n` is at index `n - 1`.
|
|
57
|
+
*/
|
|
58
|
+
export interface ScannedLine {
|
|
59
|
+
/** 1-based. */
|
|
60
|
+
readonly line: number;
|
|
61
|
+
/** Offset of the line's first character. */
|
|
62
|
+
readonly start: number;
|
|
63
|
+
/** Offset just past the line, before its terminator. */
|
|
64
|
+
readonly end: number;
|
|
65
|
+
/**
|
|
66
|
+
* Offset of the first character after the block-quote markers. In a fenced
|
|
67
|
+
* block only the markers of the quote holding the fence are taken off: a `>`
|
|
68
|
+
* written inside the code is code.
|
|
69
|
+
*/
|
|
70
|
+
readonly contentStart: number;
|
|
71
|
+
/** The line from `contentStart`, indentation intact. */
|
|
72
|
+
readonly content: string;
|
|
73
|
+
/** Indentation of `content` in columns, a tab reaching the next multiple of four. */
|
|
74
|
+
readonly indent: number;
|
|
75
|
+
/** `content` is empty or whitespace. */
|
|
76
|
+
readonly blank: boolean;
|
|
77
|
+
readonly quoteDepth: number;
|
|
78
|
+
/** Part of the front matter, delimiters included. */
|
|
79
|
+
readonly frontMatter: boolean;
|
|
80
|
+
/** Part of a fenced or indented code block, fences included. */
|
|
81
|
+
readonly code: boolean;
|
|
82
|
+
/** Part of a `<script>`, `<pre>`, `<style>` or `<textarea>` block. */
|
|
83
|
+
readonly html: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The line's first non-blank character is inside an HTML comment. What is
|
|
86
|
+
* written there is not Markdown, whatever it looks like. Never set on a blank
|
|
87
|
+
* line.
|
|
88
|
+
*/
|
|
89
|
+
readonly comment: boolean;
|
|
90
|
+
}
|
|
91
|
+
export type BlockKind = 'fenced' | 'indented' | 'html';
|
|
92
|
+
/** A block whose content is not Markdown: code, or raw-text HTML. */
|
|
93
|
+
export interface Block {
|
|
94
|
+
readonly kind: BlockKind;
|
|
95
|
+
/** Offset of the first line's first character. */
|
|
96
|
+
readonly start: number;
|
|
97
|
+
/** Offset just past the last line, before its terminator. */
|
|
98
|
+
readonly end: number;
|
|
99
|
+
/** 1-based first line: the opening fence or tag, or the first code line. */
|
|
100
|
+
readonly line: number;
|
|
101
|
+
/** 1-based last line. */
|
|
102
|
+
readonly endLine: number;
|
|
103
|
+
/** A fenced block's info string, trimmed; empty for the other kinds. */
|
|
104
|
+
readonly info: string;
|
|
105
|
+
/**
|
|
106
|
+
* Whether a closing fence or closing tag ended the block. One that runs to
|
|
107
|
+
* the end of the document or of its block quote is not closed. An indented
|
|
108
|
+
* block always is.
|
|
109
|
+
*/
|
|
110
|
+
readonly closed: boolean;
|
|
111
|
+
}
|
|
112
|
+
export interface HtmlComment {
|
|
113
|
+
/** Offset of `<!--`. */
|
|
114
|
+
readonly start: number;
|
|
115
|
+
/** Offset just past `-->`, or the end of the text for one never closed. */
|
|
116
|
+
readonly end: number;
|
|
117
|
+
/** The text between `<!--` and `-->`. */
|
|
118
|
+
readonly inner: string;
|
|
119
|
+
readonly innerStart: number;
|
|
120
|
+
/** 1-based line of `<!--`. */
|
|
121
|
+
readonly line: number;
|
|
122
|
+
/**
|
|
123
|
+
* False for a comment that opens a line and is never closed, which runs to
|
|
124
|
+
* the end of the document as CommonMark's HTML block does. A `<!--` in the
|
|
125
|
+
* middle of a line with no `-->` after it is text, and is not a comment.
|
|
126
|
+
*/
|
|
127
|
+
readonly closed: boolean;
|
|
128
|
+
}
|
|
129
|
+
export type HeadingForm = 'atx' | 'setext';
|
|
130
|
+
export interface Heading {
|
|
131
|
+
readonly form: HeadingForm;
|
|
132
|
+
readonly level: number;
|
|
133
|
+
/**
|
|
134
|
+
* The text a reader sees: trimmed, without an ATX closing sequence, and
|
|
135
|
+
* without any comment in it. Code spans are kept as written.
|
|
136
|
+
*/
|
|
137
|
+
readonly text: string;
|
|
138
|
+
/** GitHub's slug of `text`. */
|
|
139
|
+
readonly slug: string;
|
|
140
|
+
/**
|
|
141
|
+
* The anchor GitHub gives the heading: its slug, with `-1`, `-2` and so on
|
|
142
|
+
* appended for the second and later headings that slug the same.
|
|
143
|
+
*/
|
|
144
|
+
readonly anchor: string;
|
|
145
|
+
/** Offset of the heading line's content, after any block-quote markers. */
|
|
146
|
+
readonly start: number;
|
|
147
|
+
/** Offset just past the heading line, or past a setext heading's underline. */
|
|
148
|
+
readonly end: number;
|
|
149
|
+
/** Offsets of `text` as written; a comment inside it is between them. */
|
|
150
|
+
readonly textStart: number;
|
|
151
|
+
readonly textEnd: number;
|
|
152
|
+
/** 1-based line of the heading text. */
|
|
153
|
+
readonly line: number;
|
|
154
|
+
/** 1-based last line: the underline of a setext heading. */
|
|
155
|
+
readonly endLine: number;
|
|
156
|
+
}
|
|
157
|
+
/** A heading and everything under it up to the next heading at its level or above. */
|
|
158
|
+
export interface Section {
|
|
159
|
+
readonly heading: Heading;
|
|
160
|
+
/** Offset of the heading line's first character. */
|
|
161
|
+
readonly start: number;
|
|
162
|
+
/** Offset of the line after the heading. */
|
|
163
|
+
readonly bodyStart: number;
|
|
164
|
+
/** Offset of the first line of the next heading at this level or above, or the end of the text. */
|
|
165
|
+
readonly end: number;
|
|
166
|
+
/** 1-based line after the section: that heading's line, or one past the last line. */
|
|
167
|
+
readonly endLine: number;
|
|
168
|
+
}
|
|
169
|
+
export interface ListItem {
|
|
170
|
+
/** Offset of the marker line's content, after any block-quote markers. */
|
|
171
|
+
readonly start: number;
|
|
172
|
+
/** Offset just past the item's last line: continuations and nested content included. */
|
|
173
|
+
readonly end: number;
|
|
174
|
+
/** Offset of the marker. */
|
|
175
|
+
readonly markerStart: number;
|
|
176
|
+
/** `-`, `*`, `+`, or a number followed by `.` or `)`. */
|
|
177
|
+
readonly marker: string;
|
|
178
|
+
/** Offset of the item's text, after the marker and any checkbox. */
|
|
179
|
+
readonly textStart: number;
|
|
180
|
+
/**
|
|
181
|
+
* The character inside a task checkbox, or `null` without one. GFM's are
|
|
182
|
+
* space, `x` and `X`; `~ - ? ! * / +` are read too, and what each means is
|
|
183
|
+
* the caller's decision.
|
|
184
|
+
*/
|
|
185
|
+
readonly checkbox: string | null;
|
|
186
|
+
/** Offset of the checkbox's `[`. */
|
|
187
|
+
readonly checkboxStart: number | null;
|
|
188
|
+
/** The text of the marker line, trimmed. */
|
|
189
|
+
readonly firstLine: string;
|
|
190
|
+
/** Everything from `textStart` to `end`. */
|
|
191
|
+
readonly body: string;
|
|
192
|
+
/**
|
|
193
|
+
* `body` read from the structure mask. Anything that searches item text for
|
|
194
|
+
* meaning reads this, or a fenced example nested under the item speaks for it.
|
|
195
|
+
*/
|
|
196
|
+
readonly maskedBody: string;
|
|
197
|
+
/** 1-based line of the marker. */
|
|
198
|
+
readonly line: number;
|
|
199
|
+
/** 1-based last line the item owns. */
|
|
200
|
+
readonly endLine: number;
|
|
201
|
+
/** How many list items enclose this one; a top-level item is `0`. */
|
|
202
|
+
readonly depth: number;
|
|
203
|
+
/** Columns before the marker, after any block-quote markers. */
|
|
204
|
+
readonly indent: number;
|
|
205
|
+
readonly quoteDepth: number;
|
|
206
|
+
}
|
|
207
|
+
export type LinkForm = 'inline' | 'reference' | 'shortcut' | 'autolink' | 'wiki' | 'definition';
|
|
208
|
+
export interface Link {
|
|
209
|
+
/**
|
|
210
|
+
* `[text](dest)`, `[text][label]` or `[label][]`, `[label]`, `<https://...>`,
|
|
211
|
+
* `[[target|text]]`, or a reference definition `[label]: dest`.
|
|
212
|
+
*/
|
|
213
|
+
readonly form: LinkForm;
|
|
214
|
+
/** Written with a leading `!`: an image, or an embed in the wiki form. */
|
|
215
|
+
readonly image: boolean;
|
|
216
|
+
/** The label as written, trimmed. Empty for an autolink; the label for a definition. */
|
|
217
|
+
readonly text: string;
|
|
218
|
+
/** The destination as written, without angle brackets. */
|
|
219
|
+
readonly target: string;
|
|
220
|
+
/** The reference label of the reference, shortcut and definition forms; `null` for the others. */
|
|
221
|
+
readonly label: string | null;
|
|
222
|
+
/** Offsets of the whole construct, a leading `!` included. */
|
|
223
|
+
readonly start: number;
|
|
224
|
+
readonly end: number;
|
|
225
|
+
/**
|
|
226
|
+
* Offsets of `target` as written. For the inline form and a definition they
|
|
227
|
+
* lie inside the construct, inside any angle brackets, so replacing them
|
|
228
|
+
* rewrites the destination. For the reference and shortcut forms they lie
|
|
229
|
+
* inside the definition: the use has no destination of its own, and the
|
|
230
|
+
* line a human edits to fix one is the definition.
|
|
231
|
+
*/
|
|
232
|
+
readonly targetStart: number;
|
|
233
|
+
readonly targetEnd: number;
|
|
234
|
+
/** 1-based line of `start`. */
|
|
235
|
+
readonly line: number;
|
|
236
|
+
}
|
|
237
|
+
export interface TableCell {
|
|
238
|
+
/** The cell as written, trimmed. */
|
|
239
|
+
readonly text: string;
|
|
240
|
+
/** Offsets of the trimmed text. */
|
|
241
|
+
readonly start: number;
|
|
242
|
+
readonly end: number;
|
|
243
|
+
}
|
|
244
|
+
export interface TableRow {
|
|
245
|
+
readonly cells: readonly TableCell[];
|
|
246
|
+
readonly start: number;
|
|
247
|
+
readonly end: number;
|
|
248
|
+
readonly line: number;
|
|
249
|
+
}
|
|
250
|
+
export interface Table {
|
|
251
|
+
/** Offset of the header line's content. */
|
|
252
|
+
readonly start: number;
|
|
253
|
+
/** Offset just past the last row, or past the delimiter row of a table with none. */
|
|
254
|
+
readonly end: number;
|
|
255
|
+
/** 1-based line of the header. */
|
|
256
|
+
readonly line: number;
|
|
257
|
+
/** 1-based last line. */
|
|
258
|
+
readonly endLine: number;
|
|
259
|
+
readonly headers: readonly TableCell[];
|
|
260
|
+
readonly rows: readonly TableRow[];
|
|
261
|
+
}
|
|
262
|
+
export interface MarkdownScan {
|
|
263
|
+
/** The scanned text: the input without a leading byte-order mark. */
|
|
264
|
+
readonly text: string;
|
|
265
|
+
/** Code units taken off the input before scanning: 1 for a byte-order mark, else 0. */
|
|
266
|
+
readonly bom: number;
|
|
267
|
+
readonly index: LineIndex;
|
|
268
|
+
/** One record per line of `index`, front matter included. */
|
|
269
|
+
readonly lines: readonly ScannedLine[];
|
|
270
|
+
readonly frontMatter: FrontMatterBlock | null;
|
|
271
|
+
/** Offset where the body starts, after any front matter. */
|
|
272
|
+
readonly bodyStart: number;
|
|
273
|
+
/** Code blocks and raw-text HTML blocks, in order. */
|
|
274
|
+
readonly blocks: readonly Block[];
|
|
275
|
+
/** Code spans, backticks included, in order. */
|
|
276
|
+
readonly codeSpans: readonly Range[];
|
|
277
|
+
readonly comments: readonly HtmlComment[];
|
|
278
|
+
readonly masks: Masks;
|
|
279
|
+
/** ATX and setext headings, in order. */
|
|
280
|
+
readonly headings: readonly Heading[];
|
|
281
|
+
readonly listItems: readonly ListItem[];
|
|
282
|
+
/** Links, images and definitions, in order of `start`. */
|
|
283
|
+
readonly links: readonly Link[];
|
|
284
|
+
readonly tables: readonly Table[];
|
|
285
|
+
/** Whether an offset is blanked in a mask, the structure mask unless another is named. */
|
|
286
|
+
isMasked(offset: number, mask?: MaskKind): boolean;
|
|
287
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes a scan produces.
|
|
3
|
+
*
|
|
4
|
+
* Every structure carries absolute UTF-16 offsets into the scanned text - the
|
|
5
|
+
* text after any byte-order mark - and a 1-based line. Nothing holds a copy of
|
|
6
|
+
* the document that a rule could match against and then report somewhere else.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * The shapes a scan produces.\n *\n * Every structure carries absolute UTF-16 offsets into the scanned text - the\n * text after any byte-order mark - and a 1-based line. Nothing holds a copy of\n * the document that a rule could match against and then report somewhere else.\n */\n\nimport type { LineIndex, Range } from '../text/index.js';\n\n/** The three masked copies of a document; see {@link Masks}. */\nexport type MaskKind = 'structure' | 'prose' | 'directives';\n\n/**\n * Copies of the text with some constructs blanked to spaces.\n *\n * Every copy has the length of the text and its line terminators at the same\n * offsets, so a match at an offset of a mask is at that offset of the text, on\n * the same line and in the same column.\n */\nexport interface Masks {\n /**\n * Front matter, block code, raw-text HTML, code spans and comments blanked:\n * what counts as structure. Headings, list items, links and tables are read\n * from this copy.\n */\n readonly structure: string;\n /**\n * Front matter and comments blanked, code kept: what counts as content. A\n * section holding only a template hint in a comment is empty; one holding\n * only a code sample is not.\n */\n readonly prose: string;\n /**\n * Front matter, block code, raw-text HTML and code spans blanked, comments\n * kept: where a directive written in a comment is read, so that one shown in\n * a code sample is not.\n */\n readonly directives: string;\n}\n\nexport type FrontMatterKind = 'yaml' | 'toml';\n\n/** The metadata block at the top of a document. */\nexport interface FrontMatterBlock {\n /** YAML between `---` lines, closed by `---` or `...`; TOML between `+++` lines. */\n readonly kind: FrontMatterKind;\n /** The text between the delimiter lines. */\n readonly raw: string;\n /** Offset of the first character of `raw`. */\n readonly start: number;\n /** Offset just past `raw`: the start of the closing delimiter line. */\n readonly end: number;\n /** Offset just past the closing delimiter line and its terminator. */\n readonly bodyStart: number;\n /** 1-based line of the closing delimiter. */\n readonly closeLine: number;\n}\n\n/**\n * One line of the document. Every line has one, front matter included, so the\n * record for line `n` is at index `n - 1`.\n */\nexport interface ScannedLine {\n /** 1-based. */\n readonly line: number;\n /** Offset of the line's first character. */\n readonly start: number;\n /** Offset just past the line, before its terminator. */\n readonly end: number;\n /**\n * Offset of the first character after the block-quote markers. In a fenced\n * block only the markers of the quote holding the fence are taken off: a `>`\n * written inside the code is code.\n */\n readonly contentStart: number;\n /** The line from `contentStart`, indentation intact. */\n readonly content: string;\n /** Indentation of `content` in columns, a tab reaching the next multiple of four. */\n readonly indent: number;\n /** `content` is empty or whitespace. */\n readonly blank: boolean;\n readonly quoteDepth: number;\n /** Part of the front matter, delimiters included. */\n readonly frontMatter: boolean;\n /** Part of a fenced or indented code block, fences included. */\n readonly code: boolean;\n /** Part of a `<script>`, `<pre>`, `<style>` or `<textarea>` block. */\n readonly html: boolean;\n /**\n * The line's first non-blank character is inside an HTML comment. What is\n * written there is not Markdown, whatever it looks like. Never set on a blank\n * line.\n */\n readonly comment: boolean;\n}\n\nexport type BlockKind = 'fenced' | 'indented' | 'html';\n\n/** A block whose content is not Markdown: code, or raw-text HTML. */\nexport interface Block {\n readonly kind: BlockKind;\n /** Offset of the first line's first character. */\n readonly start: number;\n /** Offset just past the last line, before its terminator. */\n readonly end: number;\n /** 1-based first line: the opening fence or tag, or the first code line. */\n readonly line: number;\n /** 1-based last line. */\n readonly endLine: number;\n /** A fenced block's info string, trimmed; empty for the other kinds. */\n readonly info: string;\n /**\n * Whether a closing fence or closing tag ended the block. One that runs to\n * the end of the document or of its block quote is not closed. An indented\n * block always is.\n */\n readonly closed: boolean;\n}\n\nexport interface HtmlComment {\n /** Offset of `<!--`. */\n readonly start: number;\n /** Offset just past `-->`, or the end of the text for one never closed. */\n readonly end: number;\n /** The text between `<!--` and `-->`. */\n readonly inner: string;\n readonly innerStart: number;\n /** 1-based line of `<!--`. */\n readonly line: number;\n /**\n * False for a comment that opens a line and is never closed, which runs to\n * the end of the document as CommonMark's HTML block does. A `<!--` in the\n * middle of a line with no `-->` after it is text, and is not a comment.\n */\n readonly closed: boolean;\n}\n\nexport type HeadingForm = 'atx' | 'setext';\n\nexport interface Heading {\n readonly form: HeadingForm;\n readonly level: number;\n /**\n * The text a reader sees: trimmed, without an ATX closing sequence, and\n * without any comment in it. Code spans are kept as written.\n */\n readonly text: string;\n /** GitHub's slug of `text`. */\n readonly slug: string;\n /**\n * The anchor GitHub gives the heading: its slug, with `-1`, `-2` and so on\n * appended for the second and later headings that slug the same.\n */\n readonly anchor: string;\n /** Offset of the heading line's content, after any block-quote markers. */\n readonly start: number;\n /** Offset just past the heading line, or past a setext heading's underline. */\n readonly end: number;\n /** Offsets of `text` as written; a comment inside it is between them. */\n readonly textStart: number;\n readonly textEnd: number;\n /** 1-based line of the heading text. */\n readonly line: number;\n /** 1-based last line: the underline of a setext heading. */\n readonly endLine: number;\n}\n\n/** A heading and everything under it up to the next heading at its level or above. */\nexport interface Section {\n readonly heading: Heading;\n /** Offset of the heading line's first character. */\n readonly start: number;\n /** Offset of the line after the heading. */\n readonly bodyStart: number;\n /** Offset of the first line of the next heading at this level or above, or the end of the text. */\n readonly end: number;\n /** 1-based line after the section: that heading's line, or one past the last line. */\n readonly endLine: number;\n}\n\nexport interface ListItem {\n /** Offset of the marker line's content, after any block-quote markers. */\n readonly start: number;\n /** Offset just past the item's last line: continuations and nested content included. */\n readonly end: number;\n /** Offset of the marker. */\n readonly markerStart: number;\n /** `-`, `*`, `+`, or a number followed by `.` or `)`. */\n readonly marker: string;\n /** Offset of the item's text, after the marker and any checkbox. */\n readonly textStart: number;\n /**\n * The character inside a task checkbox, or `null` without one. GFM's are\n * space, `x` and `X`; `~ - ? ! * / +` are read too, and what each means is\n * the caller's decision.\n */\n readonly checkbox: string | null;\n /** Offset of the checkbox's `[`. */\n readonly checkboxStart: number | null;\n /** The text of the marker line, trimmed. */\n readonly firstLine: string;\n /** Everything from `textStart` to `end`. */\n readonly body: string;\n /**\n * `body` read from the structure mask. Anything that searches item text for\n * meaning reads this, or a fenced example nested under the item speaks for it.\n */\n readonly maskedBody: string;\n /** 1-based line of the marker. */\n readonly line: number;\n /** 1-based last line the item owns. */\n readonly endLine: number;\n /** How many list items enclose this one; a top-level item is `0`. */\n readonly depth: number;\n /** Columns before the marker, after any block-quote markers. */\n readonly indent: number;\n readonly quoteDepth: number;\n}\n\nexport type LinkForm = 'inline' | 'reference' | 'shortcut' | 'autolink' | 'wiki' | 'definition';\n\nexport interface Link {\n /**\n * `[text](dest)`, `[text][label]` or `[label][]`, `[label]`, `<https://...>`,\n * `[[target|text]]`, or a reference definition `[label]: dest`.\n */\n readonly form: LinkForm;\n /** Written with a leading `!`: an image, or an embed in the wiki form. */\n readonly image: boolean;\n /** The label as written, trimmed. Empty for an autolink; the label for a definition. */\n readonly text: string;\n /** The destination as written, without angle brackets. */\n readonly target: string;\n /** The reference label of the reference, shortcut and definition forms; `null` for the others. */\n readonly label: string | null;\n /** Offsets of the whole construct, a leading `!` included. */\n readonly start: number;\n readonly end: number;\n /**\n * Offsets of `target` as written. For the inline form and a definition they\n * lie inside the construct, inside any angle brackets, so replacing them\n * rewrites the destination. For the reference and shortcut forms they lie\n * inside the definition: the use has no destination of its own, and the\n * line a human edits to fix one is the definition.\n */\n readonly targetStart: number;\n readonly targetEnd: number;\n /** 1-based line of `start`. */\n readonly line: number;\n}\n\nexport interface TableCell {\n /** The cell as written, trimmed. */\n readonly text: string;\n /** Offsets of the trimmed text. */\n readonly start: number;\n readonly end: number;\n}\n\nexport interface TableRow {\n readonly cells: readonly TableCell[];\n readonly start: number;\n readonly end: number;\n readonly line: number;\n}\n\nexport interface Table {\n /** Offset of the header line's content. */\n readonly start: number;\n /** Offset just past the last row, or past the delimiter row of a table with none. */\n readonly end: number;\n /** 1-based line of the header. */\n readonly line: number;\n /** 1-based last line. */\n readonly endLine: number;\n readonly headers: readonly TableCell[];\n readonly rows: readonly TableRow[];\n}\n\nexport interface MarkdownScan {\n /** The scanned text: the input without a leading byte-order mark. */\n readonly text: string;\n /** Code units taken off the input before scanning: 1 for a byte-order mark, else 0. */\n readonly bom: number;\n readonly index: LineIndex;\n /** One record per line of `index`, front matter included. */\n readonly lines: readonly ScannedLine[];\n readonly frontMatter: FrontMatterBlock | null;\n /** Offset where the body starts, after any front matter. */\n readonly bodyStart: number;\n /** Code blocks and raw-text HTML blocks, in order. */\n readonly blocks: readonly Block[];\n /** Code spans, backticks included, in order. */\n readonly codeSpans: readonly Range[];\n readonly comments: readonly HtmlComment[];\n readonly masks: Masks;\n /** ATX and setext headings, in order. */\n readonly headings: readonly Heading[];\n readonly listItems: readonly ListItem[];\n /** Links, images and definitions, in order of `start`. */\n readonly links: readonly Link[];\n readonly tables: readonly Table[];\n /** Whether an offset is blanked in a mask, the structure mask unless another is named. */\n isMasked(offset: number, mask?: MaskKind): boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { basename, dirname, extname, isAbsolutePath, isInside, isRelativeReference, joinPosix, normalise, normalisePosix, relativePath, resolveInside, segments, splitReference, toPosix, } from './posix.js';
|