Skip to content

fix(archive): match reference-link definitions on every line - #10

Merged
docxology merged 1 commit into
mainfrom
fix/reference-link-multiline
Nov 12, 2026
Merged

docxology merged 1 commit into
mainfrom
fix/reference-link-multiline

Conversation

@docxology

Copy link
Copy Markdown
Collaborator

Regression

The gate refactor in #9 moved the checks into archive_checks.py and dropped re.MULTILINE from REFERENCE_LINK. Reference definitions after the first line were silently skipped: # title\n\n[ref]: missing.md\n\n[ref]\n matched nothing (flags: re.NOFLAG, findall → []), while docs/RUN_GUIDE.md and the module's own docstring still promised reference-style links were checked.

Fix

REFERENCE_LINK = re.compile(r"^\[[^\]]+\]:\s*(\S+)", re.MULTILINE) — byte-identical pattern and flags to the pre-refactor implementation (git show a05864a:.github/scripts/check_archive.py, compared programmatically: identical pattern+flags: True). The other three patterns were already identical.

Tests (both directions)

  • test_reference_definition_below_first_line_is_checked — a definition below a heading that points at missing.md must produce missing link target. Confirmed red before the fix: AssertionError: 0 != 1.
  • test_resolving_reference_definition_passes — a definition that resolves must not produce a false positive with the restored flag.

test_non_markdown_files_are_skipped already asserted reference definitions are scanned, but only at line 1, which is why the missing flag passed the suite.

Verification

$ python .github/scripts/gate.py tests     # before fix: 1 failure (0 != 1)
$ python .github/scripts/gate.py fast
archive: ok (61 tracked files; links resolve; Python compiles; notebooks are output-free JSON; no checkpoints)
Ran 19 tests in 0.010s
OK
tests: ok (19 tests)                                    # rc=0

The full repository passes the restored flag, so no reference definition in the tree was previously broken and hidden by the regression.

The refactor into archive_checks.py dropped re.MULTILINE from
REFERENCE_LINK, so a reference definition such as '[appendix]: missing.md'
below the first line stopped being checked while the docs and the module
docstring still promised reference-style links were covered. Restore the flag
and the pre-refactor semantics, and cover both directions with regression
tests (an unresolved definition below a heading, and a resolving one).
@docxology
docxology merged commit 438b281 into main Nov 12, 2026
0 of 4 checks passed
@docxology
docxology deleted the fix/reference-link-multiline branch November 12, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant