@driftsys/markspec 0.12.1 → 0.13.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.
Files changed (279) hide show
  1. package/esm/ast/build.d.ts.map +1 -1
  2. package/esm/ast/build.js +19 -5
  3. package/esm/ast/equivalence.js +14 -2
  4. package/esm/ast/nodes.d.ts +15 -3
  5. package/esm/ast/nodes.d.ts.map +1 -1
  6. package/esm/compiler/inverses.d.ts.map +1 -1
  7. package/esm/compiler/inverses.js +18 -3
  8. package/esm/compiler/mod.d.ts +34 -1
  9. package/esm/compiler/mod.d.ts.map +1 -1
  10. package/esm/compiler/mod.js +112 -48
  11. package/esm/compiler/schema.d.ts +3 -2
  12. package/esm/compiler/schema.d.ts.map +1 -1
  13. package/esm/compiler/schema.js +6 -3
  14. package/esm/criteria/scenarios.d.ts +55 -0
  15. package/esm/criteria/scenarios.d.ts.map +1 -0
  16. package/esm/criteria/scenarios.js +133 -0
  17. package/esm/discovery/mod.d.ts +20 -1
  18. package/esm/discovery/mod.d.ts.map +1 -1
  19. package/esm/discovery/mod.js +105 -17
  20. package/esm/formatter/entry_body.d.ts +8 -5
  21. package/esm/formatter/entry_body.d.ts.map +1 -1
  22. package/esm/formatter/entry_body.js +12 -8
  23. package/esm/formatter/feature_file.d.ts +40 -0
  24. package/esm/formatter/feature_file.d.ts.map +1 -0
  25. package/esm/formatter/feature_file.js +88 -0
  26. package/esm/formatter/mod.d.ts +21 -2
  27. package/esm/formatter/mod.d.ts.map +1 -1
  28. package/esm/formatter/mod.js +64 -22
  29. package/esm/gates/mod.d.ts +2 -2
  30. package/esm/gates/mod.d.ts.map +1 -1
  31. package/esm/gates/mod.js +17 -2
  32. package/esm/gherkin/load.d.ts +35 -0
  33. package/esm/gherkin/load.d.ts.map +1 -0
  34. package/esm/gherkin/load.js +39 -0
  35. package/esm/gherkin/parse.d.ts +11 -0
  36. package/esm/gherkin/parse.d.ts.map +1 -0
  37. package/esm/gherkin/parse.js +311 -0
  38. package/esm/gherkin/position.d.ts +23 -0
  39. package/esm/gherkin/position.d.ts.map +1 -0
  40. package/esm/gherkin/position.js +21 -0
  41. package/esm/gherkin/procedure.d.ts +76 -0
  42. package/esm/gherkin/procedure.d.ts.map +1 -0
  43. package/esm/gherkin/procedure.js +164 -0
  44. package/esm/gherkin/project.d.ts +35 -0
  45. package/esm/gherkin/project.d.ts.map +1 -0
  46. package/esm/gherkin/project.js +64 -0
  47. package/esm/gherkin/role.d.ts +23 -0
  48. package/esm/gherkin/role.d.ts.map +1 -0
  49. package/esm/gherkin/role.js +28 -0
  50. package/esm/gherkin/types.d.ts +118 -0
  51. package/esm/gherkin/types.d.ts.map +1 -0
  52. package/esm/gherkin/types.js +12 -0
  53. package/esm/lock/acquire_compile.d.ts +12 -4
  54. package/esm/lock/acquire_compile.d.ts.map +1 -1
  55. package/esm/lock/acquire_compile.js +15 -5
  56. package/esm/lock/canonical_edges.d.ts +6 -2
  57. package/esm/lock/canonical_edges.d.ts.map +1 -1
  58. package/esm/lock/canonical_edges.js +10 -3
  59. package/esm/lock/model.d.ts +5 -0
  60. package/esm/lock/model.d.ts.map +1 -1
  61. package/esm/lock/parser.d.ts.map +1 -1
  62. package/esm/lock/parser.js +2 -0
  63. package/esm/lock/resolve.d.ts +6 -2
  64. package/esm/lock/resolve.d.ts.map +1 -1
  65. package/esm/lock/resolve.js +36 -4
  66. package/esm/lock/serializer.d.ts.map +1 -1
  67. package/esm/lock/serializer.js +7 -1
  68. package/esm/mod.d.ts +23 -6
  69. package/esm/mod.d.ts.map +1 -1
  70. package/esm/mod.js +18 -5
  71. package/esm/model/mod.d.ts +42 -1
  72. package/esm/model/mod.d.ts.map +1 -1
  73. package/esm/model/mod.js +1 -1
  74. package/esm/model/relations.d.ts +9 -0
  75. package/esm/model/relations.d.ts.map +1 -1
  76. package/esm/model/relations.js +16 -1
  77. package/esm/parser/attributes.d.ts +82 -3
  78. package/esm/parser/attributes.d.ts.map +1 -1
  79. package/esm/parser/attributes.js +199 -32
  80. package/esm/parser/body_tokens.d.ts +1 -1
  81. package/esm/parser/body_tokens.d.ts.map +1 -1
  82. package/esm/parser/body_tokens.js +49 -35
  83. package/esm/parser/feature_file.d.ts +116 -0
  84. package/esm/parser/feature_file.d.ts.map +1 -0
  85. package/esm/parser/feature_file.js +540 -0
  86. package/esm/parser/markdown.d.ts +7 -0
  87. package/esm/parser/markdown.d.ts.map +1 -1
  88. package/esm/parser/markdown.js +129 -40
  89. package/esm/parser/mod.d.ts +18 -0
  90. package/esm/parser/mod.d.ts.map +1 -1
  91. package/esm/parser/mod.js +51 -0
  92. package/esm/parser/translate.d.ts.map +1 -1
  93. package/esm/parser/translate.js +5 -0
  94. package/esm/refs/mod.d.ts +2 -1
  95. package/esm/refs/mod.d.ts.map +1 -1
  96. package/esm/refs/mod.js +12 -4
  97. package/esm/refs/split.d.ts +58 -0
  98. package/esm/refs/split.d.ts.map +1 -0
  99. package/esm/refs/split.js +137 -0
  100. package/esm/reporter/mod.d.ts +7 -0
  101. package/esm/reporter/mod.d.ts.map +1 -1
  102. package/esm/reporter/mod.js +113 -3
  103. package/esm/validator/attributes.d.ts.map +1 -1
  104. package/esm/validator/attributes.js +4 -1
  105. package/esm/validator/block_role.d.ts +40 -0
  106. package/esm/validator/block_role.d.ts.map +1 -0
  107. package/esm/validator/block_role.js +109 -0
  108. package/esm/validator/feature_ac.d.ts.map +1 -1
  109. package/esm/validator/feature_ac.js +6 -1
  110. package/esm/validator/feature_parse.d.ts +35 -0
  111. package/esm/validator/feature_parse.d.ts.map +1 -0
  112. package/esm/validator/feature_parse.js +69 -0
  113. package/esm/validator/locators.d.ts +36 -0
  114. package/esm/validator/locators.d.ts.map +1 -0
  115. package/esm/validator/locators.js +184 -0
  116. package/esm/validator/mod.d.ts +10 -1
  117. package/esm/validator/mod.d.ts.map +1 -1
  118. package/esm/validator/mod.js +38 -14
  119. package/esm/validator/normalize.d.ts.map +1 -1
  120. package/esm/validator/normalize.js +8 -3
  121. package/esm/validator/per_type_attrs.d.ts +3 -3
  122. package/esm/validator/per_type_attrs.js +3 -3
  123. package/esm/validator/pipeline.d.ts +4 -12
  124. package/esm/validator/pipeline.d.ts.map +1 -1
  125. package/esm/validator/pipeline.js +24 -5
  126. package/esm/validator/procedure.d.ts +22 -0
  127. package/esm/validator/procedure.d.ts.map +1 -0
  128. package/esm/validator/procedure.js +58 -0
  129. package/esm/validator/trace_types.d.ts.map +1 -1
  130. package/esm/validator/trace_types.js +4 -3
  131. package/esm/validator/traceability.d.ts.map +1 -1
  132. package/esm/validator/traceability.js +4 -1
  133. package/esm/validator/type_resolution.d.ts +5 -3
  134. package/esm/validator/type_resolution.d.ts.map +1 -1
  135. package/esm/validator/type_resolution.js +14 -2
  136. package/esm/validator/types.d.ts +11 -0
  137. package/esm/validator/types.d.ts.map +1 -1
  138. package/esm/validator/types.js +26 -4
  139. package/esm/validator/uxil_family.d.ts +1 -1
  140. package/package.json +3 -1
  141. package/script/ast/build.d.ts.map +1 -1
  142. package/script/ast/build.js +19 -5
  143. package/script/ast/equivalence.js +14 -2
  144. package/script/ast/nodes.d.ts +15 -3
  145. package/script/ast/nodes.d.ts.map +1 -1
  146. package/script/compiler/inverses.d.ts.map +1 -1
  147. package/script/compiler/inverses.js +18 -3
  148. package/script/compiler/mod.d.ts +34 -1
  149. package/script/compiler/mod.d.ts.map +1 -1
  150. package/script/compiler/mod.js +110 -46
  151. package/script/compiler/schema.d.ts +3 -2
  152. package/script/compiler/schema.d.ts.map +1 -1
  153. package/script/compiler/schema.js +6 -3
  154. package/script/criteria/scenarios.d.ts +55 -0
  155. package/script/criteria/scenarios.d.ts.map +1 -0
  156. package/script/criteria/scenarios.js +139 -0
  157. package/script/discovery/mod.d.ts +20 -1
  158. package/script/discovery/mod.d.ts.map +1 -1
  159. package/script/discovery/mod.js +106 -17
  160. package/script/formatter/entry_body.d.ts +8 -5
  161. package/script/formatter/entry_body.d.ts.map +1 -1
  162. package/script/formatter/entry_body.js +12 -8
  163. package/script/formatter/feature_file.d.ts +40 -0
  164. package/script/formatter/feature_file.d.ts.map +1 -0
  165. package/script/formatter/feature_file.js +92 -0
  166. package/script/formatter/mod.d.ts +21 -2
  167. package/script/formatter/mod.d.ts.map +1 -1
  168. package/script/formatter/mod.js +63 -21
  169. package/script/gates/mod.d.ts +2 -2
  170. package/script/gates/mod.d.ts.map +1 -1
  171. package/script/gates/mod.js +17 -2
  172. package/script/gherkin/load.d.ts +35 -0
  173. package/script/gherkin/load.d.ts.map +1 -0
  174. package/script/gherkin/load.js +76 -0
  175. package/script/gherkin/parse.d.ts +11 -0
  176. package/script/gherkin/parse.d.ts.map +1 -0
  177. package/script/gherkin/parse.js +314 -0
  178. package/script/gherkin/position.d.ts +23 -0
  179. package/script/gherkin/position.d.ts.map +1 -0
  180. package/script/gherkin/position.js +24 -0
  181. package/script/gherkin/procedure.d.ts +76 -0
  182. package/script/gherkin/procedure.d.ts.map +1 -0
  183. package/script/gherkin/procedure.js +169 -0
  184. package/script/gherkin/project.d.ts +35 -0
  185. package/script/gherkin/project.d.ts.map +1 -0
  186. package/script/gherkin/project.js +67 -0
  187. package/script/gherkin/role.d.ts +23 -0
  188. package/script/gherkin/role.d.ts.map +1 -0
  189. package/script/gherkin/role.js +31 -0
  190. package/script/gherkin/types.d.ts +118 -0
  191. package/script/gherkin/types.d.ts.map +1 -0
  192. package/script/gherkin/types.js +13 -0
  193. package/script/lock/acquire_compile.d.ts +12 -4
  194. package/script/lock/acquire_compile.d.ts.map +1 -1
  195. package/script/lock/acquire_compile.js +15 -5
  196. package/script/lock/canonical_edges.d.ts +6 -2
  197. package/script/lock/canonical_edges.d.ts.map +1 -1
  198. package/script/lock/canonical_edges.js +10 -3
  199. package/script/lock/model.d.ts +5 -0
  200. package/script/lock/model.d.ts.map +1 -1
  201. package/script/lock/parser.d.ts.map +1 -1
  202. package/script/lock/parser.js +2 -0
  203. package/script/lock/resolve.d.ts +6 -2
  204. package/script/lock/resolve.d.ts.map +1 -1
  205. package/script/lock/resolve.js +36 -4
  206. package/script/lock/serializer.d.ts.map +1 -1
  207. package/script/lock/serializer.js +7 -1
  208. package/script/mod.d.ts +23 -6
  209. package/script/mod.d.ts.map +1 -1
  210. package/script/mod.js +45 -6
  211. package/script/model/mod.d.ts +42 -1
  212. package/script/model/mod.d.ts.map +1 -1
  213. package/script/model/mod.js +2 -1
  214. package/script/model/relations.d.ts +9 -0
  215. package/script/model/relations.d.ts.map +1 -1
  216. package/script/model/relations.js +17 -1
  217. package/script/parser/attributes.d.ts +82 -3
  218. package/script/parser/attributes.d.ts.map +1 -1
  219. package/script/parser/attributes.js +205 -33
  220. package/script/parser/body_tokens.d.ts +1 -1
  221. package/script/parser/body_tokens.d.ts.map +1 -1
  222. package/script/parser/body_tokens.js +49 -35
  223. package/script/parser/feature_file.d.ts +116 -0
  224. package/script/parser/feature_file.d.ts.map +1 -0
  225. package/script/parser/feature_file.js +548 -0
  226. package/script/parser/markdown.d.ts +7 -0
  227. package/script/parser/markdown.d.ts.map +1 -1
  228. package/script/parser/markdown.js +128 -39
  229. package/script/parser/mod.d.ts +18 -0
  230. package/script/parser/mod.d.ts.map +1 -1
  231. package/script/parser/mod.js +52 -1
  232. package/script/parser/translate.d.ts.map +1 -1
  233. package/script/parser/translate.js +5 -0
  234. package/script/refs/mod.d.ts +2 -1
  235. package/script/refs/mod.d.ts.map +1 -1
  236. package/script/refs/mod.js +12 -4
  237. package/script/refs/split.d.ts +58 -0
  238. package/script/refs/split.d.ts.map +1 -0
  239. package/script/refs/split.js +145 -0
  240. package/script/reporter/mod.d.ts +7 -0
  241. package/script/reporter/mod.d.ts.map +1 -1
  242. package/script/reporter/mod.js +113 -3
  243. package/script/validator/attributes.d.ts.map +1 -1
  244. package/script/validator/attributes.js +4 -1
  245. package/script/validator/block_role.d.ts +40 -0
  246. package/script/validator/block_role.d.ts.map +1 -0
  247. package/script/validator/block_role.js +112 -0
  248. package/script/validator/feature_ac.d.ts.map +1 -1
  249. package/script/validator/feature_ac.js +6 -1
  250. package/script/validator/feature_parse.d.ts +35 -0
  251. package/script/validator/feature_parse.d.ts.map +1 -0
  252. package/script/validator/feature_parse.js +73 -0
  253. package/script/validator/locators.d.ts +36 -0
  254. package/script/validator/locators.d.ts.map +1 -0
  255. package/script/validator/locators.js +188 -0
  256. package/script/validator/mod.d.ts +10 -1
  257. package/script/validator/mod.d.ts.map +1 -1
  258. package/script/validator/mod.js +38 -14
  259. package/script/validator/normalize.d.ts.map +1 -1
  260. package/script/validator/normalize.js +8 -3
  261. package/script/validator/per_type_attrs.d.ts +3 -3
  262. package/script/validator/per_type_attrs.js +3 -3
  263. package/script/validator/pipeline.d.ts +4 -12
  264. package/script/validator/pipeline.d.ts.map +1 -1
  265. package/script/validator/pipeline.js +23 -5
  266. package/script/validator/procedure.d.ts +22 -0
  267. package/script/validator/procedure.d.ts.map +1 -0
  268. package/script/validator/procedure.js +61 -0
  269. package/script/validator/trace_types.d.ts.map +1 -1
  270. package/script/validator/trace_types.js +4 -3
  271. package/script/validator/traceability.d.ts.map +1 -1
  272. package/script/validator/traceability.js +4 -1
  273. package/script/validator/type_resolution.d.ts +5 -3
  274. package/script/validator/type_resolution.d.ts.map +1 -1
  275. package/script/validator/type_resolution.js +14 -2
  276. package/script/validator/types.d.ts +11 -0
  277. package/script/validator/types.d.ts.map +1 -1
  278. package/script/validator/types.js +27 -4
  279. package/script/validator/uxil_family.d.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/parser/markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAa,UAAU,EAAE,KAAK,EAAc,MAAM,iBAAiB,CAAC;AAsBhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAsB7C,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;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E,oBAAoB,GAC7B,mBAAmB,CAiDrB"}
