@nielspeter/eess-md 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/README.md +3 -1
- package/dist/builders/declaration-findings.d.ts +37 -0
- package/dist/builders/declaration-findings.d.ts.map +1 -0
- package/dist/builders/declaration-findings.js +128 -0
- package/dist/builders/declaration-findings.js.map +1 -0
- package/dist/builders/links.d.ts +60 -1
- package/dist/builders/links.d.ts.map +1 -1
- package/dist/builders/links.js +92 -1
- package/dist/builders/links.js.map +1 -1
- package/dist/conditions/linked-back.d.ts +17 -0
- package/dist/conditions/linked-back.d.ts.map +1 -0
- package/dist/conditions/linked-back.js +122 -0
- package/dist/conditions/linked-back.js.map +1 -0
- package/dist/conditions/resolve.d.ts +8 -40
- package/dist/conditions/resolve.d.ts.map +1 -1
- package/dist/conditions/resolve.js +26 -138
- package/dist/conditions/resolve.js.map +1 -1
- package/dist/corpus.d.ts +3 -0
- package/dist/corpus.d.ts.map +1 -1
- package/dist/corpus.js +7 -10
- package/dist/corpus.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/model/document.d.ts +8 -1
- package/dist/model/document.d.ts.map +1 -1
- package/dist/model/document.js +14 -3
- package/dist/model/document.js.map +1 -1
- package/dist/model/label.d.ts +35 -0
- package/dist/model/label.d.ts.map +1 -0
- package/dist/model/label.js +68 -0
- package/dist/model/label.js.map +1 -0
- package/dist/model/links.d.ts +43 -0
- package/dist/model/links.d.ts.map +1 -1
- package/dist/model/links.js +112 -11
- package/dist/model/links.js.map +1 -1
- package/dist/model/prose.d.ts +11 -0
- package/dist/model/prose.d.ts.map +1 -1
- package/dist/model/prose.js +50 -5
- package/dist/model/prose.js.map +1 -1
- package/dist/model/query.d.ts +7 -0
- package/dist/model/query.d.ts.map +1 -1
- package/dist/model/query.js +10 -3
- package/dist/model/query.js.map +1 -1
- package/dist/model/resolve-link.d.ts +142 -0
- package/dist/model/resolve-link.d.ts.map +1 -0
- package/dist/model/resolve-link.js +194 -0
- package/dist/model/resolve-link.js.map +1 -0
- package/dist/predicates/declared-block.d.ts +29 -0
- package/dist/predicates/declared-block.d.ts.map +1 -0
- package/dist/predicates/declared-block.js +47 -0
- package/dist/predicates/declared-block.js.map +1 -0
- package/dist/predicates/live-target.d.ts +12 -0
- package/dist/predicates/live-target.d.ts.map +1 -0
- package/dist/predicates/live-target.js +17 -0
- package/dist/predicates/live-target.js.map +1 -0
- package/dist/rules/adr.d.ts +14 -5
- package/dist/rules/adr.d.ts.map +1 -1
- package/dist/rules/adr.js +5 -27
- package/dist/rules/adr.js.map +1 -1
- package/dist/rules/ledger.d.ts +10 -6
- package/dist/rules/ledger.d.ts.map +1 -1
- package/dist/rules/ledger.js +80 -24
- package/dist/rules/ledger.js.map +1 -1
- package/package.json +6 -3
|
@@ -1,125 +1,45 @@
|
|
|
1
|
-
import { posix } from 'node:path';
|
|
2
1
|
import { mdViolation } from '../model/violation.js';
|
|
3
|
-
|
|
4
|
-
* Resolve an internal link's URL to its base repo-relative target(s), or `[]`
|
|
5
|
-
* if it is a pure fragment (`#anchor`) or otherwise not a file reference.
|
|
6
|
-
* Site-absolute links (leading `/`) yield the repo-root target plus, when
|
|
7
|
-
* `rootDir` is set, the content-root target.
|
|
8
|
-
*/
|
|
9
|
-
function resolveTargets(link, options) {
|
|
10
|
-
const withoutFragment = link.url.split('#')[0] ?? '';
|
|
11
|
-
if (withoutFragment === '')
|
|
12
|
-
return []; // same-document anchor
|
|
13
|
-
const decoded = decodeURIComponent(withoutFragment);
|
|
14
|
-
if (decoded.startsWith('/')) {
|
|
15
|
-
const repoRooted = posix.normalize(decoded.replace(/^\/+/, ''));
|
|
16
|
-
return options.rootDir !== undefined
|
|
17
|
-
? [repoRooted, posix.normalize(posix.join(options.rootDir, repoRooted))]
|
|
18
|
-
: [repoRooted];
|
|
19
|
-
}
|
|
20
|
-
const base = posix.dirname(link.doc.relPath);
|
|
21
|
-
return [posix.normalize(posix.join(base, decoded))];
|
|
22
|
-
}
|
|
23
|
-
/** All repo-relative candidates for a target under the given options. */
|
|
24
|
-
function candidates(target, options) {
|
|
25
|
-
const out = [target];
|
|
26
|
-
const bare = target.replace(/\/+$/, '');
|
|
27
|
-
for (const ext of options.tryExtensions ?? []) {
|
|
28
|
-
out.push(bare + ext);
|
|
29
|
-
}
|
|
30
|
-
if (options.tryIndex !== undefined) {
|
|
31
|
-
out.push(posix.join(bare, options.tryIndex));
|
|
32
|
-
}
|
|
33
|
-
return out;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Every known directory reachable from `fileIndex`'s files, derived from it
|
|
37
|
-
* rather than new I/O: each indexed file's ancestors are known directories.
|
|
38
|
-
* `fileIndex` itself spans the whole physical repo walk from `cwd`, not just
|
|
39
|
-
* the corpus's configured `roots` (`roots` only filters which files become
|
|
40
|
-
* *documents* — see `corpus()`), so a directory link can resolve against
|
|
41
|
-
* something outside any configured root. Built only when `resolveDirectories`
|
|
42
|
-
* is on — the cost of a directory-shaped link resolving is opt-in, so is the
|
|
43
|
-
* cost of computing it.
|
|
44
|
-
*
|
|
45
|
-
* The repo root itself (`.`) is deliberately excluded — `[root](/)` still
|
|
46
|
-
* won't resolve even with the option on. Nobody links "the whole repo," and
|
|
47
|
-
* `resolveTargets` never had a resolvable shape for it before this option
|
|
48
|
-
* existed either.
|
|
49
|
-
*/
|
|
50
|
-
function directoryIndex(corpus) {
|
|
51
|
-
const dirs = new Set();
|
|
52
|
-
for (const rel of corpus.fileIndex) {
|
|
53
|
-
let dir = posix.dirname(rel);
|
|
54
|
-
while (dir !== '.' && dir !== '/' && !dirs.has(dir)) {
|
|
55
|
-
dirs.add(dir);
|
|
56
|
-
dir = posix.dirname(dir);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return dirs;
|
|
60
|
-
}
|
|
2
|
+
import { basenameIndex, linkTargets, movedLinkFix, resolveLink, } from '../model/resolve-link.js';
|
|
61
3
|
/**
|
|
62
4
|
* Condition: every (internal) link resolves to a file in the corpus's repo tree.
|
|
63
5
|
* Closes over the `Corpus` for the file index. External links and pure anchors
|
|
64
6
|
* are skipped. `options` adds extensionless-link resolution (`tryExtensions`,
|
|
65
7
|
* `tryIndex`) for static-site corpora, and directory resolution
|
|
66
8
|
* (`resolveDirectories`) for repo-hosted ones.
|
|
9
|
+
*
|
|
10
|
+
* Resolution is `resolveLink`'s (plan 0404): this condition only decides which
|
|
11
|
+
* of its cases count as resolved — a loaded document, an existing file outside
|
|
12
|
+
* the corpus, and (with `resolveDirectories`) a directory.
|
|
67
13
|
*/
|
|
68
14
|
export function linkResolves(corpus, options = {}) {
|
|
69
15
|
// Basename → repo files, for finding a uniquely-moved target of a broken link.
|
|
70
|
-
const byBasename =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// unconditionally alongside `dirIndex`, so the happy path (no violations)
|
|
85
|
-
// never pays for it, and only when `resolveDirectories` is already off —
|
|
86
|
-
// when it's on, a real directory already resolved above and can't reach
|
|
87
|
-
// this branch at all.
|
|
88
|
-
//
|
|
89
|
-
// A site-absolute link with `rootDir` set yields two candidates
|
|
90
|
-
// (repo-root, then content-root — see `resolveTargets`), and either can
|
|
91
|
-
// independently be a real directory. Reporting whichever comes first
|
|
92
|
-
// unlabelled can name the *wrong* one: a repo-root directory that happens
|
|
93
|
-
// to share a name with the intended content-root page sends the author to
|
|
94
|
-
// toggle `resolveDirectories`, which would resolve the unrelated
|
|
95
|
-
// repo-root directory, not fix their actual (still-missing) page. Labelled
|
|
96
|
-
// only when there are two candidates to disambiguate between — the common,
|
|
97
|
-
// single-target case (no `rootDir`) is unaffected.
|
|
98
|
-
let diagnosticDirIndex;
|
|
99
|
-
const directoryHint = (target, label) => {
|
|
100
|
-
diagnosticDirIndex ??= directoryIndex(corpus);
|
|
101
|
-
const bare = target.replace(/\/+$/, '');
|
|
102
|
-
return diagnosticDirIndex.has(bare)
|
|
103
|
-
? ` — "${bare}"${label} is a real directory; this check runs with resolveDirectories off`
|
|
104
|
-
: '';
|
|
16
|
+
const byBasename = basenameIndex(corpus);
|
|
17
|
+
// Bug 0137: a link that names a real directory and one that names nothing at
|
|
18
|
+
// all both reported the identical "does not resolve" message — no hint that
|
|
19
|
+
// `resolveDirectories` exists, or that this specific target would resolve
|
|
20
|
+
// with it on. A site-absolute link with `rootDir` set has two candidates
|
|
21
|
+
// (repo-root, then content-root), and either can be a real directory.
|
|
22
|
+
// Reporting it unlabelled could name the *wrong* one: a repo-root directory
|
|
23
|
+
// sharing a name with the intended content-root page would send the author
|
|
24
|
+
// to toggle `resolveDirectories`, which resolves the unrelated directory, not
|
|
25
|
+
// their missing page. Labelled only when there are two candidates.
|
|
26
|
+
const directoryHint = (link, path) => {
|
|
27
|
+
const targets = linkTargets(link, options).map((t) => t.replace(/\/+$/, ''));
|
|
28
|
+
const label = targets.length > 1 ? (targets.indexOf(path) === 0 ? ' (repo-root)' : ' (content-root)') : '';
|
|
29
|
+
return ` — "${path}"${label} is a real directory; this check runs with resolveDirectories off`;
|
|
105
30
|
};
|
|
106
31
|
return {
|
|
107
32
|
description: 'resolve to an existing file',
|
|
108
33
|
evaluate: (links, ctx) => links.flatMap((link) => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
34
|
+
const target = resolveLink(link, corpus, options);
|
|
35
|
+
if (target.kind === 'external' ||
|
|
36
|
+
target.kind === 'self' ||
|
|
37
|
+
target.kind === 'document' ||
|
|
38
|
+
target.kind === 'not-in-corpus')
|
|
113
39
|
return [];
|
|
114
|
-
if (
|
|
40
|
+
if (target.kind === 'directory' && options.resolveDirectories === true)
|
|
115
41
|
return [];
|
|
116
|
-
|
|
117
|
-
return [];
|
|
118
|
-
const hint = options.resolveDirectories === true
|
|
119
|
-
? ''
|
|
120
|
-
: (targets
|
|
121
|
-
.map((t, i) => directoryHint(t, targets.length > 1 ? (i === 0 ? ' (repo-root)' : ' (content-root)') : ''))
|
|
122
|
-
.find((h) => h) ?? '');
|
|
42
|
+
const hint = target.kind === 'directory' ? directoryHint(link, target.path) : '';
|
|
123
43
|
return [
|
|
124
44
|
mdViolation({
|
|
125
45
|
element: `${link.doc.relPath} → ${link.url}`,
|
|
@@ -134,36 +54,4 @@ export function linkResolves(corpus, options = {}) {
|
|
|
134
54
|
}),
|
|
135
55
|
};
|
|
136
56
|
}
|
|
137
|
-
/**
|
|
138
|
-
* If a broken link's basename uniquely names one file in the repo (the target
|
|
139
|
-
* moved, not renamed), emit a deterministic autofix rewriting the URL to a path
|
|
140
|
-
* relative to the linking document (plan 0066). Ambiguous basename, or a URL
|
|
141
|
-
* whose exact span isn't known, → no fix.
|
|
142
|
-
*/
|
|
143
|
-
function movedLinkFix(link, byBasename) {
|
|
144
|
-
if (link.urlStart === undefined || link.urlEnd === undefined)
|
|
145
|
-
return undefined;
|
|
146
|
-
const path = link.url.split('#')[0] ?? '';
|
|
147
|
-
const fragment = link.url.slice(path.length); // '' or '#anchor'
|
|
148
|
-
const base = path.slice(path.replace(/\/+$/, '').lastIndexOf('/') + 1);
|
|
149
|
-
const matches = byBasename.get(base) ?? [];
|
|
150
|
-
if (matches.length !== 1)
|
|
151
|
-
return undefined; // renamed (no match) or ambiguous → no fix
|
|
152
|
-
const target = matches[0];
|
|
153
|
-
if (target === undefined)
|
|
154
|
-
return undefined;
|
|
155
|
-
let rel = posix.relative(posix.dirname(link.doc.relPath), target);
|
|
156
|
-
if (!rel.startsWith('.'))
|
|
157
|
-
rel = './' + rel;
|
|
158
|
-
const replacement = rel + fragment;
|
|
159
|
-
if (replacement === link.url)
|
|
160
|
-
return undefined;
|
|
161
|
-
return {
|
|
162
|
-
file: link.doc.file,
|
|
163
|
-
start: link.urlStart,
|
|
164
|
-
end: link.urlEnd,
|
|
165
|
-
replacement,
|
|
166
|
-
describe: `rewrite link "${link.url}" → "${replacement}"`,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
57
|
//# sourceMappingURL=resolve.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/conditions/resolve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/conditions/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,EACZ,WAAW,GAEZ,MAAM,0BAA0B,CAAA;AASjC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,UAA8B,EAAE;IAC3E,+EAA+E;IAC/E,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IAExC,6EAA6E;IAC7E,4EAA4E;IAC5E,0EAA0E;IAC1E,yEAAyE;IACzE,sEAAsE;IACtE,4EAA4E;IAC5E,2EAA2E;IAC3E,8EAA8E;IAC9E,mEAAmE;IACnE,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,IAAY,EAAU,EAAE;QAC3D,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAA;QAC5E,MAAM,KAAK,GACT,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QAC9F,OAAO,OAAO,IAAI,IA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|
13
13
|
* false (bug 0253): a frozen document's LINKS are still checked, and its code
|
|
14
14
|
* pointers are excluded from `pointers().areLive()` — so they are not examined
|
|
15
15
|
* at all. They are not "reported but never failed"; nothing reports them.
|
|
16
|
+
* A frozen record also cannot answer a declared relation: `links().haveLiveTargets()`
|
|
17
|
+
* drops a link into one, and `beLinkedBack()` reports it as frozen without it
|
|
18
|
+
* (plan 0406).
|
|
16
19
|
*
|
|
17
20
|
* Defaults to the near-universal `completed`/`archived`; extend for your
|
|
18
21
|
* project's lifecycle folders (`delivered`, `wont-do`, …).
|
package/dist/corpus.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../src/corpus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../src/corpus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAIpE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,qFAAqF;IACrF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,4BAA4B;IAC5B,SAAS,IAAI,UAAU,EAAE,CAAA;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,gGAAgG;IAChG,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACxC;AAKD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAsCrD"}
|
package/dist/corpus.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { walkFiles } from '@nielspeter/eess/internal';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { fromMarkdown } from 'mdast-util-from-markdown';
|
|
5
|
-
import { gfm } from 'micromark-extension-gfm';
|
|
6
|
-
import { gfmFromMarkdown } from 'mdast-util-gfm';
|
|
7
4
|
import picomatch from 'picomatch';
|
|
8
5
|
import { buildDocument } from './model/document.js';
|
|
6
|
+
import { parseMarkdown } from './model/prose.js';
|
|
7
|
+
import { registerCorpusMatchers } from './model/resolve-link.js';
|
|
9
8
|
const DEFAULT_FROZEN = ['**/completed/**', '**/archived/**'];
|
|
10
9
|
const BUILTIN_IGNORE = ['node_modules', '.git', 'dist', 'coverage', '.output', '.nuxt', '.vercel'];
|
|
11
10
|
/**
|
|
@@ -23,17 +22,12 @@ export function corpus(options) {
|
|
|
23
22
|
const matchesFrozen = picomatch([...(options.frozen ?? DEFAULT_FROZEN)]);
|
|
24
23
|
const matchesIgnore = options.ignore && options.ignore.length > 0 ? picomatch([...options.ignore]) : () => false;
|
|
25
24
|
const fileIndex = new Set(allFiles);
|
|
26
|
-
const gfmExt = gfm();
|
|
27
|
-
const gfmMdast = gfmFromMarkdown();
|
|
28
25
|
const documents = allFiles
|
|
29
26
|
.filter((rel) => rel.endsWith('.md') && matchesRoot(rel) && !matchesIgnore(rel))
|
|
30
27
|
.map((rel) => {
|
|
31
28
|
const abs = join(root, rel);
|
|
32
29
|
const text = readFileSync(abs, 'utf8');
|
|
33
|
-
const tree =
|
|
34
|
-
extensions: [gfmExt],
|
|
35
|
-
mdastExtensions: [gfmMdast],
|
|
36
|
-
});
|
|
30
|
+
const tree = parseMarkdown(text);
|
|
37
31
|
return buildDocument({
|
|
38
32
|
file: abs,
|
|
39
33
|
relPath: rel,
|
|
@@ -42,10 +36,13 @@ export function corpus(options) {
|
|
|
42
36
|
root: tree,
|
|
43
37
|
});
|
|
44
38
|
});
|
|
45
|
-
|
|
39
|
+
const loaded = {
|
|
46
40
|
documents: () => documents,
|
|
47
41
|
root,
|
|
48
42
|
fileIndex,
|
|
49
43
|
};
|
|
44
|
+
// Kept so `resolveLink` can say why an existing file was not loaded (plan 0404).
|
|
45
|
+
registerCorpusMatchers(loaded, { inRoots: matchesRoot, ignored: matchesIgnore });
|
|
46
|
+
return loaded;
|
|
50
47
|
}
|
|
51
48
|
//# sourceMappingURL=corpus.js.map
|
package/dist/corpus.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corpus.js","sourceRoot":"","sources":["../src/corpus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"corpus.js","sourceRoot":"","sources":["../src/corpus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,aAAa,EAAmB,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AA8ChE,MAAM,cAAc,GAAG,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAA;AAC5D,MAAM,cAAc,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AAEl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AAI,CAAC,CAAA;QAChC,OAAO,aAAa,CAAC;YACnB,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,GAAG;YACZ,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC;YAC1B,IAAI;YACJ,IAAI,EAAE,IAAI;SACX,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEJ,MAAM,MAAM,GAAW;QACrB,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;QAC1B,IAAI;QACJ,SAAS;KACV,CAAA;IACD,iFAAiF;IACjF,sBAAsB,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAA;IAChF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { corpus } from './corpus.js';
|
|
2
2
|
export type { CorpusOptions, Corpus } from './corpus.js';
|
|
3
3
|
export type { Predicate, Condition, ConditionContext, ArchFix, PresetReportOptions, PresetBaseOptions, } from '@nielspeter/eess';
|
|
4
|
-
export { RuleBuilder, finishPreset, generateCodeFrame, not, dispatchRule, validateOverrides, reportViolations, isArchConfigError, } from '@nielspeter/eess';
|
|
4
|
+
export { RuleBuilder, finishPreset, generateCodeFrame, not, dispatchRule, validateOverrides, reportViolations, isArchConfigError, ArchConfigError, } from '@nielspeter/eess';
|
|
5
5
|
export { correspondence, CorrespondenceBuilder } from '@nielspeter/eess';
|
|
6
6
|
export { collectResult, mergeCollectResults, hasEvidence } from '@nielspeter/eess';
|
|
7
7
|
export type { CollectResult } from '@nielspeter/eess';
|
|
@@ -13,7 +13,10 @@ export type { ArchViolation } from './model/violation.js';
|
|
|
13
13
|
export { docs, DocsRuleBuilder } from './builders/docs.js';
|
|
14
14
|
export { links, LinkRuleBuilder } from './builders/links.js';
|
|
15
15
|
export type { MdLink } from './builders/links.js';
|
|
16
|
+
export type { MdLinkBlock } from './model/links.js';
|
|
16
17
|
export type { LinkResolveOptions } from './conditions/resolve.js';
|
|
18
|
+
export { resolveLink } from './model/resolve-link.js';
|
|
19
|
+
export type { LinkTarget, LinkToResolve, NotInCorpusReason } from './model/resolve-link.js';
|
|
17
20
|
export { pointers, PointerRuleBuilder } from './builders/pointers.js';
|
|
18
21
|
export type { MdPointer } from './builders/pointers.js';
|
|
19
22
|
export { presentExternalRoots } from './conditions/pointer-resolve.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAOxD,YAAY,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,GAAG,EACH,YAAY,EACZ,iBAAiB,EAMjB,gBAAgB,EAChB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAOxD,YAAY,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,GAAG,EACH,YAAY,EACZ,iBAAiB,EAMjB,gBAAgB,EAChB,iBAAiB,EAEjB,eAAe,GAChB,MAAM,kBAAkB,CAAA;AASzB,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAOx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0B,CAAA;AACzE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC7E,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGnG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACpE,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,9 @@ export { RuleBuilder, finishPreset, generateCodeFrame, not, dispatchRule, valida
|
|
|
12
12
|
// without throwing nor catch what the seam throws. ADR-008 names
|
|
13
13
|
// `reportViolations` as the one emitter, and ADR-014's configuration findings
|
|
14
14
|
// arrive as an `ArchConfigError` a caller has to recognise.
|
|
15
|
-
reportViolations, isArchConfigError,
|
|
15
|
+
reportViolations, isArchConfigError,
|
|
16
|
+
// Bug 0284: `honestyAtClose` throws it for a half-declared vocabulary.
|
|
17
|
+
ArchConfigError, } from '@nielspeter/eess';
|
|
16
18
|
// `correspondence`/`CorrespondenceBuilder`: not touched by this package's
|
|
17
19
|
// OWN source (so the family.rules.ts code-import scan can't see this gap —
|
|
18
20
|
// review found it manually), but this README's own "Binding a spec table to
|
|
@@ -33,6 +35,7 @@ export { matchTableRows } from './model/rows.js';
|
|
|
33
35
|
// Entry points
|
|
34
36
|
export { docs, DocsRuleBuilder } from './builders/docs.js';
|
|
35
37
|
export { links, LinkRuleBuilder } from './builders/links.js';
|
|
38
|
+
export { resolveLink } from './model/resolve-link.js';
|
|
36
39
|
export { pointers, PointerRuleBuilder } from './builders/pointers.js';
|
|
37
40
|
export { presentExternalRoots } from './conditions/pointer-resolve.js';
|
|
38
41
|
export { rows, RowsRuleBuilder } from './builders/rows.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,gFAAgF;AAChF,wCAAwC;AAExC,gBAAgB;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAgBpC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,GAAG,EACH,YAAY,EACZ,iBAAiB;AACjB,4EAA4E;AAC5E,yEAAyE;AACzE,iEAAiE;AACjE,8EAA8E;AAC9E,4DAA4D;AAC5D,gBAAgB,EAChB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,gFAAgF;AAChF,wCAAwC;AAExC,gBAAgB;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAgBpC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,GAAG,EACH,YAAY,EACZ,iBAAiB;AACjB,4EAA4E;AAC5E,yEAAyE;AACzE,iEAAiE;AACjE,8EAA8E;AAC9E,4DAA4D;AAC5D,gBAAgB,EAChB,iBAAiB;AACjB,uEAAuE;AACvE,eAAe,GAChB,MAAM,kBAAkB,CAAA;AACzB,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,+DAA+D;AAC/D,6EAA6E;AAC7E,qEAAqE;AACrE,2EAA2E;AAC3E,wBAAwB;AACxB,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxE,6EAA6E;AAC7E,gFAAgF;AAChF,EAAE;AACF,8EAA8E;AAC9E,iFAAiF;AACjF,oEAAoE;AACpE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAYlF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGhD,eAAe;AACf,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAI5D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAErE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAEtE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG7E,oDAAoD;AACpD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA"}
|
package/dist/model/document.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Root } from 'mdast';
|
|
1
|
+
import type { Root, RootContent } from 'mdast';
|
|
2
2
|
/**
|
|
3
3
|
* A heading in a markdown document.
|
|
4
4
|
*/
|
|
@@ -61,6 +61,13 @@ export interface MdDocument {
|
|
|
61
61
|
/** mdast root (internal / advanced) */
|
|
62
62
|
readonly root: Root;
|
|
63
63
|
}
|
|
64
|
+
/** A heading's name as `sections` records it — shared so links and tables agree on section names. */
|
|
65
|
+
export declare function headingName(node: RootContent): string;
|
|
66
|
+
/**
|
|
67
|
+
* Move a running heading stack (index i is the current heading at depth i+1) past one heading.
|
|
68
|
+
* Shared by `buildDocument` (tables) and `collectLinks` (links), so both read one section path.
|
|
69
|
+
*/
|
|
70
|
+
export declare function enterHeading(stack: string[], depth: number, name: string): void;
|
|
64
71
|
/**
|
|
65
72
|
* Build an `MdDocument` from a parsed mdast `Root`.
|
|
66
73
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/model/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/model/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAE9C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAA;IAC7C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,iFAAiF;IACjF,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CACxC;AAED,kDAA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node) {
|
|
|
14
14
|
}
|
|
15
15
|
return '';
|
|
16
16
|
}
|
|
17
|
+
/** A heading's name as `sections` records it — shared so links and tables agree on section names. */
|
|
18
|
+
export function headingName(node) {
|
|
19
|
+
return nodeText(node).trim();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Move a running heading stack (index i is the current heading at depth i+1) past one heading.
|
|
23
|
+
* Shared by `buildDocument` (tables) and `collectLinks` (links), so both read one section path.
|
|
24
|
+
*/
|
|
25
|
+
export function enterHeading(stack, depth, name) {
|
|
26
|
+
stack.length = depth - 1;
|
|
27
|
+
stack[depth - 1] = name;
|
|
28
|
+
}
|
|
17
29
|
function lineOf(node) {
|
|
18
30
|
return node.position?.start.line ?? 0;
|
|
19
31
|
}
|
|
@@ -32,10 +44,9 @@ export function buildDocument(args) {
|
|
|
32
44
|
const headingStack = [];
|
|
33
45
|
for (const node of args.root.children) {
|
|
34
46
|
if (node.type === 'heading') {
|
|
35
|
-
const name =
|
|
47
|
+
const name = headingName(node);
|
|
36
48
|
sections.push({ name, depth: node.depth, line: lineOf(node) });
|
|
37
|
-
headingStack
|
|
38
|
-
headingStack[node.depth - 1] = name;
|
|
49
|
+
enterHeading(headingStack, node.depth, name);
|
|
39
50
|
}
|
|
40
51
|
else if (node.type === 'table') {
|
|
41
52
|
const rowsText = node.children.map((row) => row.children.map((cell) => nodeText(cell).trim()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/model/document.ts"],"names":[],"mappings":"AAoEA;;;;GAIG;AACH,SAAS,QAAQ,CAAC,IAAwB;IACxC,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACjE,OAAO,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,CAAA;IAC/B,CAAC;IACD,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK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,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ;QACR,MAAM;QACN,UAAU;QACV,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The label grammar a Markdown record uses to declare something on a line —
|
|
3
|
+
* `**State:** Done`, `**Related to:** [a](a.md)` (plan 0405).
|
|
4
|
+
*
|
|
5
|
+
* One grammar, shared by the ledger's `State:` reader, `links().areLabelled()`,
|
|
6
|
+
* and the link walk's label-alone test, so `**Related to**:` cannot be a label to
|
|
7
|
+
* one and a misspelling to another. Every reader below is built from the same
|
|
8
|
+
* fragments; none restates a form by hand. Each caller decides case sensitivity
|
|
9
|
+
* when it compiles the pattern: the ledger reads `**state:**` as `State`,
|
|
10
|
+
* `areLabelled` matches the declared spelling exactly.
|
|
11
|
+
*
|
|
12
|
+
* Accepted forms, each optionally after a list marker: `**Label:**`, `**Label**:`,
|
|
13
|
+
* `__Label__:`, `Label:`. **The colon is required in every form.** Making it
|
|
14
|
+
* optional turned any line beginning with the word into a declaration: the ledger
|
|
15
|
+
* read `Stateless rendering is the default` as the state `less`, and `State
|
|
16
|
+
* machine transitions are documented` as `machine`.
|
|
17
|
+
*
|
|
18
|
+
* The link walk hands these readers a block's text from its content column, so
|
|
19
|
+
* an ordered-list marker, a task box or a blockquote `>` never reaches them; the
|
|
20
|
+
* optional bullet marker is kept for the ledger, which reads raw lines.
|
|
21
|
+
*/
|
|
22
|
+
/** The regex source for a line that opens with `label`, in any accepted form. */
|
|
23
|
+
export declare function labelPattern(label: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* The text of a **wrapped** label (`**Label:**`, `**Label**:`, `__Label__:`) that
|
|
26
|
+
* opens `line`, or `undefined`. The plain `Label:` form is deliberately absent:
|
|
27
|
+
* prose that begins "related to: …" is common, so only a wrapped label is read
|
|
28
|
+
* as an attempt to declare something.
|
|
29
|
+
*/
|
|
30
|
+
export declare function wrappedLabelOf(line: string): string | undefined;
|
|
31
|
+
/** True when `line` is a label in any form and nothing else follows it. */
|
|
32
|
+
export declare function isLabelAlone(line: string): boolean;
|
|
33
|
+
/** Two label spellings that differ only in case or inner spacing. */
|
|
34
|
+
export declare function isNearMiss(found: string, declared: string): boolean;
|
|
35
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../src/model/label.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAuBH,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGlD;AAMD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI/D;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAInE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The label grammar a Markdown record uses to declare something on a line —
|
|
3
|
+
* `**State:** Done`, `**Related to:** [a](a.md)` (plan 0405).
|
|
4
|
+
*
|
|
5
|
+
* One grammar, shared by the ledger's `State:` reader, `links().areLabelled()`,
|
|
6
|
+
* and the link walk's label-alone test, so `**Related to**:` cannot be a label to
|
|
7
|
+
* one and a misspelling to another. Every reader below is built from the same
|
|
8
|
+
* fragments; none restates a form by hand. Each caller decides case sensitivity
|
|
9
|
+
* when it compiles the pattern: the ledger reads `**state:**` as `State`,
|
|
10
|
+
* `areLabelled` matches the declared spelling exactly.
|
|
11
|
+
*
|
|
12
|
+
* Accepted forms, each optionally after a list marker: `**Label:**`, `**Label**:`,
|
|
13
|
+
* `__Label__:`, `Label:`. **The colon is required in every form.** Making it
|
|
14
|
+
* optional turned any line beginning with the word into a declaration: the ledger
|
|
15
|
+
* read `Stateless rendering is the default` as the state `less`, and `State
|
|
16
|
+
* machine transitions are documented` as `machine`.
|
|
17
|
+
*
|
|
18
|
+
* The link walk hands these readers a block's text from its content column, so
|
|
19
|
+
* an ordered-list marker, a task box or a blockquote `>` never reaches them; the
|
|
20
|
+
* optional bullet marker is kept for the ledger, which reads raw lines.
|
|
21
|
+
*/
|
|
22
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
23
|
+
/** Leading space and an optional bullet marker — the ledger's raw-line prefix. */
|
|
24
|
+
const PREFIX = String.raw `^\s*(?:[-*+]\s+)?`;
|
|
25
|
+
/** The three wrapped forms over a label body (a regex source). */
|
|
26
|
+
const wrapped = (body) => String.raw `\*\*${body}:\*\*|\*\*${body}\*\*\s*:|__${body}__\s*:`;
|
|
27
|
+
/** The plain form over a label body (a regex source). */
|
|
28
|
+
const plain = (body) => String.raw `${body}\s*:`;
|
|
29
|
+
/**
|
|
30
|
+
* Any label's body. A plain body may be anything up to a colon: it is read only
|
|
31
|
+
* to ask whether a line is a label alone, and a plain line that is not the
|
|
32
|
+
* declared label never decides a declaration (`decidingBlock`), so a loose match
|
|
33
|
+
* here cannot hide one.
|
|
34
|
+
*/
|
|
35
|
+
const ANY_WRAPPED = String.raw `([^*_\n]+?)`;
|
|
36
|
+
const ANY_PLAIN = String.raw `[^\s:*_][^:\n]*?`;
|
|
37
|
+
/** The regex source for a line that opens with `label`, in any accepted form. */
|
|
38
|
+
export function labelPattern(label) {
|
|
39
|
+
const l = escapeRe(label);
|
|
40
|
+
return `${PREFIX}(?:${wrapped(l)}|${plain(l)})\\s*`;
|
|
41
|
+
}
|
|
42
|
+
const WRAPPED_LABEL = new RegExp(`${PREFIX}(?:${wrapped(ANY_WRAPPED)})`);
|
|
43
|
+
const OPENS_WITH_LABEL = new RegExp(`${PREFIX}(?:${wrapped(ANY_WRAPPED)}|${plain(ANY_PLAIN)})`);
|
|
44
|
+
const LABEL_ALONE = new RegExp(`${OPENS_WITH_LABEL.source}\\s*$`);
|
|
45
|
+
/**
|
|
46
|
+
* The text of a **wrapped** label (`**Label:**`, `**Label**:`, `__Label__:`) that
|
|
47
|
+
* opens `line`, or `undefined`. The plain `Label:` form is deliberately absent:
|
|
48
|
+
* prose that begins "related to: …" is common, so only a wrapped label is read
|
|
49
|
+
* as an attempt to declare something.
|
|
50
|
+
*/
|
|
51
|
+
export function wrappedLabelOf(line) {
|
|
52
|
+
const m = WRAPPED_LABEL.exec(line);
|
|
53
|
+
if (m === null)
|
|
54
|
+
return undefined;
|
|
55
|
+
return m[1] ?? m[2] ?? m[3];
|
|
56
|
+
}
|
|
57
|
+
/** True when `line` is a label in any form and nothing else follows it. */
|
|
58
|
+
export function isLabelAlone(line) {
|
|
59
|
+
return LABEL_ALONE.test(line);
|
|
60
|
+
}
|
|
61
|
+
/** Two label spellings that differ only in case or inner spacing. */
|
|
62
|
+
export function isNearMiss(found, declared) {
|
|
63
|
+
if (found === declared)
|
|
64
|
+
return false;
|
|
65
|
+
const norm = (s) => s.trim().replace(/\s+/g, ' ').toLowerCase();
|
|
66
|
+
return norm(found) === norm(declared);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/model/label.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAA;AAEhF,kFAAkF;AAClF,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAA,mBAAmB,CAAA;AAE5C,kEAAkE;AAClE,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE,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,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,QAAgB;IACxD,IAAI,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACpC,MAAM,IAAI,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;IAC/E,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAA;AACvC,CAAC"}
|
package/dist/model/links.d.ts
CHANGED
|
@@ -18,7 +18,49 @@ export interface MdLinkRef {
|
|
|
18
18
|
*/
|
|
19
19
|
readonly urlStart?: number;
|
|
20
20
|
readonly urlEnd?: number;
|
|
21
|
+
/** The innermost block that holds this link (plan 0405); absent in a heading or a table cell. */
|
|
22
|
+
readonly block?: MdLinkBlock;
|
|
23
|
+
/**
|
|
24
|
+
* Every block enclosing this link, outermost first, ending with `block` — the
|
|
25
|
+
* paragraphs and list items it sits in, and a label alone on its paragraph for
|
|
26
|
+
* the lists directly after it (plan 0405). Mirrors `sectionPath`.
|
|
27
|
+
*/
|
|
28
|
+
readonly blockPath?: readonly MdLinkBlock[];
|
|
29
|
+
/** The headings above this link, outermost first, as `MdTable.sectionPath` records them. */
|
|
30
|
+
readonly sectionPath?: readonly string[];
|
|
21
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* A block that can hold a link (plan 0405): a paragraph or a list item.
|
|
34
|
+
*
|
|
35
|
+
* `line` is the block's first source line; `text` is that line from the block's
|
|
36
|
+
* content column, so a list marker (`-`, `1.`), a task box (`[ ]`) and a
|
|
37
|
+
* blockquote `>` are not part of it.
|
|
38
|
+
*/
|
|
39
|
+
export interface MdLinkBlock {
|
|
40
|
+
readonly line: number;
|
|
41
|
+
readonly text: string;
|
|
42
|
+
}
|
|
43
|
+
/** A label written where no block starts — read by `areLabelled()`'s declaration scan. */
|
|
44
|
+
interface MdUnreadLabel {
|
|
45
|
+
readonly line: number;
|
|
46
|
+
readonly label: string;
|
|
47
|
+
/** `position`: not where a block starts; `format`: at a block's start, in a form the grammar does not read. */
|
|
48
|
+
readonly reason: 'position' | 'format';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Collect inline markdown links (`[text](url)`) from a document tree, each with
|
|
52
|
+
* the blocks that enclose it and the headings above it; plus every block, the
|
|
53
|
+
* enclosing blocks of each reference-style link, and every label written where
|
|
54
|
+
* no block starts (later in a paragraph, in a table cell, in a heading), which
|
|
55
|
+
* therefore declares nothing. Links inside fenced code are not parsed as `link`
|
|
56
|
+
* nodes by mdast, so they are naturally excluded.
|
|
57
|
+
*/
|
|
58
|
+
export declare function collectLinkBlocks(root: Root, source?: string): {
|
|
59
|
+
links: MdLinkRef[];
|
|
60
|
+
references: (readonly MdLinkBlock[])[];
|
|
61
|
+
blocks: MdLinkBlock[];
|
|
62
|
+
unreadLabels: MdUnreadLabel[];
|
|
63
|
+
};
|
|
22
64
|
/**
|
|
23
65
|
* Collect inline markdown links (`[text](url)`) from a document tree. Links
|
|
24
66
|
* inside fenced code are not parsed as `link` nodes by mdast, so they are
|
|
@@ -29,4 +71,5 @@ export declare function collectLinks(root: Root, source?: string): MdLinkRef[];
|
|
|
29
71
|
export interface MdLink extends MdLinkRef {
|
|
30
72
|
readonly doc: MdDocument;
|
|
31
73
|
}
|
|
74
|
+
export {};
|
|
32
75
|
//# sourceMappingURL=links.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/model/links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAS,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/model/links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,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