Skip to content

fix(convert): stop check misreporting a self-referencing same-page anchor - #122

Merged
willkg merged 1 commit into
mainfrom
fix/check-self-anchor-warning
Aug 31, 2026
Merged

fix(convert): stop check misreporting a self-referencing same-page anchor#122
willkg merged 1 commit into
mainfrom
fix/check-self-anchor-warning

Conversation

@willkg

@willkg willkg commented Aug 31, 2026

Copy link
Copy Markdown
Member

Fixes #118

Summary

  • A same-page anchor (#heading) in a file with no page_id yet resolved fine to a real heading, but could only be reported through the generic link not resolved: TARGET warning -- naming the current file as if it were some other broken reference, when the anchor itself is fine and just needs this file's own first publish (check warns on a same-page anchor in an unpublished file #118).
  • Gives the self-reference case its own same-page anchor not resolved: #heading message, gated on the anchor having actually matched a heading (anchorResolved) so a self-link with a bad fragment falls through to the existing anchor not found + link not resolved pair rather than falsely claiming a resolution that didn't happen.
  • Updates check's --help text, which previously documented the confusing behavior as expected rather than fixing it.

Test plan

  • New regression fixture internal/convert/testdata/regression/same-page-anchor-unpublished/ covering both the resolved-anchor case and the bad-fragment self-reference case
  • New cmd/check tests: TestRunSamePageAnchorUnpublishedWarnsDistinctly, TestRunSelfReferenceWithBadFragmentDoesNotClaimAnchorResolved
  • make check passes
  • Manually reproduced the issue's repro against the built binary before and after the fix

…chor as a broken cross-file link

A same-page anchor (#heading) in a file with no page_id yet resolved to a
real heading fine, but rewriteHref's fully-qualifying step could only report
it through the generic "link not resolved: TARGET" warning, naming the
current file as if it were some other unresolved reference. Give the
self-reference case its own "same-page anchor not resolved" message, gated
on the anchor having actually matched a heading so a self-link with a bad
fragment still falls through to the existing (redundant but accurate)
warning pair rather than claiming a resolution that didn't happen.

Fixes #118.
@willkg
willkg merged commit 25b75c8 into main Aug 31, 2026
1 check passed
@willkg
willkg deleted the fix/check-self-anchor-warning branch August 31, 2026 02:10
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.

check warns on a same-page anchor in an unpublished file

1 participant