@@ -17,18 +17,8 @@ const code_regions_js_1 = require("./code_regions.js");
17
17
  const line_endings_js_1 = require("../util/line_endings.js");
18
18
  const translate_js_1 = require("./translate.js");
19
19
  const mod_js_2 = require("../typl/mod.js");
20
- /**
21
- * Canonical set of trailer attribute keys the core recognizes: the union of
22
- * every authored universal attribute, every core trace relation, and the
23
- * extra inverse lock key (`Verified-by`). Universal keys with
24
- * `origin: "generated"` (`Contains`, `Caused`, ...) are left out: the compiler
25
- * computes them and authors never write them (#706). MSL-P020 (misplaced
26
- * trailer) fires only when a body line's key is in this set; any other
27
- * capitalized `Word:` lead-in (`Note:`, `Example:`, `Assumption:`) is prose,
28
- * not a misplaced trailer (#654).
29
- */
30
- const RECOGNIZED_TRAILER_KEYS = new Set([
31
- ...mod_js_1.UNIVERSAL_ATTRIBUTE_KEYS.filter((key) => (0, mod_js_1.attributeSpec)(key)?.origin !== "generated"),
20
+ /** Keys of the core trace relations, for the MSL-P020 warning. */
21
+ const TRACE_RELATION_KEYS = new Set([
32
22
  ...mod_js_1.CORE_RELATIONS.map((r) => r.attr),
33
23
  ...mod_js_1.LOCK_EXTRA_INVERSE_KEYS,
34
24
  ]);
@@ -110,7 +100,7 @@ function parseMarkdown(markdown, options) {
110
100
  if (list.ordered)
111
101
  continue;
112
102
  for (const item of list.children) {
113
- const entry = extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, !!options?.lineMap);
103
+ const entry = extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, !!options?.lineMap, options?.allowTitleOnly === true);
114
104
  if (entry)
115
105
  entries.push(entry);
116
106
  }
@@ -151,7 +141,7 @@ function detectReferencesDocument(_file, explicit) {
151
141
  * Returns undefined if the list item is not an entry block.
152
142
  * Diagnostics (e.g., deprecation warnings) are pushed into the accumulator.
153
143
  */
154
- function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, _hasLineMap = false) {
144
+ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, _hasLineMap = false, allowTitleOnly = false) {
155
145
  // Task list items (remark-gfm sets checked to true/false) are not entries.
156
146
  if (item.checked != null)
157
147
  return undefined;
@@ -259,19 +249,40 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
259
249
  }
260
250
  // Extract body content and attributes.
261
251
  const bodyContent = extractBodyContent(item, markdownLines);
262
- const [body, attrLines] = (0, attributes_js_1.splitBodyAndAttributes)(bodyContent);
252
+ const [rawBody, attrLines] = (0, attributes_js_1.splitBodyAndAttributes)(bodyContent);
253
+ const body = rawBody.trimStart();
263
254
  const attributes = (0, attributes_js_1.parseAttributes)(attrLines);
264
255
  const { blocks: bodyAst, tree: mdastTree } = (0, build_js_1.buildBodyAstWithTree)(body);
265
256
  const entryLine = item.position?.start.line ?? 1;
266
- // MSL-P020: trailers block is not the final indented code block.
267
- // Detect `Key: Value` lines in the body that likely should be trailers
268
- // but are not at the final position (body content follows them). Only lines
269
- // whose key is a recognized trailer attribute count — see
270
- // RECOGNIZED_TRAILER_KEYS — so ordinary prose (`Note:`, `Example:`) and
271
- // caption lead-ins (`Figure:`, `Table:`) are left as legitimate body content.
257
+ // MSL-P020: a body line that would carry identity or a trace link.
258
+ // Only `Id:` and the core trace relation keys count. Other recognized
259
+ // keys (`Rationale:`, `Labels:`, `Type:`) and any other capitalized
260
+ // lead-in (`Note:`, `Example:`) start ordinary body prose: such a line
261
+ // keeps its text in the body, and `markspec fmt` cannot change it, so
262
+ // an error there could never be cleared (#654, #916).
263
+ //
264
+ // - Error: an `Id:` or trace-relation line with other content after it
265
+ // (body content or the trailer block). The trailer is not at the final
266
+ // position, so the identity or the link is lost. A trailing run that
267
+ // holds an `Id:` line is always the trailer (findTrailerStart), so an
268
+ // `Id:` line never reaches the warning case below.
269
+ // - Warning: a trace-relation line in the trailing run of `Key: Value`
270
+ // lines of an entry with no trailer. The run was not accepted as the
271
+ // trailer (no blank line above it, or a key outside the core set), so
272
+ // the line is body text and does not create a trace link.
272
273
  if (body.length > 0) {
273
274
  const bodyLines = body.split("\n");
274
275
  const fencedLines = (0, code_regions_js_1.parseCodeRegions)((0, line_endings_js_1.normalizeLineEndings)(body), mdastTree).fencedLines;
276
+ // Start of the trailing run of `Key: Value` lines (blank lines skipped
277
+ // at the end only).
278
+ let tailStart = bodyLines.length;
279
+ while (tailStart > 0 && bodyLines[tailStart - 1].trim() === "") {
280
+ tailStart--;
281
+ }
282
+ while (tailStart > 0 && !fencedLines.has(tailStart - 1) &&
283
+ attributes_js_1.ATTR_LINE_RE.test(bodyLines[tailStart - 1].trim()))
284
+ tailStart--;
285
+ let warned = false;
275
286
  for (let i = 0; i < bodyLines.length; i++) {
276
287
  // Reuse the LF-normalized body tree: examples cannot be misplaced trailers.
277
288
  if (fencedLines.has(i))
@@ -279,24 +290,49 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
279
290
  const trimmed = bodyLines[i].trim();
280
291
  if (!attributes_js_1.ATTR_LINE_RE.test(trimmed))
281
292
  continue;
282
- // Only a RECOGNIZED trailer key signals a genuinely misplaced trailer.
283
- // A body paragraph starting with any other capitalized word + colon
284
- // (`Note:`, `Example:`, `Assumption:`) is prose, not a trailer (#654).
285
- const keyMatch = trimmed.match(/^([A-Z][A-Za-z-]*):/);
286
- if (!keyMatch || !RECOGNIZED_TRAILER_KEYS.has(keyMatch[1]))
293
+ const key = trimmed.match(/^([A-Z][A-Za-z-]*):/)?.[1];
294
+ if (key === undefined)
287
295
  continue;
288
- // Found a misplaced trailer-like line in the body — non-final position
289
- diagnostics.push({
290
- code: "MSL-P020",
291
- severity: "error",
292
- message: `${displayId}: trailers block is not the final indented code ` +
293
- `block of the entry -- content appears after trailer-like ` +
294
- `lines (spec section 4.1)`,
295
- location: { file, line: entryLine, column: 1 },
296
- });
297
- break; // One diagnostic per entry is sufficient
296
+ if (key !== mod_js_1.IDENTITY_KEY && !TRACE_RELATION_KEYS.has(key))
297
+ continue;
298
+ if (i < tailStart || attrLines.length > 0) {
299
+ diagnostics.push({
300
+ code: "MSL-P020",
301
+ severity: "error",
302
+ message: `${displayId}: trailers block is not the final indented code ` +
303
+ `block of the entry -- content appears after trailer-like ` +
304
+ `lines (spec section 4.1)`,
305
+ location: { file, line: entryLine, column: 1 },
306
+ });
307
+ break; // One diagnostic per entry is sufficient
308
+ }
309
+ if (!warned) {
310
+ warned = true;
311
+ diagnostics.push({
312
+ code: "MSL-P020",
313
+ severity: "warning",
314
+ message: `${displayId}: '${key}:' line is read as body ` +
315
+ `text, not as a trailer; to make it a trace link, put the ` +
316
+ `trailer in an indented block after a blank line ` +
317
+ `(spec section 4.1)`,
318
+ location: { file, line: entryLine, column: 1 },
319
+ });
320
+ }
298
321
  }
299
322
  }
323
+ // MSL-P020 (warning): the trailer is an `Id:` run directly under prose,
324
+ // with no blank line above it. It is still read as the trailer, so the entry keeps its
325
+ // identity, but it is not in the canonical layout (#916).
326
+ if ((0, attributes_js_1.isTrailerUnderProse)(bodyContent.split("\n"))) {
327
+ diagnostics.push({
328
+ code: "MSL-P020",
329
+ severity: "warning",
330
+ message: `${displayId}: trailers block is not separated from the ` +
331
+ `body by a blank line; run 'markspec fmt' to ` +
332
+ `move it to the canonical layout (spec section 4.1)`,
333
+ location: { file, line: entryLine, column: 1 },
334
+ });
335
+ }
300
336
  // MSL-P021 / MSL-P022: validate trailer lines for syntax correctness.
301
337
  // The trailer block is the final indented code block. Lines within it
302
338
  // should all match `Key: Value` syntax. We check both the parsed
@@ -316,8 +352,57 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
316
352
  const firstNonBlank = (markdownLines[line - 1] ?? "").search(/\S/);
317
353
  return { file, line, column: firstNonBlank >= 0 ? firstNonBlank + 1 : 1 };
318
354
  };
