flashtrace 0.9.1 → 0.9.2

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 (2) hide show
  1. package/dist/flashtrace.mjs +22 -10
  2. package/package.json +1 -1
@@ -317,13 +317,22 @@ function isParagraphLine(line) {
317
317
  }
318
318
  var isParagraphAt = (lines, inTable, j) => !inTable[j] && isParagraphLine(lines[j]);
319
319
  var isSetextHeading = (lines, inTable, titleIndex) => titleIndex + 1 < lines.length && SETEXT_UNDERLINE_RE.test(lines[titleIndex + 1]) && isParagraphAt(lines, inTable, titleIndex);
320
- function opensSetextHeading(lines, inTable, j) {
321
- if (!isParagraphAt(lines, inTable, j)) return false;
322
- let k = j;
323
- while (k + 1 < lines.length && isParagraphAt(lines, inTable, k + 1)) k++;
324
- return isSetextHeading(lines, inTable, k);
320
+ function scanSetextHeadings(lines, inTable) {
321
+ const opensHeading = new Array(lines.length).fill(false);
322
+ let j = 0;
323
+ while (j < lines.length) {
324
+ if (!isParagraphAt(lines, inTable, j)) {
325
+ j++;
326
+ continue;
327
+ }
328
+ const start = j;
329
+ while (j + 1 < lines.length && isParagraphAt(lines, inTable, j + 1)) j++;
330
+ if (isSetextHeading(lines, inTable, j)) opensHeading.fill(true, start, j + 1);
331
+ j++;
332
+ }
333
+ return opensHeading;
325
334
  }
326
- var isBoundary = (lines, inTable, j) => !inTable[j] && DEFINITION_RE.test(lines[j]) || HEADING_RE.test(lines[j]) || opensSetextHeading(lines, inTable, j);
335
+ var isBoundary = (lines, inTable, opensHeading, j) => !inTable[j] && DEFINITION_RE.test(lines[j]) || HEADING_RE.test(lines[j]) || opensHeading[j];
327
336
  function foldSetextTitle(lines, inTable, lastIndex) {
328
337
  let first = lastIndex;
329
338
  while (first > 0 && isParagraphAt(lines, inTable, first - 1)) first--;
@@ -444,10 +453,11 @@ function applyKeyword(item, keyword, entries, file, keywordLine, problems, sourc
444
453
  });
445
454
  }
446
455
  }
447
- function parseItemBody(lines, inTable, start, item, file, problems, forwards) {
456
+ function parseItemBody(lines, boundary, start, item, file, problems, forwards) {
457
+ const { inTable, opensHeading } = boundary;
448
458
  let j = start;
449
459
  let descriptionDone = false;
450
- while (j < lines.length && !isBoundary(lines, inTable, j)) {
460
+ while (j < lines.length && !isBoundary(lines, inTable, opensHeading, j)) {
451
461
  const line = lines[j];
452
462
  if (takeForward(line, file, j, forwards)) {
453
463
  j++;
@@ -483,10 +493,12 @@ function parseItemBody(lines, inTable, start, item, file, problems, forwards) {
483
493
  function parseMarkdown(file, text, problems, forwards = []) {
484
494
  const lines = text.split(/\r?\n/);
485
495
  const inTable = scanTables(lines, file, problems);
496
+ const opensHeading = scanSetextHeadings(lines, inTable);
497
+ const boundary = { inTable, opensHeading };
486
498
  const items = [];
487
499
  let i = 0;
488
500
  while (i < lines.length) {
489
- const startsHeading = opensSetextHeading(lines, inTable, i);
501
+ const startsHeading = opensHeading[i];
490
502
  if (!startsHeading && takeForward(lines[i], file, i, forwards)) {
491
503
  i++;
492
504
  continue;
@@ -507,7 +519,7 @@ function parseMarkdown(file, text, problems, forwards = []) {
507
519
  }
508
520
  const item = newItem(makeId(definition[1], definition[2], definition[3], definition[4]), "markdown", file, i + 1);
509
521
  item.title = titleAbove(lines, inTable, i);
510
- i = parseItemBody(lines, inTable, i + 1, item, file, problems, forwards);
522
+ i = parseItemBody(lines, boundary, i + 1, item, file, problems, forwards);
511
523
  items.push(item);
512
524
  }
513
525
  return items;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flashtrace",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Lightning-fast, reference-based requirement tracing that works anywhere.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {