Repository navigation
fix: resolve internal links by target instead of link text - #76
Merged
Merged
Conversation
`Writer.Inline.Link` built the help reference for a `[text](#anchor)` link
by slugifying the link's text, ignoring the target entirely. A link only
resolved when its text happened to spell the target heading, so any other
wording produced a `|reference|` matching no tag, and `:help` on it failed
with E149.
The failure was silent: pandoc exited 0, `:helptags` exited 0, and the
README rendered correctly on GitHub.
`Writer.Pandoc` now walks the document before rendering and maps each
heading's identifier to the tag that heading will emit, including the
parent prefix added under `--dedup-subheadings`. Links resolve against
that map, so the reference follows the target.
Link text that adds something is kept ahead of the tag, matching how
external links already render as `text <target>`:
See [Options](#options) and [the options below](#options).
See |project-options| and the options below |project-options|.
Text that merely repeats the heading is dropped, since the tag already
spells it out, and the comparison ignores case and markup so
[`Options`](#options) is treated as a repeat.
Headings below level 2 are rendered without a tag, so links to them cannot
resolve. Those now render as plain text with a warning on stderr rather
than emitting a reference that cannot be followed.
Verified against two published plugin READMEs: output is byte-identical
for one whose link text already matched its headings, and the other's
eleven dangling references drop to zero.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
|
Thanks for the PR with tests! |
Contributor
Author
|
Thank you for the quick turnaround. Are there any plans to create a new tag and/or release or should I switch to main? I am asking because I'd like to use the Nix package but it's quite old: https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/pa/panvimdoc/package.nix |
Owner
|
Thanks for the ping, I made a new release! https://github.com/kdheepak/panvimdoc/releases/tag/v5.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Writer.Inline.Linkbuilt the help reference for a[text](#anchor)link by slugifying the link's text, ignoring the target entirely. A link only resolved when its text happened to spell the target heading, so any other wording produced a|reference|matching no tag, and:helpon it failed with E149.The failure was silent: pandoc exited 0,
:helptagsexited 0, and the README rendered correctly on GitHub.Writer.Pandocnow walks the document before rendering and maps each heading's identifier to the tag that heading will emit, including the parent prefix added under--dedup-subheadings. Links resolve against that map, so the reference follows the target.Link text that adds something is kept ahead of the tag, matching how external links already render as
text <target>:Text that merely repeats the heading is dropped, since the tag already spells it out, and the comparison ignores case and markup so
Optionsis treated as a repeat.Headings below level 2 are rendered without a tag, so links to them cannot resolve. Those now render as plain text with a warning on stderr rather than emitting a reference that cannot be followed.
Verified against two published plugin READMEs: output is byte-identical for one whose link text already matched its headings, and the other's eleven dangling references drop to zero.
Fixes #75