355
+ // MSL-P023: a trailer with a line indented less than 4 columns past the
356
+ // list-item content (git style) is accepted but not canonical in
357
+ // Markdown. Every trailer line is checked, tab-aware, so a block whose
358
+ // later lines are not indented is reported too: `markspec fmt` rewrites
359
+ // it. The warning points at the trailer's first line. The legacy
360
+ // trailing-backslash form has its own deprecation warning, so it is
361
+ // skipped. A run directly under prose is reported as MSL-P020 above, so
362
+ // at most one of the two warnings fires for a block.
363
+ const contentLines = bodyContent.split("\n");
364
+ if (attrLines.length > 0 &&
365
+ !attrLines.some((line) => line.trimEnd().endsWith("\\")) &&
366
+ !(0, attributes_js_1.isTrailerUnderProse)(contentLines)) {
367
+ const trailerIndex = (0, attributes_js_1.findTrailerStart)(contentLines);
368
+ const indent = itemContentIndent(item);
369
+ let notIndented = false;
370
+ let hasContinuation = false;
371
+ for (let i = trailerIndex; i < contentLines.length; i++) {
372
+ const rawLine = markdownLines[trailerLineLocation(i).line - 1] ?? "";
373
+ if (rawLine.trim() === "")
374
+ continue;
375
+ if ((0, attributes_js_1.leadingColumns)(rawLine) - indent < 4)
376
+ notIndented = true;
377
+ if (!attributes_js_1.ATTR_LINE_RE.test(rawLine.trim()))
378
+ hasContinuation = true;
379
+ }
380
+ if (notIndented) {
381
+ // fmt and the quick fix leave a trailer with a continuation line
382
+ // (MSL-P021) unchanged, so the hint to run fmt applies only without
383
+ // one.
384
+ const hint = hasContinuation
385
+ ? "fix the MSL-P021 continuation line by hand, then indent the trailer"
386
+ : "run `markspec fmt` to indent the trailer";
387
+ diagnostics.push({
388
+ code: "MSL-P023",
389
+ severity: "warning",
390
+ message: `${displayId}: a trailer line is not indented; ${hint} ` +
391
+ "(spec section 1.3)",
392
+ location: trailerLineLocation(trailerIndex),
393
+ });
394
+ }
395
+ }
319
396
  // `attrLines` is the contiguous, blank-free tail of `bodyContent`.
