@driftsys/markspec 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/config/markspec.d.ts +2 -2
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +47 -5
- package/esm/discovery/projects.d.ts +6 -4
- package/esm/discovery/projects.d.ts.map +1 -1
- package/esm/discovery/projects.js +27 -17
- package/esm/formatter/entry_body.d.ts +5 -7
- package/esm/formatter/entry_body.d.ts.map +1 -1
- package/esm/formatter/entry_body.js +13 -9
- package/esm/formatter/md_equiv.d.ts +6 -5
- package/esm/formatter/md_equiv.d.ts.map +1 -1
- package/esm/formatter/md_equiv.js +6 -5
- package/esm/formatter/mod.d.ts +4 -1
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +206 -8
- package/esm/formatter/tab_markers.d.ts +15 -0
- package/esm/formatter/tab_markers.d.ts.map +1 -0
- package/esm/formatter/tab_markers.js +133 -0
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +1 -1
- package/esm/lock/upstream_deps.js +1 -1
- package/esm/mod.d.ts +2 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +2 -1
- package/esm/model/mod.d.ts +1 -1
- package/esm/refs/mod.d.ts +6 -2
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +8 -3
- package/esm/sync/mapping.d.ts +4 -3
- package/esm/sync/mapping.d.ts.map +1 -1
- package/esm/sync/mapping.js +52 -9
- package/esm/util/display_id.d.ts +20 -0
- package/esm/util/display_id.d.ts.map +1 -0
- package/esm/util/display_id.js +19 -0
- package/esm/validator/pipeline.d.ts +6 -4
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +13 -11
- package/package.json +1 -1
- package/script/config/markspec.d.ts +2 -2
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +47 -5
- package/script/discovery/projects.d.ts +6 -4
- package/script/discovery/projects.d.ts.map +1 -1
- package/script/discovery/projects.js +27 -17
- package/script/formatter/entry_body.d.ts +5 -7
- package/script/formatter/entry_body.d.ts.map +1 -1
- package/script/formatter/entry_body.js +13 -9
- package/script/formatter/md_equiv.d.ts +6 -5
- package/script/formatter/md_equiv.d.ts.map +1 -1
- package/script/formatter/md_equiv.js +6 -5
- package/script/formatter/mod.d.ts +4 -1
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +205 -7
- package/script/formatter/tab_markers.d.ts +15 -0
- package/script/formatter/tab_markers.d.ts.map +1 -0
- package/script/formatter/tab_markers.js +141 -0
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +1 -1
- package/script/lock/upstream_deps.js +1 -1
- package/script/mod.d.ts +2 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +8 -5
- package/script/model/mod.d.ts +1 -1
- package/script/refs/mod.d.ts +6 -2
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +8 -3
- package/script/sync/mapping.d.ts +4 -3
- package/script/sync/mapping.d.ts.map +1 -1
- package/script/sync/mapping.js +52 -9
- package/script/util/display_id.d.ts +20 -0
- package/script/util/display_id.d.ts.map +1 -0
- package/script/util/display_id.js +22 -0
- package/script/validator/pipeline.d.ts +6 -4
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +13 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/sync/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,2BAA2B;AAC3B,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC;AAEjE,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAC;AAErE,gEAAg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.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* cache TTL.
|
|
8
8
|
*
|
|
9
9
|
* Diagnostic family is `MSL-S###`:
|
|
10
|
-
* - MSL-S001 — malformed YAML / unsupported schema
|
|
10
|
+
* - MSL-S001 — malformed YAML / invalid structure / unsupported schema
|
|
11
11
|
* - MSL-S002 — locked + outbound contradiction
|
|
12
12
|
* - MSL-S003 — unknown conflict policy (newest-wins removed pre-1.0)
|
|
13
13
|
* - MSL-S004 — system ≠ identity.external-id-scheme
|
|
@@ -23,8 +23,9 @@ const ALLOWED_POLICIES = new Set([
|
|
|
23
23
|
]);
|
|
24
24
|
/**
|
|
25
25
|
* Parse and validate one mapping.yaml. Returns the model when valid, or
|
|
26
|
-
* an MSL-S### diagnostic when not.
|
|
27
|
-
*
|
|
26
|
+
* an MSL-S### diagnostic when not. Never throws on invalid YAML or invalid
|
|
27
|
+
* field shapes. Single-shot — stops at the first integrity failure to keep
|
|
28
|
+
* the repair signal clear.
|
|
28
29
|
*/
|
|
29
30
|
export function parseMapping(yaml, sourcePath) {
|
|
30
31
|
let raw;
|
|
@@ -34,7 +35,16 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
34
35
|
catch (e) {
|
|
35
36
|
return fail("MSL-S001", `Malformed mapping.yaml: ${e.message}`, sourcePath);
|
|
36
37
|
}
|
|
38
|
+
if (raw === null || raw === undefined) {
|
|
39
|
+
return fail("MSL-S001", "Mapping YAML is empty or null", sourcePath);
|
|
40
|
+
}
|
|
41
|
+
if (!isRecord(raw)) {
|
|
42
|
+
return fail("MSL-S001", "Mapping YAML must be an object", sourcePath);
|
|
43
|
+
}
|
|
37
44
|
const schema = raw.schema;
|
|
45
|
+
if (typeof schema !== "number") {
|
|
46
|
+
return fail("MSL-S001", "Missing or non-number `schema` field", sourcePath);
|
|
47
|
+
}
|
|
38
48
|
if (schema !== SUPPORTED_SCHEMA) {
|
|
39
49
|
return fail("MSL-S001", `Unsupported mapping schema: ${schema} (expected ${SUPPORTED_SCHEMA})`, sourcePath);
|
|
40
50
|
}
|
|
@@ -43,12 +53,18 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
43
53
|
return fail("MSL-S001", "Missing or non-string `system` field", sourcePath);
|
|
44
54
|
}
|
|
45
55
|
const direction = raw.direction;
|
|
56
|
+
if (typeof direction !== "string") {
|
|
57
|
+
return fail("MSL-S001", "Missing or non-string `direction` field", sourcePath);
|
|
58
|
+
}
|
|
46
59
|
if (direction !== "outbound" && direction !== "inbound" &&
|
|
47
60
|
direction !== "bidirectional") {
|
|
48
61
|
return fail("MSL-S001", `Invalid top-level direction '${direction}' (expected outbound/inbound/bidirectional)`, sourcePath);
|
|
49
62
|
}
|
|
50
63
|
const identity = raw.identity;
|
|
51
|
-
|
|
64
|
+
if (!isRecord(identity)) {
|
|
65
|
+
return fail("MSL-S001", "Missing or non-object `identity` field", sourcePath);
|
|
66
|
+
}
|
|
67
|
+
const scheme = identity["external-id-scheme"];
|
|
52
68
|
if (typeof scheme !== "string") {
|
|
53
69
|
return fail("MSL-S001", "Missing identity.external-id-scheme", sourcePath);
|
|
54
70
|
}
|
|
@@ -56,19 +72,42 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
56
72
|
return fail("MSL-S004", `system '${system}' does not match identity.external-id-scheme '${scheme}'`, sourcePath);
|
|
57
73
|
}
|
|
58
74
|
const conflict = raw.conflict;
|
|
75
|
+
if (conflict !== undefined && !isRecord(conflict)) {
|
|
76
|
+
return fail("MSL-S001", "Non-object `conflict` field", sourcePath);
|
|
77
|
+
}
|
|
59
78
|
const policy = conflict?.default;
|
|
79
|
+
if (policy !== undefined && typeof policy !== "string") {
|
|
80
|
+
return fail("MSL-S001", "Non-string conflict.default", sourcePath);
|
|
81
|
+
}
|
|
60
82
|
if (policy !== undefined && !ALLOWED_POLICIES.has(policy)) {
|
|
61
83
|
return fail("MSL-S003", `Unknown conflict policy '${policy}' (allowed: manual, local-wins, remote-wins; newest-wins removed pre-1.0)`, sourcePath);
|
|
62
84
|
}
|
|
63
85
|
const cacheRaw = raw.cache;
|
|
64
|
-
|
|
86
|
+
if (cacheRaw !== undefined && !isRecord(cacheRaw)) {
|
|
87
|
+
return fail("MSL-S001", "Non-object `cache` field", sourcePath);
|
|
88
|
+
}
|
|
89
|
+
const ttlStr = cacheRaw?.ttl === undefined ? "15m" : cacheRaw.ttl;
|
|
90
|
+
if (typeof ttlStr !== "string") {
|
|
91
|
+
return fail("MSL-S001", "Non-string cache.ttl", sourcePath);
|
|
92
|
+
}
|
|
65
93
|
const ttlMs = parseDurationMs(ttlStr);
|
|
66
94
|
if (ttlMs === null) {
|
|
67
95
|
return fail("MSL-S005", `Unparseable cache.ttl '${ttlStr}' (expected: 15m, 1h, 7d etc.)`, sourcePath);
|
|
68
96
|
}
|
|
69
|
-
const attrsRaw = raw.attributes
|
|
97
|
+
const attrsRaw = raw.attributes === undefined ? [] : raw.attributes;
|
|
98
|
+
if (!Array.isArray(attrsRaw)) {
|
|
99
|
+
return fail("MSL-S001", "Non-array `attributes` field", sourcePath);
|
|
100
|
+
}
|
|
70
101
|
const attributes = [];
|
|
71
102
|
for (const a of attrsRaw) {
|
|
103
|
+
if (!isRecord(a) || typeof a.markspec !== "string" ||
|
|
104
|
+
typeof a.external !== "string") {
|
|
105
|
+
return fail("MSL-S001", "Each attribute mapping requires an object with string 'markspec' and 'external' fields", sourcePath);
|
|
106
|
+
}
|
|
107
|
+
if ((a.direction !== undefined && typeof a.direction !== "string") ||
|
|
108
|
+
(a.locked !== undefined && typeof a.locked !== "boolean")) {
|
|
109
|
+
return fail("MSL-S001", "Attribute mapping requires a string 'direction' and boolean 'locked' when present", sourcePath);
|
|
110
|
+
}
|
|
72
111
|
const attrDir = (a.direction === "outbound" || a.direction === "inbound" ||
|
|
73
112
|
a.direction === "bidirectional")
|
|
74
113
|
? a.direction
|
|
@@ -77,9 +116,6 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
77
116
|
if (locked && attrDir === "outbound") {
|
|
78
117
|
return fail("MSL-S002", `Attribute '${a.markspec}': locked: true contradicts direction: outbound`, sourcePath);
|
|
79
118
|
}
|
|
80
|
-
if (typeof a.markspec !== "string" || typeof a.external !== "string") {
|
|
81
|
-
return fail("MSL-S001", "Each attribute mapping requires string 'markspec' and 'external' fields", sourcePath);
|
|
82
|
-
}
|
|
83
119
|
attributes.push({
|
|
84
120
|
markspec: a.markspec,
|
|
85
121
|
external: a.external,
|
|
@@ -99,6 +135,13 @@ export function parseMapping(yaml, sourcePath) {
|
|
|
99
135
|
};
|
|
100
136
|
return { mapping, diagnostics: [] };
|
|
101
137
|
}
|
|
138
|
+
/** Whether a YAML value is a plain mapping rather than a scalar or sequence. */
|
|
139
|
+
function isRecord(value) {
|
|
140
|
+
if (typeof value !== "object" || value === null)
|
|
141
|
+
return false;
|
|
142
|
+
const prototype = Object.getPrototypeOf(value);
|
|
143
|
+
return prototype === Object.prototype || prototype === null;
|
|
144
|
+
}
|
|
102
145
|
/**
|
|
103
146
|
* Cross-system validation: at most one system writes locally per attribute.
|
|
104
147
|
* "Writes locally" = direction is `inbound` or `bidirectional`. Multiple
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-ID token characters are ASCII letters, digits, dots, slashes,
|
|
3
|
+
* underscores and hyphens. The LSP reads the whole token under the cursor,
|
|
4
|
+
* including trailing characters in this set, then applies DISPLAY_ID_TOKEN_RE.
|
|
5
|
+
* The renderer scans whole runs of the same characters and resolves each
|
|
6
|
+
* against the known IDs: exact match first, then split on slashes only if
|
|
7
|
+
* every segment is nonempty and a known ID. If neither resolves, remove one
|
|
8
|
+
* trailing period and repeat, leaving the removed period outside the link.
|
|
9
|
+
* A token with a trailing hyphen, such as SYS_A-, does not link SYS_A.
|
|
10
|
+
* With only A/B and C known, A/B/C links nothing: slash segments are not
|
|
11
|
+
* recursively grouped. A known short ID links wherever it stands alone.
|
|
12
|
+
* These recognition rules do not constrain the parser's entry IDs.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DISPLAY_ID_CHAR_RE: RegExp;
|
|
15
|
+
/**
|
|
16
|
+
* An LSP display-ID token starts with an ASCII letter or digit and contains
|
|
17
|
+
* at least three characters. Any display-ID character may end the token.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DISPLAY_ID_TOKEN_RE: RegExp;
|
|
20
|
+
//# sourceMappingURL=display_id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display_id.d.ts","sourceRoot":"","sources":["../../src/util/display_id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,QAAoB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAEjC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-ID token characters are ASCII letters, digits, dots, slashes,
|
|
3
|
+
* underscores and hyphens. The LSP reads the whole token under the cursor,
|
|
4
|
+
* including trailing characters in this set, then applies DISPLAY_ID_TOKEN_RE.
|
|
5
|
+
* The renderer scans whole runs of the same characters and resolves each
|
|
6
|
+
* against the known IDs: exact match first, then split on slashes only if
|
|
7
|
+
* every segment is nonempty and a known ID. If neither resolves, remove one
|
|
8
|
+
* trailing period and repeat, leaving the removed period outside the link.
|
|
9
|
+
* A token with a trailing hyphen, such as SYS_A-, does not link SYS_A.
|
|
10
|
+
* With only A/B and C known, A/B/C links nothing: slash segments are not
|
|
11
|
+
* recursively grouped. A known short ID links wherever it stands alone.
|
|
12
|
+
* These recognition rules do not constrain the parser's entry IDs.
|
|
13
|
+
*/
|
|
14
|
+
export const DISPLAY_ID_CHAR_RE = /[A-Za-z0-9._/-]/;
|
|
15
|
+
/**
|
|
16
|
+
* An LSP display-ID token starts with an ASCII letter or digit and contains
|
|
17
|
+
* at least three characters. Any display-ID character may end the token.
|
|
18
|
+
*/
|
|
19
|
+
export const DISPLAY_ID_TOKEN_RE = new RegExp(`^[A-Za-z0-9]${DISPLAY_ID_CHAR_RE.source}{2,}$`);
|
|
@@ -19,12 +19,14 @@ export interface PipelineResult {
|
|
|
19
19
|
/** Options for {@linkcode runPipeline}. */
|
|
20
20
|
export interface PipelineOptions {
|
|
21
21
|
/**
|
|
22
|
-
* When `false`, suppress
|
|
23
|
-
*
|
|
22
|
+
* When `false`, suppress cross-entry TYPL-009/010/011 from Stage 1,
|
|
23
|
+
* UXIL-016/017/018 from Stage 5, and MSL-L006 ("link target does not
|
|
24
|
+
* resolve") from Stage 4.
|
|
25
|
+
* Use this when the validator is running against a subset
|
|
24
26
|
* of the project's files (e.g. `markspec check <file>`): file-local scope
|
|
25
27
|
* cannot distinguish a typo from a valid cross-file target. MSL-L006 is
|
|
26
28
|
* only meaningful when the full entry set is available (LSP, `compile`).
|
|
27
|
-
* Defaults to `true` (full-project scope — emit
|
|
29
|
+
* Defaults to `true` (full-project scope — emit these codes normally).
|
|
28
30
|
*/
|
|
29
31
|
readonly projectWide?: boolean;
|
|
30
32
|
/**
|
|
@@ -53,7 +55,7 @@ export interface PipelineOptions {
|
|
|
53
55
|
* and non-empty, MSL-C072 is checked for each entry. Defaults to no
|
|
54
56
|
* conventions (rule inactive).
|
|
55
57
|
* @param opts - Pipeline options. Pass `{ projectWide: false }` when
|
|
56
|
-
* validating a file-local subset
|
|
58
|
+
* validating a file-local subset to suppress cross-entry diagnostics.
|
|
57
59
|
*/
|
|
58
60
|
export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null, captionConventions?: CaptionConventions, opts?: PipelineOptions): PipelineResult;
|
|
59
61
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;AAyCzB,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;OASG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;;;;OAOG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,EAChC,kBAAkB,GAAE,kBAAuB,EAC3C,IAAI,GAAE,eAAoB,GACzB,cAAc,CA0JhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,SAAS,UAAU,EAAE,CASvB"}
|
|
@@ -23,11 +23,15 @@ import { validateCaptionConvention } from "./caption_convention.js";
|
|
|
23
23
|
import { validateDiscipline } from "./discipline.js";
|
|
24
24
|
import { buildEffectiveDisciplineRegistry } from "../profile/discipline_registry.js";
|
|
25
25
|
import { validateUxilFamily } from "./uxil_family.js";
|
|
26
|
-
/** Cross-entry
|
|
26
|
+
/** Cross-entry DSL codes suppressed under file-local scope: a
|
|
27
27
|
* subset registry cannot distinguish a dangling reference from an
|
|
28
28
|
* unchecked file — the same false-positive class the MSL-L006 filter
|
|
29
|
-
* guards.
|
|
30
|
-
|
|
29
|
+
* guards. Suppress these even when the cause is inside the subset,
|
|
30
|
+
* matching uxil's scope policy. Parser diagnostics are unaffected. */
|
|
31
|
+
const FILE_LOCAL_SUPPRESSED_DSL = new Set([
|
|
32
|
+
"TYPL-009",
|
|
33
|
+
"TYPL-010",
|
|
34
|
+
"TYPL-011",
|
|
31
35
|
"UXIL-016",
|
|
32
36
|
"UXIL-017",
|
|
33
37
|
"UXIL-018",
|
|
@@ -48,7 +52,7 @@ const FILE_LOCAL_SUPPRESSED_UXIL = new Set([
|
|
|
48
52
|
* and non-empty, MSL-C072 is checked for each entry. Defaults to no
|
|
49
53
|
* conventions (rule inactive).
|
|
50
54
|
* @param opts - Pipeline options. Pass `{ projectWide: false }` when
|
|
51
|
-
* validating a file-local subset
|
|
55
|
+
* validating a file-local subset to suppress cross-entry diagnostics.
|
|
52
56
|
*/
|
|
53
57
|
export function runPipeline(entries, profile, captionConventions = {}, opts = {}) {
|
|
54
58
|
const diagnostics = [];
|
|
@@ -169,14 +173,12 @@ export function runPipeline(entries, profile, captionConventions = {}, opts = {}
|
|
|
169
173
|
// FULL classified list on purpose: the family derives its own #771
|
|
170
174
|
// partition and its own declaring/citing split — registry scope is the
|
|
171
175
|
// module's contract, not this orchestrator's (mirrors validateTypl).
|
|
172
|
-
// File-local scope (projectWide: false) suppresses the cross-entry codes
|
|
173
|
-
// (UXIL-016/017/018) — a subset registry cannot distinguish a dangling
|
|
174
|
-
// reference from an unchecked file, the same false-positive class the
|
|
175
|
-
// MSL-L006 suppression guards (#727 review).
|
|
176
176
|
const uxilDiagnostics = validateUxilFamily(finalEntries, profile);
|
|
177
|
-
diagnostics.push(...
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
diagnostics.push(...uxilDiagnostics);
|
|
178
|
+
// Apply the same scope policy to Stage 1's typl and Stage 5's uxil.
|
|
179
|
+
const scopedDiagnostics = projectWide ? diagnostics : diagnostics.filter((d) => !FILE_LOCAL_SUPPRESSED_DSL.has(d.code));
|
|
180
|
+
const valid = !scopedDiagnostics.some((d) => d.severity === "error");
|
|
181
|
+
return { entries: finalEntries, diagnostics: scopedDiagnostics, valid };
|
|
180
182
|
}
|
|
181
183
|
/**
|
|
182
184
|
* Drop core Stage 1 `MSL-R010` ("unknown attribute") warnings for attributes
|
package/package.json
CHANGED
|
@@ -50,12 +50,12 @@ export interface MarkspecYaml {
|
|
|
50
50
|
* Applied after built-in build-output skips and all `.gitignore` rules at
|
|
51
51
|
* every directory level by `core/discovery`. Negations can re-include
|
|
52
52
|
* non-hidden directories, provided their parents are not ignored. Hidden
|
|
53
|
-
* directories are always skipped. Defaults to `[]` when the key is absent.
|
|
53
|
+
* directories are always skipped. Defaults to `[]` when the key is absent or null.
|
|
54
54
|
*/
|
|
55
55
|
readonly exclude: readonly string[];
|
|
56
56
|
/**
|
|
57
57
|
* Per-keyword caption-position conventions (spec §4.7 MSL-C072).
|
|
58
|
-
* Defaults to `{}` when the key is absent.
|
|
58
|
+
* Defaults to `{}` when the key is absent or null.
|
|
59
59
|
*/
|
|
60
60
|
readonly captionConventions: CaptionConventions;
|
|
61
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/config/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/config/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,yFAAyF;AACzF,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAMrE;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAU7B;AA8DD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,aAAa,CA4Hf;AAwID;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAiBxD;AAMD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAUvC"}
|
package/script/config/mod.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.deriveDomain = deriveDomain;
|
|
|
13
13
|
exports.loadConfig = loadConfig;
|
|
14
14
|
const yaml_1 = require("@std/yaml");
|
|
15
15
|
const path_1 = require("@std/path");
|
|
16
|
+
const formats_js_1 = require("ajv-formats/dist/formats.js");
|
|
16
17
|
const mod_js_1 = require("../model/mod.js");
|
|
17
18
|
/** The config file name used as the project root marker. */
|
|
18
19
|
exports.CONFIG_FILE_NAME = "project.yaml";
|
|
@@ -150,12 +151,24 @@ function parseProjectConfig(yaml, filePath) {
|
|
|
150
151
|
// version: required string (org project schema)
|
|
151
152
|
let version = mod_js_1.DEFAULT_PROJECT_CONFIG.version;
|
|
152
153
|
if (obj.version !== undefined && obj.version !== null && obj.version !== "") {
|
|
153
|
-
if (typeof obj.version === "
|
|
154
|
+
if (typeof obj.version === "string") {
|
|
155
|
+
version = obj.version;
|
|
156
|
+
}
|
|
157
|
+
else if (typeof obj.version === "number") {
|
|
158
|
+
// Existing tests and the guide require numeric-version coercion.
|
|
159
|
+
// This remains an exception to the org schema's string-only rule.
|
|
154
160
|
console.error(`warning: ${filePath}: version is a number (${obj.version}), ` +
|
|
155
161
|
`coerced to "${String(obj.version)}". ` +
|
|
156
162
|
`Quote it in YAML: version: "${obj.version}"`);
|
|
163
|
+
version = String(obj.version);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
errors.push({
|
|
167
|
+
field: "version",
|
|
168
|
+
message: `expected string, got ${typeof obj.version}`,
|
|
169
|
+
line: findLineNumber(yaml, "version"),
|
|
170
|
+
});
|
|
157
171
|
}
|
|
158
|
-
version = String(obj.version);
|
|
159
172
|
}
|
|
160
173
|
else {
|
|
161
174
|
errors.push({
|
|
@@ -200,6 +213,8 @@ function parseProjectConfig(yaml, filePath) {
|
|
|
200
213
|
/** Safe upstream id: single path segment, no separators or traversal. */
|
|
201
214
|
const PROJECT_REF_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
202
215
|
const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
|
|
216
|
+
// ajv-formats provides the RFC 3986 URI validator used by schema validation.
|
|
217
|
+
const isUri = formats_js_1.fullFormats.uri;
|
|
203
218
|
/**
|
|
204
219
|
* Parse a `dependencies:` or `references:` list of projectRef objects
|
|
205
220
|
* (`{ url (required), version?, name? }`). Pushes field errors onto
|
|
@@ -208,7 +223,7 @@ const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
|
|
|
208
223
|
* mask other unrelated errors.
|
|
209
224
|
*/
|
|
210
225
|
function parseProjectRefList(value, field, yaml, errors) {
|
|
211
|
-
if (value === undefined
|
|
226
|
+
if (value === undefined)
|
|
212
227
|
return [];
|
|
213
228
|
if (!Array.isArray(value)) {
|
|
214
229
|
errors.push({
|
|
@@ -218,6 +233,13 @@ function parseProjectRefList(value, field, yaml, errors) {
|
|
|
218
233
|
});
|
|
219
234
|
return [];
|
|
220
235
|
}
|
|
236
|
+
if (value.length === 0) {
|
|
237
|
+
errors.push({
|
|
238
|
+
field,
|
|
239
|
+
message: "must contain at least one projectRef when present",
|
|
240
|
+
line: findLineNumber(yaml, field),
|
|
241
|
+
});
|
|
242
|
+
}
|
|
221
243
|
const out = [];
|
|
222
244
|
value.forEach((item, i) => {
|
|
223
245
|
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
@@ -247,12 +269,24 @@ function parseProjectRefList(value, field, yaml, errors) {
|
|
|
247
269
|
});
|
|
248
270
|
return;
|
|
249
271
|
}
|
|
272
|
+
// Local paths and scp-style Git URLs are required by existing tests and
|
|
273
|
+
// documentation, although the org schema's URI format rejects them.
|
|
274
|
+
const isGitLocation = field === "dependencies" && (url.startsWith("./") || url.startsWith("../") || url.startsWith("/") ||
|
|
275
|
+
/^[A-Za-z]:\\/.test(url) ||
|
|
276
|
+
/^[^@/:\s]+@[^/:\s]+:[^\s]+$/.test(url));
|
|
277
|
+
if (!isUri(url) && !isGitLocation) {
|
|
278
|
+
errors.push({
|
|
279
|
+
field: `${field}[${i}].url`,
|
|
280
|
+
message: "must be a URI",
|
|
281
|
+
line: findLineNumber(yaml, field),
|
|
282
|
+
});
|
|
283
|
+
}
|
|
250
284
|
const ref = { url };
|
|
251
285
|
if (record.version !== undefined) {
|
|
252
|
-
if (typeof record.version !== "string"
|
|
286
|
+
if (typeof record.version !== "string") {
|
|
253
287
|
errors.push({
|
|
254
288
|
field: `${field}[${i}].version`,
|
|
255
|
-
message: "must be a
|
|
289
|
+
message: "must be a string when present",
|
|
256
290
|
line: findLineNumber(yaml, field),
|
|
257
291
|
});
|
|
258
292
|
}
|
|
@@ -273,6 +307,14 @@ function parseProjectRefList(value, field, yaml, errors) {
|
|
|
273
307
|
ref.name = record.name;
|
|
274
308
|
}
|
|
275
309
|
}
|
|
310
|
+
if (out.some((previous) => previous.url === ref.url && previous.version === ref.version &&
|
|
311
|
+
previous.name === ref.name)) {
|
|
312
|
+
errors.push({
|
|
313
|
+
field: `${field}[${i}]`,
|
|
314
|
+
message: "duplicate projectRef; list items must be unique",
|
|
315
|
+
line: findLineNumber(yaml, field),
|
|
316
|
+
});
|
|
317
|
+
}
|
|
276
318
|
out.push(ref);
|
|
277
319
|
});
|
|
278
320
|
return out;
|
|
@@ -32,10 +32,12 @@ export declare function resolveConfigRoot(startDir: string, readFile: (path: str
|
|
|
32
32
|
* `exclude`). Each discovered `project.yaml` or `.markspec.yaml` is
|
|
33
33
|
* resolved with {@linkcode resolveConfigRoot} from its own directory, so a
|
|
34
34
|
* `.markspec.yaml` below a `project.yaml` is not a root of its own — the
|
|
35
|
-
* same answer the CLI gives for a file there.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
35
|
+
* same answer the CLI gives for a file there. Each found root is scanned
|
|
36
|
+
* again with its own exclude list, so its negations can re-include non-hidden
|
|
37
|
+
* folders that the enclosing project's walk skipped. A found root is dropped
|
|
38
|
+
* when the start root's exclude list or the `.markspec.yaml` `exclude:` list
|
|
39
|
+
* of another found root above it covers it: each project's exclude list applies
|
|
40
|
+
* to its own subtree, with patterns relative to that project. The result is sorted.
|
|
39
41
|
*/
|
|
40
42
|
export declare function findNestedProjectRoots(root: string, io: DiscoveryIO, exclude?: readonly string[]): Promise<string[]>;
|
|
41
43
|
/** Options for {@linkcode discoverProjectRoots}. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/discovery/projects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAS3D,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED;;;GAGG;AACH,wB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,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,WAAW,EACf,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAoBnD;AAED;4CAC4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C;;;;;;OAMG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,WAAW,EACf,OAAO,GAAE,uBAA4B,GACpC,mBAAmB,CAqErB"}
|
|
@@ -67,33 +67,43 @@ async function resolveConfigRoot(startDir, readFile) {
|
|
|
67
67
|
* `exclude`). Each discovered `project.yaml` or `.markspec.yaml` is
|
|
68
68
|
* resolved with {@linkcode resolveConfigRoot} from its own directory, so a
|
|
69
69
|
* `.markspec.yaml` below a `project.yaml` is not a root of its own — the
|
|
70
|
-
* same answer the CLI gives for a file there.
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
70
|
+
* same answer the CLI gives for a file there. Each found root is scanned
|
|
71
|
+
* again with its own exclude list, so its negations can re-include non-hidden
|
|
72
|
+
* folders that the enclosing project's walk skipped. A found root is dropped
|
|
73
|
+
* when the start root's exclude list or the `.markspec.yaml` `exclude:` list
|
|
74
|
+
* of another found root above it covers it: each project's exclude list applies
|
|
75
|
+
* to its own subtree, with patterns relative to that project. The result is sorted.
|
|
74
76
|
*/
|
|
75
77
|
async function findNestedProjectRoots(root, io, exclude) {
|
|
76
78
|
const out = new Set();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
const scans = [{ root, exclude }];
|
|
80
|
+
for (const scan of scans) {
|
|
81
|
+
for await (const path of (0, mod_js_2.discoverFiles)(scan.root, io, {
|
|
82
|
+
extensions: new Set([".yaml"]),
|
|
83
|
+
exclude: scan.exclude,
|
|
84
|
+
inheritGitignoreFrom: root,
|
|
85
|
+
})) {
|
|
86
|
+
if (!CONFIG_BASENAMES.has((0, path_1.basename)(path)))
|
|
87
|
+
continue;
|
|
88
|
+
const dir = (0, path_1.dirname)(path);
|
|
89
|
+
if (dir === scan.root)
|
|
90
|
+
continue;
|
|
91
|
+
const found = await resolveConfigRoot(dir, io.readFile);
|
|
92
|
+
if (found !== undefined && found !== root && isWithin(root, found) &&
|
|
93
|
+
!out.has(found)) {
|
|
94
|
+
out.add(found);
|
|
95
|
+
const { config } = await (0, markspec_js_1.loadToolConfig)(found, io.readFile);
|
|
96
|
+
scans.push({ root: found, exclude: config.exclude });
|
|
97
|
+
}
|
|
89
98
|
}
|
|
90
99
|
}
|
|
91
100
|
const nested = [...out];
|
|
92
101
|
const excludeRules = new Map();
|
|
102
|
+
excludeRules.set(root, (0, gitignore_js_1.parseGitignore)((exclude ?? []).join("\n"), ""));
|
|
93
103
|
const kept = [];
|
|
94
104
|
for (const candidate of nested) {
|
|
95
105
|
let covered = false;
|
|
96
|
-
for (const ancestor of nested) {
|
|
106
|
+
for (const ancestor of [root, ...nested]) {
|
|
97
107
|
if (ancestor === candidate || !isWithin(ancestor, candidate))
|
|
98
108
|
continue;
|
|
99
109
|
let rules = excludeRules.get(ancestor);
|
|
@@ -34,13 +34,11 @@ export type EntryBodyEdit = {
|
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* 0-based content column of the list item whose marker starts at `marker`
|
|
37
|
-
* on `line`: the marker column, plus 1 for the bullet, plus the
|
|
38
|
-
* after it.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* start with a bullet and a space at `marker`, the marker column plus 2 is
|
|
43
|
-
* used as a fallback.
|
|
37
|
+
* on `line`: the marker column, plus 1 for the bullet, plus the whitespace
|
|
38
|
+
* after it. Tabs advance to the next four-column CommonMark tab stop.
|
|
39
|
+
* So `- [ID]` gives 2, `- [ID]` gives 4, and `-\t[ID]` gives 4 at
|
|
40
|
+
* column zero. Ordered lists never hold entries. When there is no bullet
|
|
41
|
+
* followed by whitespace at `marker`, use the marker column plus 2.
|
|
44
42
|
*/
|
|
45
43
|
export declare function contentColumn(line: string, marker: number): number;
|
|
46
44
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry_body.d.ts","sourceRoot":"","sources":["../../src/formatter/entry_body.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,YAAY,GACZ,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAAC;AA8E/D
|
|
1
|
+
{"version":3,"file":"entry_body.d.ts","sourceRoot":"","sources":["../../src/formatter/entry_body.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,YAAY,GACZ,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAAC;AA8E/D;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQlE;AAyCD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,CAAC,CAoDxB"}
|
|
@@ -86,17 +86,21 @@ function bodySpan(lines, entry) {
|
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* 0-based content column of the list item whose marker starts at `marker`
|
|
89
|
-
* on `line`: the marker column, plus 1 for the bullet, plus the
|
|
90
|
-
* after it.
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* start with a bullet and a space at `marker`, the marker column plus 2 is
|
|
95
|
-
* used as a fallback.
|
|
89
|
+
* on `line`: the marker column, plus 1 for the bullet, plus the whitespace
|
|
90
|
+
* after it. Tabs advance to the next four-column CommonMark tab stop.
|
|
91
|
+
* So `- [ID]` gives 2, `- [ID]` gives 4, and `-\t[ID]` gives 4 at
|
|
92
|
+
* column zero. Ordered lists never hold entries. When there is no bullet
|
|
93
|
+
* followed by whitespace at `marker`, use the marker column plus 2.
|
|
96
94
|
*/
|
|
97
95
|
function contentColumn(line, marker) {
|
|
98
|
-
const m = /^[-*+]( +)/.exec(line.slice(marker));
|
|
99
|
-
|
|
96
|
+
const m = /^[-*+]([ \t]+)/.exec(line.slice(marker));
|
|
97
|
+
if (!m)
|
|
98
|
+
return marker + 2;
|
|
99
|
+
let column = marker + 1;
|
|
100
|
+
for (const character of m[1]) {
|
|
101
|
+
column += character === "\t" ? 4 - column % 4 : 1;
|
|
102
|
+
}
|
|
103
|
+
return column;
|
|
100
104
|
}
|
|
101
105
|
/** Dedented span lines, trailing whitespace removed. */
|
|
102
106
|
function spanText(lines, span) {
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* @module formatter/md_equiv
|
|
3
3
|
*
|
|
4
4
|
* CommonMark-semantic Markdown equivalence — the gate for the ADR-029
|
|
5
|
-
* dprint pass. Two fragments are equivalent
|
|
6
|
-
* same mdast structure after eliding source `position`s
|
|
5
|
+
* dprint pass and entry tab-marker normalization. Two fragments are equivalent
|
|
6
|
+
* when they parse to the same mdast structure after eliding source `position`s
|
|
7
|
+
* and collapsing
|
|
7
8
|
* ASCII whitespace runs inside `text` node values. Only ASCII
|
|
8
9
|
* whitespace is collapsed — NBSP (U+00A0) and Unicode spaces are
|
|
9
10
|
* content, not wrap artifacts, and must not compare equal to a plain
|
|
@@ -15,9 +16,9 @@
|
|
|
15
16
|
* and definition `url`s stay byte-exact.
|
|
16
17
|
*
|
|
17
18
|
* DELIBERATELY weaker than ADR-015's `astEquivalent` (byte-verbatim on
|
|
18
|
-
* inline markup). Used
|
|
19
|
-
* ADR-015 relation still guards §5.2 body emission (MSL-F900) and must
|
|
20
|
-
*
|
|
19
|
+
* inline markup). Used to accept/reject dprint output and tab-marker rewrites.
|
|
20
|
+
* The ADR-015 relation still guards §5.2 body emission (MSL-F900) and must not
|
|
21
|
+
* be modified.
|
|
21
22
|
*/
|
|
22
23
|
/** True when `a` and `b` are the same Markdown, modulo presentation. */
|
|
23
24
|
export declare function markdownSemanticallyEquivalent(a: string, b: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md_equiv.d.ts","sourceRoot":"","sources":["../../src/formatter/md_equiv.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"md_equiv.d.ts","sourceRoot":"","sources":["../../src/formatter/md_equiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,wEAAwE;AACxE,wBAAgB,8BAA8B,CAC5C,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAMT"}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* @module formatter/md_equiv
|
|
4
4
|
*
|
|
5
5
|
* CommonMark-semantic Markdown equivalence — the gate for the ADR-029
|
|
6
|
-
* dprint pass. Two fragments are equivalent
|
|
7
|
-
* same mdast structure after eliding source `position`s
|
|
6
|
+
* dprint pass and entry tab-marker normalization. Two fragments are equivalent
|
|
7
|
+
* when they parse to the same mdast structure after eliding source `position`s
|
|
8
|
+
* and collapsing
|
|
8
9
|
* ASCII whitespace runs inside `text` node values. Only ASCII
|
|
9
10
|
* whitespace is collapsed — NBSP (U+00A0) and Unicode spaces are
|
|
10
11
|
* content, not wrap artifacts, and must not compare equal to a plain
|
|
@@ -16,9 +17,9 @@
|
|
|
16
17
|
* and definition `url`s stay byte-exact.
|
|
17
18
|
*
|
|
18
19
|
* DELIBERATELY weaker than ADR-015's `astEquivalent` (byte-verbatim on
|
|
19
|
-
* inline markup). Used
|
|
20
|
-
* ADR-015 relation still guards §5.2 body emission (MSL-F900) and must
|
|
21
|
-
*
|
|
20
|
+
* inline markup). Used to accept/reject dprint output and tab-marker rewrites.
|
|
21
|
+
* The ADR-015 relation still guards §5.2 body emission (MSL-F900) and must not
|
|
22
|
+
* be modified.
|
|
22
23
|
*/
|
|
23
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|