main.py:8` or
+ ``. The attribute does not change
+ how the page renders. It is how the script tells a deliberate choice from a
+ reference the run forgot to link.
The script's count needs both the `tr` and the `sed`. A `.filename` label
reads `class="filename">path:line` when bare and
@@ -87,11 +96,13 @@ that mistake now fails instead of passing.
`tr` the opening tag is never stripped and the same reference goes uncounted.
Either way `links` ends up exceeding `refs` on a page where everything worked.
- The mismatch scan proves nothing on its own: with no links on
- the page it finds nothing and reports success, which is exactly when the
- feature is most broken. So compare the counts first. `links` should equal
- `refs` minus the references you deliberately left bare, and you should be able
- to name every one of those and say which of the two reasons applies.
+ The count takes a `` span or `.filename` label that starts with
+ `path.ext:line`. A `host:port` such as `example.com:8080` has the same shape,
+ so the script drops one whose extension is a common top-level domain.
+
+ The sha check alone proves nothing: with no links on the page it finds
+ nothing and reports success, which is exactly when the feature is most
+ broken. The count comparison is what catches that case.
- No `file:line` reference shortens its path with `...`. The script fails on
`.../` inside a `.filename` label or a `` span, because a link cannot
diff --git a/skills/explain-diff-html/scripts/validate-output.sh b/skills/explain-diff-html/scripts/validate-output.sh
index 1ff902f..94b4dad 100644
--- a/skills/explain-diff-html/scripts/validate-output.sh
+++ b/skills/explain-diff-html/scripts/validate-output.sh
@@ -29,10 +29,27 @@ fi
status=0
# Flatten, then strip anchors, so a linked reference still counts as a reference.
-refs=$(tr '\n' ' ' < "$page" | sed -E 's#?a[^>]*>##g; s/ +/ /g' \
- | grep -oE '(]*>|class="filename"[^>]*>) *[^<]*\.[A-Za-z]+:[0-9]+' | wc -l | tr -d ' ')
+# A reference is a span or .filename label that starts with path.ext:line.
+# A host:port such as example.com:8080 looks the same, so drop common TLDs.
+flat=$(tr '\n' ' ' < "$page" | sed -E 's#?a[^>]*>##g; s/ +/ /g')
+ref='(]*>|class="filename"[^>]*>) *[A-Za-z0-9_./-]+\.[A-Za-z0-9]+:[0-9]+(-[0-9]+)?[ ,<]'
+tld='\.(com|org|net|io|dev|app|local|internal|localhost):'
+count() { printf '%s\n' "$flat" | grep -oE "$ref" | grep -vE "$tld" | grep -cE "$1"; }
+refs=$(count '.')
+marked=$(count 'data-bare=')
links=$(grep -o 'class="srcref"' "$page" | wc -l | tr -d ' ')
-echo "references=$refs linked=$links"
+echo "references=$refs linked=$links marked-bare=$marked"
+
+# Every reference is linked unless the page marks it with data-bare, or the
+# provenance line says the host could not be linked at all.
+if printf '%s\n' "$flat" | grep -q 'References are not linked'; then
+ echo "pass: provenance says references are not linked"
+elif [ "$links" -lt $((refs - marked)) ]; then
+ echo "FAIL: $((refs - marked - links)) references are neither linked nor marked data-bare"
+ status=1
+else
+ echo "pass: every reference is linked or marked data-bare"
+fi
# A link names the full 40-character sha. GitHub resolves an abbreviation only
# while the commit is on a branch, so a short sha 404s once a squash merge lands.