320
397
  const attrContentStart = bodyContent.split("\n").length - attrLines.length;
398
+ // File line of each parsed attribute. `parseAttributes` keeps one
399
+ // attribute per trailer line and skips blank and empty-valued lines.
400
+ const attributeLines = [];
401
+ for (const [attrIndex, rawLine] of attrLines.entries()) {
402
+ if ((0, attributes_js_1.parseAttributes)([rawLine]).length === 1) {
403
+ attributeLines.push(trailerLineLocation(attrContentStart + attrIndex).line);
404
+ }
405
+ }
321
406
  // Check lines that DID end up in attrLines but might have key issues
322
407
  for (const [attrIndex, rawLine] of attrLines.entries()) {
323
408
  const trailerLocation = trailerLineLocation(attrContentStart + attrIndex);
@@ -402,7 +487,7 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
402
487
  // whitespace and the punctuation `.`, `/`, `,`, `'`, `"` into
403
488
  // hyphens, trimming hyphens at both ends, and checking the recognized
404
489
  // key vocabulary.
405
- const typoOfKnownKey = RECOGNIZED_TRAILER_KEYS.has(key.replace(/[\s./,'"]+/g, "-").replace(/^-+|-+$/g, ""));
490
+ const typoOfKnownKey = attributes_js_1.RECOGNIZED_TRAILER_KEYS.has(key.replace(/[\s./,'"]+/g, "-").replace(/^-+|-+$/g, ""));
406
491
  // A time (`10:30`), an abbreviation (`e.g.:`), a version (`v2.0:`)
407
492
  // or a word pair (`and/or:`) is prose. The 80-column wrap of the
408
493
  // formatter can put one at the start of the last body line. A
@@ -497,8 +582,9 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
497
582
  // Body requirement: identified entries require a body; referenced entries
498
583
  // may omit it. If there's only one child (the title paragraph), admit
499
584
  // only referenced entries.
500
- if (shape !== "Reference" && item.children.length < 2)
585
+ if (shape !== "Reference" && item.children.length < 2 && !allowTitleOnly) {
501
586
  return undefined;
587
+ }
502
588
  // Source location
503
589
  const line = item.position?.start.line ?? 1;
504
590
  const column = item.position?.start.column ?? 1;
@@ -543,6 +629,7 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
543
629
  location: entryLocation,
544
630
  bodyStartLine,
545
631
  ...(endLine !== undefined ? { endLine } : {}),
632
+ ...(attributeLines.length > 0 ? { attributeLines } : {}),
546
633
  source: { kind: "markdown" },
547
634
  properties: { file: { path: file, line, column } },
548
635
  bodyTokens,
@@ -588,5 +675,7 @@ function extractBodyContent(item, lines) {
588
675
  return line.slice(indent);
589
676
  return line;
590
677
  });
591
- return stripped.join("\n").trim();
678
+ // Keep the first line's own indent: it marks an indented trailer in a
679
+ // body-less entry, and `markspec fmt` sees the same text (#916).
680
+ return stripped.join("\n").trimEnd();
592
681
  }
@@ -10,6 +10,7 @@
10
10
  * - source: doc comment extraction from Rust, Kotlin, C, C++, Java
11
11
  */
12
12
  import type { Caption, Diagnostic, Document, Entry } from "../model/mod.js";
13
+ import { type GherkinApi } from "../gherkin/load.js";
13
14
  import { type DetectCaptionsOptions } from "./captions.js";
14
15
  export type { DetectCaptionsOptions } from "./captions.js";
15
16
  export { detectDirectives } from "./directives.js";
@@ -56,6 +57,21 @@ export interface ParseFileResult {
56
57
  */
57
58
  readonly diagnostics: readonly Diagnostic[];
58
59
  }
60
+ /**
61
+ * A fenced code block whose info string starts with the word `gherkin` or
62
+ * `feature`, followed by whitespace or the end of the line (so
63
+ * `gherkin-json` does not match). The fence has three or more backticks or
64
+ * tildes. Before the fence, the line may hold spaces, tabs, blockquote
65
+ * markers and doc-comment prefixes (`>`, `///`, `//!`, ` *`, `#`), and list
66
+ * markers (`-`, `*`, `+`, `1.`, `1)`) followed by a space or tab. The
67
+ * prefix holds no newline, so the match never spans lines, and each
68
+ * prefix character matches only one alternative, so the scan stays linear.
69
+ *
70
+ * @internal Exported for tests.
71
+ */
72
+ export declare const GHERKIN_FENCE_RE: RegExp;
73
+ /** Loads the Gherkin parser; replaced in tests. */
74
+ type GherkinLoader = () => Promise<GherkinApi>;
59
75
  /**
60
76
  * Parse a file and return entries, annotation links, and (for Markdown
61
77
  * files) a Document with front-matter attributes.
@@ -66,6 +82,8 @@ export interface ParseFileResult {
66
82
  */
67
83
  export declare function parseFile(content: string, options: {
68
84
  readonly file: string;
85
+ /** @internal Replaces the Gherkin parser loader in tests. */
86
+ readonly gherkinLoader?: GherkinLoader;
69
87
  }): Promise<ParseFileResult>;
70
88
  /**
71
89
  * Detect table and figure captions in a Markdown string.
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parser/mod.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AAO,EAAE,MAAM,EACf,OAAO,EAAE;IACP,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;CACxC,GACA,OAAO,CAAC,eAAe,CAAC,CAwF1B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,EAAE,CAEX"}
@@ -11,12 +11,14 @@
11
11
  * - source: doc comment extraction from Rust, Kotlin, C, C++, Java
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.languageIdForExtension = exports.LANGUAGE_SPECS = exports.buildBlockLineMap = exports.loadGrammar = exports.isSupportedExtension = exports.wrapAsListItem = exports.stripLineCommentPrefix = exports.stripBlockCommentPrefix = exports.parseSource = exports.detectInlineRefs = exports.extractFrontMatter = exports.detectDirectives = void 0;
14
+ exports.GHERKIN_FENCE_RE = exports.languageIdForExtension = exports.LANGUAGE_SPECS = exports.buildBlockLineMap = exports.loadGrammar = exports.isSupportedExtension = exports.wrapAsListItem = exports.stripLineCommentPrefix = exports.stripBlockCommentPrefix = exports.parseSource = exports.detectInlineRefs = exports.extractFrontMatter = exports.detectDirectives = void 0;
15
15
  exports.parse = parse;
16
16
  exports.parseFile = parseFile;
17
17
  exports.detectCaptions = detectCaptions;
18
18
  const path_1 = require("@std/path");
19
19
  const line_endings_js_1 = require("../util/line_endings.js");
20
+ const load_js_1 = require("../gherkin/load.js");
21
+ const feature_file_js_1 = require("./feature_file.js");
20
22
  const markdown_js_1 = require("./markdown.js");
21
23
  const grammars_js_1 = require("./grammars.js");
22
24
  const source_js_1 = require("./source.js");
@@ -70,6 +72,19 @@ function isReferencesDocument(file) {
70
72
  // same as POSIX.
71
73
  return /[\\/]references[\\/]/.test(file);
72
74
  }
75
+ /**
76
+ * A fenced code block whose info string starts with the word `gherkin` or
77
+ * `feature`, followed by whitespace or the end of the line (so
78
+ * `gherkin-json` does not match). The fence has three or more backticks or
79
+ * tildes. Before the fence, the line may hold spaces, tabs, blockquote
80
+ * markers and doc-comment prefixes (`>`, `///`, `//!`, ` *`, `#`), and list
81
+ * markers (`-`, `*`, `+`, `1.`, `1)`) followed by a space or tab. The
82
+ * prefix holds no newline, so the match never spans lines, and each
83
+ * prefix character matches only one alternative, so the scan stays linear.
84
+ *
85
+ * @internal Exported for tests.
86
+ */
87
+ exports.GHERKIN_FENCE_RE = /^(?:[ \t/*#!>]|[-+][ \t]|\d{1,9}[.)][ \t])*(`{3,}|~{3,})[ \t]*(gherkin|feature)(?=[ \t]|$)/m;
73
88
  /**
74
89
  * Parse a file and return entries, annotation links, and (for Markdown
75
90
  * files) a Document with front-matter attributes.
@@ -80,7 +95,43 @@ function isReferencesDocument(file) {
80
95
  */
81
96
  async function parseFile(content, options) {
82
97
  const ext = (0, path_1.extname)(options.file);
98
+ const lowerExt = ext.toLowerCase();
83
99
  const normalised = (0, line_endings_js_1.normalizeLineEndings)(content);
100
+ // A `.feature` file always needs the parser (ADR-038): entries come from
101
+ // its `# [ID]` header comments. A load failure gives no entries and one
102
+ // MSL-B062 when the file has a header line, and never throws.
103
+ if (lowerExt === ".feature") {
104
+ let api;
105
+ try {
106
+ api = await (options.gherkinLoader ?? load_js_1.loadGherkin)();
107
+ }
108
+ catch (err) {
109
+ const diagnostics = (0, feature_file_js_1.hasFeatureHeaderLine)(normalised)
110
+ ? [{
111
+ code: "MSL-B062",
112
+ severity: "warning",
113
+ message: `Gherkin file not parsed: the Gherkin parser failed to ` +
114
+ `load (${err instanceof Error ? err.message : String(err)})`,
115
+ location: { file: options.file, line: 1, column: 1 },
116
+ }]
117
+ : [];
118
+ return { entries: [], diagnostics };
119
+ }
120
+ return (0, feature_file_js_1.parseFeatureFile)(normalised, { file: options.file, api });
121
+ }
122
+ // Load the Gherkin parser before the synchronous parse, and only when the
123
+ // text holds a gherkin or feature fence (the load is cached). A failed
124
+ // load is not fatal: parsing continues without the Gherkin AST, and the
125
+ // criteria come from the line scanner. The loader does not cache the
126
+ // failure, so a later file tries again.
127
+ if (exports.GHERKIN_FENCE_RE.test(normalised)) {
128
+ try {
129
+ await (options.gherkinLoader ?? load_js_1.loadGherkin)();
130
+ }
131
+ catch {
132
+ // Continue without the parser (ADR-038 Decision 4).
133
+ }
134
+ }
84
135
  if ((0, grammars_js_1.isSupportedExtension)(ext)) {
85
136
  const language = await (0, grammars_js_1.loadGrammar)(ext);
86
137
  const languageId = (0, grammars_js_1.languageIdForExtension)(ext);
@@ -1 +1 @@
1
- {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/parser/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,iBAAiB,CAAC;AAE7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,OAAO,GACf,KAAK,EAAE,CAyDT"}
1
+ {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/parser/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,iBAAiB,CAAC;AAE7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,OAAO,GACf,KAAK,EAAE,CAgET"}
@@ -45,6 +45,11 @@ function translateEntryLocations(entries, lineMap) {
45
45
  endLine: lineMap.translate(entry.endLine, 1)?.line ?? entry.endLine,
46
46
  }
47
47
  : {}),
48
+ ...(entry.attributeLines !== undefined
49
+ ? {
50
+ attributeLines: entry.attributeLines.map((line) => lineMap.translate(line, 1)?.line ?? line),
51
+ }
52
+ : {}),
48
53
  bodyAst: entry.bodyAst
49
54
  ? entry.bodyAst.map((block) => translateBlock(block, lineMap, fallbackPoint, warn))
50
55
  : entry.bodyAst,
@@ -9,7 +9,8 @@
9
9
  *
10
10
  * Architecture: composed AROUND the pure `core/formatter` by the `markspec fmt`
11
11
  * CLI. It MUST NOT import `core/formatter`, and `core/formatter` MUST NOT import
12
- * it (WASM-migration purity guard, AGENTS.md).
12
+ * this module (WASM-migration purity guard, AGENTS.md). The formatter may
13
+ * import only the pure leaf `core/refs/split.ts` (ADR-026 D6).
13
14
  */
14
15
  import type { Entry } from "../model/mod.js";
15
16
  import type { LockEdge } from "../lock/mod.js";
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAGnD,CAAC;AAEH,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CAajE;AAcD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,eAAe,GAAE,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACtE,GACH;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAwGtC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAGnD,CAAC;AAEH,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CAajE;AAmBD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,eAAe,GAAE,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACtE,GACH;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAwGtC"}
@@ -10,7 +10,8 @@
10
10
  *
11
11
  * Architecture: composed AROUND the pure `core/formatter` by the `markspec fmt`
12
12
  * CLI. It MUST NOT import `core/formatter`, and `core/formatter` MUST NOT import
13
- * it (WASM-migration purity guard, AGENTS.md).
13
+ * this module (WASM-migration purity guard, AGENTS.md). The formatter may
14
+ * import only the pure leaf `core/refs/split.ts` (ADR-026 D6).
14
15
  */
15
16
  Object.defineProperty(exports, "__esModule", { value: true });
16
17
  exports.TRACE_ATTRIBUTE_KEYS = void 0;
@@ -54,8 +55,13 @@ const TRACE_TRAILER_RE = /^(\s{4,})([A-Z][A-Za-z-]*)(\s*:\s*)(.*)$/;
54
55
  * non-empty value-rest (no `Key:` — that sat on the first physical line).
55
56
  */
56
57
  const CONTINUATION_LINE_RE = /^(\s+)(\S.*)$/;
57
- /** Token splitter that preserves separators between value tokens. */
58
- const VALUE_TOKEN_RE = /[^\s,]+/g;
58
+ /**
59
+ * Token splitter that preserves separators between value tokens. The first
60
+ * alternative matches a closed scenario locator after whitespace
61
+ * (`STK_1 [AC one]`, #915, same grammar as `refs/split.ts`); a locator is
62
+ * kept verbatim, so only the target before it is rewritten.
63
+ */
64
+ const VALUE_TOKEN_RE = /(\s\[(?:\\[\s\S]|[^\]\\])+\])|[^\s,]+/g;
59
65
  /**
60
66
  * Rewrite trace-attribute values in `content` per the canonicalise/heal rules.
61
67
  * `entries` MUST be the parse of `content` (used to map each trailer line to its
@@ -163,7 +169,9 @@ function canonicalizeRefs(content, entries, index, ledger, preservedRanges = [])
163
169
  function rewriteValuePreservingContinuation(value, sourceUlid, relation, index, ledgerByKey) {
164
170
  const hasBackslash = value.endsWith("\\");
165
171
  const core = hasBackslash ? value.slice(0, -1) : value;
166
- const rewritten = core.replace(VALUE_TOKEN_RE, (token) => rewriteToken(token, sourceUlid, relation, index, ledgerByKey));
172
+ const rewritten = core.replace(VALUE_TOKEN_RE, (token, locator) => locator !== undefined
173
+ ? token
174
+ : rewriteToken(token, sourceUlid, relation, index, ledgerByKey));
167
175
  return hasBackslash ? `${rewritten}\\` : rewritten;
168
176
  }
169
177
  function rewriteToken(token, sourceUlid, relation, index, ledgerByKey) {
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @module refs/split
3
+ *
4
+ * Bracket-aware splitting of trace attribute values. A value is
5
+ * `target [ 1*WSP "[" locator "]" ]`. A locator can contain commas, so a
6
+ * plain split on commas is wrong for it. The escapes `\]` and `\\` are
7
+ * valid inside a locator only; any other backslash sequence (such as `\x`)
8
+ * is kept as written. A locator must follow whitespace after the target,
9
+ * so `A[x]` has no locator. A value without a closed locator is read
10
+ * exactly as before scenario locators existed.
11
+ */
12
+ /** A parsed trace value. */
13
+ export interface ParsedTraceValue {
14
+ /** The referenced entry or reference identifier. */
15
+ readonly target: string;
16
+ /** The locator after {@linkcode normalizeLocator} and unescaping. */
17
+ readonly locator?: string;
18
+ /** The locator text exactly as authored between the brackets. */
19
+ readonly locatorRaw?: string;
20
+ }
21
+ /**
22
+ * Normalize locator text for comparison: Unicode NFC, trim, and collapse
23
+ * each whitespace run to one space.
24
+ */
25
+ export declare function normalizeLocator(text: string): string;
26
+ /**
27
+ * Split a trace attribute value into its parts. When at least one part has
28
+ * a closed bracket locator after whitespace, commas inside a locator do not
29
+ * split. Otherwise the value is split on every comma, exactly as before
30
+ * scenario locators existed, so an unterminated `[` does not change how a
31
+ * value is read. Parts are trimmed and empty parts are dropped.
32
+ */
33
+ export declare function splitTraceValues(value: string): string[];
34
+ /**
35
+ * Parse one value from {@linkcode splitTraceValues} into target and
36
+ * optional locator. A value without a closed locator after whitespace is
37
+ * kept whole as the target, as before scenario locators existed.
38
+ */
39
+ export declare function parseTraceValue(raw: string): ParsedTraceValue;
40
+ /**
41
+ * `true` when a trace value has a `[` after whitespace that no unescaped
42
+ * `]` closes. Such a value has no locator.
43
+ */
44
+ export declare function isUnterminatedLocator(raw: string): boolean;
45
+ /**
46
+ * The target of a trace value for existence and value-type checks: the
47
+ * target before a closed bracket locator, else the trimmed value as
48
+ * written.
49
+ */
50
+ export declare function traceTarget(raw: string): string;
51
+ /**
52
+ * The tokens of a trace value that can name another entry, for reference
53
+ * scans (find references, dependent counts). A closed locator is dropped,
54
+ * so an ID written inside a locator is not a reference. Any other part is
55
+ * split on whitespace and commas, as before scenario locators existed.
56
+ */
57
+ export declare function referenceTokens(value: string): string[];
58
+ //# sourceMappingURL=split.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../src/refs/split.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,4BAA4B;AAC5B,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAKxD;AAqCD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAU7D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAa1D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAWvD"}