fix(visualize): resolve OKF wikilinks in the reader - #654
Open
C. Willis (carlitoswillis) wants to merge 1 commit into
Open
fix(visualize): resolve OKF wikilinks in the reader#654C. Willis (carlitoswillis) wants to merge 1 commit into
C. Willis (carlitoswillis) wants to merge 1 commit into
Conversation
The doc generator emits Open Knowledge Format wikilinks — [[path/to/page]] and [[path/to/page|label]] — but the visualizer's reader parsed page bodies with marked alone, which does not know the syntax, so wikilinks showed up as literal [[...]] text. Resolve wikilinks before parsing: a target that matches a known node id (case-insensitively, tolerating a stray .md extension, with a unique final-path-segment fallback for short targets) becomes a standard markdown link that the existing anchor-rewrite pass upgrades to in-app navigation; an unresolved target degrades to its label as plain text rather than a dead link. Backtick code spans and fences are passed through untouched. rewriteLinks also learns to read wikilink-derived hrefs as wiki-root-relative, since hand-written links are page-relative. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
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.
The bug
The doc generator emits Open Knowledge Format wikilinks in its markdown —
[[path/to/page]]and[[path/to/page|label]]— but the bundled visualizer (openwiki visualize) never resolves them. The reader renders page bodies with marked, which does not know the wikilink syntax, andrewriteLinksonly handles standard[text](x.md)anchors, so wikilinks show up as literal[[...]]text in the official UI.Found while generating and browsing wikis for 14 repositories — pages that lean on wikilinks for cross-references are noticeably degraded in the reader.
The fix
resolveWikilinkshelper inclient-lib.tsrewrites[[target]]/[[target|label]]before the body reachesmarked.parse..mdextension, with a unique final-path-segment fallback for short targets like[[overview]]) become standard markdown links, which the existingrewriteLinkspass upgrades to in-app navigation.rewriteLinksadditionally tries a wiki-root-relative reading of an href when the page-relative one misses, since wikilink targets are rooted at the wiki while hand-written links are page-relative.Unit tests added for
resolveWikilinksalongside the otherclient-libhelper tests; also verified end-to-end with a headless browser against a generated wiki (resolved wikilink navigates in-app, unresolved renders as plain text, no[[remains in the reader).🤖 Generated with Claude Code