@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
package/esm/config/markspec.d.ts
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
|
}
|
package/esm/config/mod.d.ts.map
CHANGED
|
@@ -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/esm/config/mod.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { parse as parseYaml } from "@std/yaml";
|
|
8
8
|
import { dirname, join, resolve } from "@std/path";
|
|
9
|
+
import { fullFormats } from "ajv-formats/dist/formats.js";
|
|
9
10
|
import { ConfigError, DEFAULT_PROJECT_CONFIG, } from "../model/mod.js";
|
|
10
11
|
/** The config file name used as the project root marker. */
|
|
11
12
|
export const CONFIG_FILE_NAME = "project.yaml";
|
|
@@ -143,12 +144,24 @@ export function parseProjectConfig(yaml, filePath) {
|
|
|
143
144
|
// version: required string (org project schema)
|
|
144
145
|
let version = DEFAULT_PROJECT_CONFIG.version;
|
|
145
146
|
if (obj.version !== undefined && obj.version !== null && obj.version !== "") {
|
|
146
|
-
if (typeof obj.version === "
|
|
147
|
+
if (typeof obj.version === "string") {
|
|
148
|
+
version = obj.version;
|
|
149
|
+
}
|
|
150
|
+
else if (typeof obj.version === "number") {
|
|
151
|
+
// Existing tests and the guide require numeric-version coercion.
|
|
152
|
+
// This remains an exception to the org schema's string-only rule.
|
|
147
153
|
console.error(`warning: ${filePath}: version is a number (${obj.version}), ` +
|
|
148
154
|
`coerced to "${String(obj.version)}". ` +
|
|
149
155
|
`Quote it in YAML: version: "${obj.version}"`);
|
|
156
|
+
version = String(obj.version);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
errors.push({
|
|
160
|
+
field: "version",
|
|
161
|
+
message: `expected string, got ${typeof obj.version}`,
|
|
162
|
+
line: findLineNumber(yaml, "version"),
|
|
163
|
+
});
|
|
150
164
|
}
|
|
151
|
-
version = String(obj.version);
|
|
152
165
|
}
|
|
153
166
|
else {
|
|
154
167
|
errors.push({
|
|
@@ -193,6 +206,8 @@ export function parseProjectConfig(yaml, filePath) {
|
|
|
193
206
|
/** Safe upstream id: single path segment, no separators or traversal. */
|
|
194
207
|
const PROJECT_REF_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
195
208
|
const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
|
|
209
|
+
// ajv-formats provides the RFC 3986 URI validator used by schema validation.
|
|
210
|
+
const isUri = fullFormats.uri;
|
|
196
211
|
/**
|
|
197
212
|
* Parse a `dependencies:` or `references:` list of projectRef objects
|
|
198
213
|
* (`{ url (required), version?, name? }`). Pushes field errors onto
|
|
@@ -201,7 +216,7 @@ const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
|
|
|
201
216
|
* mask other unrelated errors.
|
|
202
217
|
*/
|
|
203
218
|
function parseProjectRefList(value, field, yaml, errors) {
|
|
204
|
-
if (value === undefined
|
|
219
|
+
if (value === undefined)
|
|
205
220
|
return [];
|
|
206
221
|
if (!Array.isArray(value)) {
|
|
207
222
|
errors.push({
|
|
@@ -211,6 +226,13 @@ function parseProjectRefList(value, field, yaml, errors) {
|
|
|
211
226
|
});
|
|
212
227
|
return [];
|
|
213
228
|
}
|
|
229
|
+
if (value.length === 0) {
|
|
230
|
+
errors.push({
|
|
231
|
+
field,
|
|
232
|
+
message: "must contain at least one projectRef when present",
|
|
233
|
+
line: findLineNumber(yaml, field),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
214
236
|
const out = [];
|
|
215
237
|
value.forEach((item, i) => {
|
|
216
238
|
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
@@ -240,12 +262,24 @@ function parseProjectRefList(value, field, yaml, errors) {
|
|
|
240
262
|
});
|
|
241
263
|
return;
|
|
242
264
|
}
|
|
265
|
+
// Local paths and scp-style Git URLs are required by existing tests and
|
|
266
|
+
// documentation, although the org schema's URI format rejects them.
|
|
267
|
+
const isGitLocation = field === "dependencies" && (url.startsWith("./") || url.startsWith("../") || url.startsWith("/") ||
|
|
268
|
+
/^[A-Za-z]:\\/.test(url) ||
|
|
269
|
+
/^[^@/:\s]+@[^/:\s]+:[^\s]+$/.test(url));
|
|
270
|
+
if (!isUri(url) && !isGitLocation) {
|
|
271
|
+
errors.push({
|
|
272
|
+
field: `${field}[${i}].url`,
|
|
273
|
+
message: "must be a URI",
|
|
274
|
+
line: findLineNumber(yaml, field),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
243
277
|
const ref = { url };
|
|
244
278
|
if (record.version !== undefined) {
|
|
245
|
-
if (typeof record.version !== "string"
|
|
279
|
+
if (typeof record.version !== "string") {
|
|
246
280
|
errors.push({
|
|
247
281
|
field: `${field}[${i}].version`,
|
|
248
|
-
message: "must be a
|
|
282
|
+
message: "must be a string when present",
|
|
249
283
|
line: findLineNumber(yaml, field),
|
|
250
284
|
});
|
|
251
285
|
}
|
|
@@ -266,6 +300,14 @@ function parseProjectRefList(value, field, yaml, errors) {
|
|
|
266
300
|
ref.name = record.name;
|
|
267
301
|
}
|
|
268
302
|
}
|
|
303
|
+
if (out.some((previous) => previous.url === ref.url && previous.version === ref.version &&
|
|
304
|
+
previous.name === ref.name)) {
|
|
305
|
+
errors.push({
|
|
306
|
+
field: `${field}[${i}]`,
|
|
307
|
+
message: "duplicate projectRef; list items must be unique",
|
|
308
|
+
line: findLineNumber(yaml, field),
|
|
309
|
+
});
|
|
310
|
+
}
|
|
269
311
|
out.push(ref);
|
|
270
312
|
});
|
|
271
313
|
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,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GACtB,MAAM,GAAG,SAAS,CAOpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GACtD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAG7B;AAED
|
|
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,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,KA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ACpC,mBAAmB,CAqErB"}
|
|
@@ -59,33 +59,43 @@ export async function resolveConfigRoot(startDir, readFile) {
|
|
|
59
59
|
* `exclude`). Each discovered `project.yaml` or `.markspec.yaml` is
|
|
60
60
|
* resolved with {@linkcode resolveConfigRoot} from its own directory, so a
|
|
61
61
|
* `.markspec.yaml` below a `project.yaml` is not a root of its own — the
|
|
62
|
-
* same answer the CLI gives for a file there.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
62
|
+
* same answer the CLI gives for a file there. Each found root is scanned
|
|
63
|
+
* again with its own exclude list, so its negations can re-include non-hidden
|
|
64
|
+
* folders that the enclosing project's walk skipped. A found root is dropped
|
|
65
|
+
* when the start root's exclude list or the `.markspec.yaml` `exclude:` list
|
|
66
|
+
* of another found root above it covers it: each project's exclude list applies
|
|
67
|
+
* to its own subtree, with patterns relative to that project. The result is sorted.
|
|
66
68
|
*/
|
|
67
69
|
export async function findNestedProjectRoots(root, io, exclude) {
|
|
68
70
|
const out = new Set();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
const scans = [{ root, exclude }];
|
|
72
|
+
for (const scan of scans) {
|
|
73
|
+
for await (const path of discoverFiles(scan.root, io, {
|
|
74
|
+
extensions: new Set([".yaml"]),
|
|
75
|
+
exclude: scan.exclude,
|
|
76
|
+
inheritGitignoreFrom: root,
|
|
77
|
+
})) {
|
|
78
|
+
if (!CONFIG_BASENAMES.has(basename(path)))
|
|
79
|
+
continue;
|
|
80
|
+
const dir = dirname(path);
|
|
81
|
+
if (dir === scan.root)
|
|
82
|
+
continue;
|
|
83
|
+
const found = await resolveConfigRoot(dir, io.readFile);
|
|
84
|
+
if (found !== undefined && found !== root && isWithin(root, found) &&
|
|
85
|
+
!out.has(found)) {
|
|
86
|
+
out.add(found);
|
|
87
|
+
const { config } = await loadToolConfig(found, io.readFile);
|
|
88
|
+
scans.push({ root: found, exclude: config.exclude });
|
|
89
|
+
}
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
92
|
const nested = [...out];
|
|
84
93
|
const excludeRules = new Map();
|
|
94
|
+
excludeRules.set(root, parseGitignore((exclude ?? []).join("\n"), ""));
|
|
85
95
|
const kept = [];
|
|
86
96
|
for (const candidate of nested) {
|
|
87
97
|
let covered = false;
|
|
88
|
-
for (const ancestor of nested) {
|
|
98
|
+
for (const ancestor of [root, ...nested]) {
|
|
89
99
|
if (ancestor === candidate || !isWithin(ancestor, candidate))
|
|
90
100
|
continue;
|
|
91
101
|
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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IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,CAAC,CAoDxB"}
|
|
@@ -81,17 +81,21 @@ function bodySpan(lines, entry) {
|
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* 0-based content column of the list item whose marker starts at `marker`
|
|
84
|
-
* on `line`: the marker column, plus 1 for the bullet, plus the
|
|
85
|
-
* after it.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* start with a bullet and a space at `marker`, the marker column plus 2 is
|
|
90
|
-
* used as a fallback.
|
|
84
|
+
* on `line`: the marker column, plus 1 for the bullet, plus the whitespace
|
|
85
|
+
* after it. Tabs advance to the next four-column CommonMark tab stop.
|
|
86
|
+
* So `- [ID]` gives 2, `- [ID]` gives 4, and `-\t[ID]` gives 4 at
|
|
87
|
+
* column zero. Ordered lists never hold entries. When there is no bullet
|
|
88
|
+
* followed by whitespace at `marker`, use the marker column plus 2.
|
|
91
89
|
*/
|
|
92
90
|
export function contentColumn(line, marker) {
|
|
93
|
-
const m = /^[-*+]( +)/.exec(line.slice(marker));
|
|
94
|
-
|
|
91
|
+
const m = /^[-*+]([ \t]+)/.exec(line.slice(marker));
|
|
92
|
+
if (!m)
|
|
93
|
+
return marker + 2;
|
|
94
|
+
let column = marker + 1;
|
|
95
|
+
for (const character of m[1]) {
|
|
96
|
+
column += character === "\t" ? 4 - column % 4 : 1;
|
|
97
|
+
}
|
|
98
|
+
return column;
|
|
95
99
|
}
|
|
96
100
|
/** Dedented span lines, trailing whitespace removed. */
|
|
97
101
|
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"}
|
|
@@ -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
|
import { unified } from "unified";
|
|
23
24
|
import remarkParse from "remark-parse";
|
package/esm/formatter/mod.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* and requirement block insertion.
|
|
7
7
|
*/
|
|
8
8
|
import type { Attribute, Diagnostic } from "../model/mod.js";
|
|
9
|
+
import { type EntryExtent } from "./prose.js";
|
|
9
10
|
import { type ProseFormatter } from "./dprint.js";
|
|
10
11
|
/**
|
|
11
12
|
* Decide whether the EARS keyword at `offset` in `line` is at sentence
|
|
@@ -76,6 +77,8 @@ export interface FormatResult {
|
|
|
76
77
|
readonly diagnostics: readonly Diagnostic[];
|
|
77
78
|
/** Whether any changes were made. */
|
|
78
79
|
readonly changed: boolean;
|
|
80
|
+
/** Output line spans (0-based, end exclusive) kept unchanged after refusal. */
|
|
81
|
+
readonly preservedRanges?: readonly EntryExtent[];
|
|
79
82
|
}
|
|
80
83
|
/**
|
|
81
84
|
* Format a Markdown string — normalize attribute blocks,
|
|
@@ -143,7 +146,7 @@ export declare function findItemEnd(lines: readonly string[], startIdx: number,
|
|
|
143
146
|
* Scans forward from the entry start to find the list item boundary,
|
|
144
147
|
* then walks backwards to find the contiguous trailing attribute block.
|
|
145
148
|
*/
|
|
146
|
-
export declare function findAttributeBlockRange(lines: readonly string[], entryStartLine: number, indent: number, itemEndFloor?: number): {
|
|
149
|
+
export declare function findAttributeBlockRange(lines: readonly string[], entryStartLine: number, indent: number, itemEndFloor?: number, preservedRanges?: readonly EntryExtent[]): {
|
|
147
150
|
start: number;
|
|
148
151
|
end: number;
|
|
149
152
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AAyBzB,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,YAAY,CAAC;AAOnE,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAGrB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D;AA4WD,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ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