Repository navigation
fix(document): a wikilink's display text is not part of its target - #1
Merged
Merged
Conversation
`[[link-op|link operator]]` writes one reference, and the words after the bar are there so the sentence reads naturally. The collector took the whole bracketed string as the target, so that link produced a node named `link-op|link operator` beside the real `link-op` — thirty-three such links across `doc/`, fourteen distinct phantom nodes. Splitting at the first bar is the whole fix. Duplicates need no work: `build_edges` already identifies a link edge by its endpoints, so `[[beta]]` and `[[beta|the second one]]` now collapse into one edge with their annotations merged, which is what the design asked for and what the wrong target was preventing.
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.
[[link-op|link operator]]is one reference with display text, ashypermarkdown.hmd states — "all of which may carry
display text as
[[target|display text]]" — and asdoc-type.hmd repeats: "Display text declares
nothing."
The collector took the whole bracketed string as the target, so that link became
a node named
link-op|link operatorsitting beside the reallink-op. Queryingthis repository's own wiki showed it:
Thirty-three such links across
doc/, fourteen distinct phantom nodes.The change
split_once('|')on the bracketed text, taking what precedes the bar. A laterbar is display text too, which is why it is
split_onceand notsplit.Duplicates needed no work
build_edgesalready identifies a link edge by its endpoints and merges theannotations across every place the link is written. The wrong target was what
prevented that from applying. A card writing both forms of one link:
One edge, both annotations merged. Two edges to two nodes before.
Document.referencesstill holds one entry per written occurrence, in documentorder, since that is what makes the merge downstream possible.
Tests
Three beside the code in
src/document.rs: display text stripped from thetarget including spaces around the bar, an annotation still binding through
display text, and
[[|just words]]naming nothing rather than yielding an emptytarget.
Not in this change
A
[[link]]written inside a fenced code block is still collected as areference, so the syntax examples in the wiki's code blocks remain phantom nodes
—
aliceandnowhereare still in that query's output. That is a behaviourchange with a design question behind it and belongs on its own.