Skip to content

fix(visualize): resolve OKF wikilinks in the reader - #654

Open
C. Willis (carlitoswillis) wants to merge 1 commit into
langchain-ai:mainfrom
carlitoswillis:fix/visualizer-wikilinks
Open

fix(visualize): resolve OKF wikilinks in the reader#654
C. Willis (carlitoswillis) wants to merge 1 commit into
langchain-ai:mainfrom
carlitoswillis:fix/visualizer-wikilinks

Conversation

@carlitoswillis

Copy link
Copy Markdown

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, and rewriteLinks only 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

  • New resolveWikilinks helper in client-lib.ts rewrites [[target]] / [[target|label]] before the body reaches marked.parse.
  • Resolved targets (matching a known node id case-insensitively, tolerating a stray .md extension, with a unique final-path-segment fallback for short targets like [[overview]]) become standard markdown links, which the existing rewriteLinks pass upgrades to in-app navigation.
  • Unresolved targets degrade to their label as plain text — no dead links, no raw brackets.
  • Backtick code spans and fences are passed through untouched, so documentation about wikilink syntax renders literally (tilde and 4+-backtick fences are not recognised by this lexer-free pass; noted in the doc comment).
  • rewriteLinks additionally 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 resolveWikilinks alongside the other client-lib helper 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

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>
@changeset-bot

changeset-bot Bot commented Aug 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c71ad32

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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