flashtrace 0.9.0 → 0.9.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.
@@ -520,6 +520,19 @@ var TAG_RE = new RegExp(
520
520
  "g"
521
521
  );
522
522
  var FORWARD_RE = new RegExp(FORWARD_SRC, "g");
523
+ var URL_RE = /[A-Za-z][A-Za-z0-9+.-]{0,63}:\/\/[^\s"'`<>[\]]*/g;
524
+ function urlSpans(line) {
525
+ if (!line.includes("://")) return [];
526
+ return [...line.matchAll(URL_RE)].map((m) => ({ start: m.index, end: m.index + m[0].length }));
527
+ }
528
+ function markerIndex(line, marker, pos, spans) {
529
+ let idx = line.indexOf(marker, pos);
530
+ for (const span of spans) {
531
+ if (idx === -1 || idx < span.start) break;
532
+ if (idx < span.end) idx = line.indexOf(marker, span.end);
533
+ }
534
+ return idx;
535
+ }
523
536
  function activeLeaf(grammar, state) {
524
537
  if (state.region) return state.region.grammar;
525
538
  return grammar.regions ? grammar.default : grammar;
@@ -543,7 +556,7 @@ function* regionEvents(line, pos, grammar, state) {
543
556
  }
544
557
  }
545
558
  }
546
- function nextEvent(line, pos, grammar, state) {
559
+ function nextEvent(line, pos, grammar, state, spans) {
547
560
  const leaf = activeLeaf(grammar, state);
548
561
  let best = null;
549
562
  const consider = (idx, event) => {
@@ -553,10 +566,10 @@ function nextEvent(line, pos, grammar, state) {
553
566
  }
554
567
  };
555
568
  for (const marker of leaf.line) {
556
- consider(line.indexOf(marker, pos), { kind: "line", len: marker.length });
569
+ consider(markerIndex(line, marker, pos, spans), { kind: "line", len: marker.length });
557
570
  }
558
571
  for (const [open, close, nestable] of leaf.block) {
559
- consider(line.indexOf(open, pos), {
572
+ consider(markerIndex(line, open, pos, spans), {
560
573
  kind: "block",
561
574
  len: open.length,
562
575
  open,
@@ -611,6 +624,7 @@ function consumeLine(line, pos, state, exit) {
611
624
  return { text: line.slice(pos) + " ", pos: line.length, done: true };
612
625
  }
613
626
  function commentText(line, state, grammar) {
627
+ const spans = urlSpans(line);
614
628
  let comment = "";
615
629
  let pos = 0;
616
630
  while (pos < line.length) {
@@ -621,7 +635,7 @@ function commentText(line, state, grammar) {
621
635
  pos = consumed.pos;
622
636
  continue;
623
637
  }
624
- const event = nextEvent(line, pos, grammar, state);
638
+ const event = nextEvent(line, pos, grammar, state, spans);
625
639
  if (!event) break;
626
640
  pos = event.idx + event.len;
627
641
  if (event.kind === "line") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flashtrace",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Lightning-fast, reference-based requirement tracing that works anywhere.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {