flashtrace 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flashtrace.mjs +33 -0
- package/package.json +1 -1
package/dist/flashtrace.mjs
CHANGED
|
@@ -296,6 +296,7 @@ var DEF_RE = new RegExp(String.raw`^\s*\`${ID_SRC}\`\s*$`);
|
|
|
296
296
|
var HEADING_RE = /^(#{1,6})\s+(\S(?:.*\S)?)\s*$/;
|
|
297
297
|
var KEYWORD_RE = /^(Needs|Covers|Tags):\s*((?:\S.*)?)$/;
|
|
298
298
|
var BULLET_RE = /^\s*[-*+]\s+(\S(?:.*\S)?)\s*$/;
|
|
299
|
+
var DELIM_CELL_RE = /^:?-+:?$/;
|
|
299
300
|
var FORWARD_LINE_RE = new RegExp(String.raw`^\s*(\`?)${FORWARD_SRC}\1\s*$`);
|
|
300
301
|
var isBoundary = (l) => DEF_RE.test(l) || HEADING_RE.test(l);
|
|
301
302
|
function takeForward(line, file, n, forwards) {
|
|
@@ -325,6 +326,34 @@ function keywordEntries(lines, j, inline) {
|
|
|
325
326
|
}
|
|
326
327
|
return { entries, j };
|
|
327
328
|
}
|
|
329
|
+
function rowCells(line) {
|
|
330
|
+
let s = line.trim();
|
|
331
|
+
if (!s.includes("|")) return null;
|
|
332
|
+
if (s.startsWith("|")) s = s.slice(1);
|
|
333
|
+
if (s.endsWith("|")) s = s.slice(0, -1);
|
|
334
|
+
return s.split("|").map((c) => c.trim());
|
|
335
|
+
}
|
|
336
|
+
function takeKeywordTable(lines, j, item, file, problems) {
|
|
337
|
+
const header = rowCells(lines[j]);
|
|
338
|
+
if (!header) return null;
|
|
339
|
+
const columns = [];
|
|
340
|
+
header.forEach((cell, col) => {
|
|
341
|
+
if (cell === "Needs" || cell === "Covers" || cell === "Tags") columns.push([col, cell]);
|
|
342
|
+
});
|
|
343
|
+
if (columns.length === 0) return null;
|
|
344
|
+
const delim = j + 1 < lines.length ? rowCells(lines[j + 1]) : null;
|
|
345
|
+
if (delim?.length !== header.length || !delim.every((c) => DELIM_CELL_RE.test(c))) return null;
|
|
346
|
+
j++;
|
|
347
|
+
while (j + 1 < lines.length && !isBoundary(lines[j + 1])) {
|
|
348
|
+
const cells = rowCells(lines[j + 1]);
|
|
349
|
+
if (!cells) break;
|
|
350
|
+
j++;
|
|
351
|
+
for (const [col, keyword] of columns) {
|
|
352
|
+
if (cells[col]) applyKeyword(item, keyword, [cells[col]], file, j + 1, problems);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return j;
|
|
356
|
+
}
|
|
328
357
|
function applyKeyword(item, keyword, entries, file, kwLine, problems) {
|
|
329
358
|
if (keyword === "Tags") {
|
|
330
359
|
item.tags.push(...entries);
|
|
@@ -353,11 +382,15 @@ function parseItemBody(lines, start, item, file, problems, forwards) {
|
|
|
353
382
|
continue;
|
|
354
383
|
}
|
|
355
384
|
const kw = line.match(KEYWORD_RE);
|
|
385
|
+
const tableEnd = kw ? null : takeKeywordTable(lines, j, item, file, problems);
|
|
356
386
|
if (kw) {
|
|
357
387
|
descDone = true;
|
|
358
388
|
const collected = keywordEntries(lines, j, kw[2]);
|
|
359
389
|
applyKeyword(item, kw[1], collected.entries, file, j + 1, problems);
|
|
360
390
|
j = collected.j;
|
|
391
|
+
} else if (tableEnd !== null) {
|
|
392
|
+
descDone = true;
|
|
393
|
+
j = tableEnd;
|
|
361
394
|
} else if (line.trim() === "") {
|
|
362
395
|
if (item.description.length > 0) descDone = true;
|
|
363
396
|
} else if (!descDone) {
|