Skip to content

fix(refactor): extend link refactoring to handle [[Title]] wiki-link syntax#1126

Merged
perber merged 2 commits into
mainfrom
fix/wiki-links-refactor-preview
Jun 4, 2026
Merged

fix(refactor): extend link refactoring to handle [[Title]] wiki-link syntax#1126
perber merged 2 commits into
mainfrom
fix/wiki-links-refactor-preview

Conversation

@perber

@perber perber commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Preview: FindWikiLinksForPath detects [[Title]] and [[path/hint]] patterns in page content and shows them in the affected-pages list instead of the raw route path, so users see [[Project Plan]] rather than /docs/project-plan.

Apply: RewriteWikiLinks rewrites [[OldTitle]] → [[NewTitle]] on rename and [[old/path]] → [[new/path]] for path hints on rename/move, respecting code blocks and inline code spans. OldTitle/NewTitle added to RewriteRule so the rename case carries title information through to the rewrite step.

…syntax

Preview: FindWikiLinksForPath detects [[Title]] and [[path/hint]] patterns in
page content and shows them in the affected-pages list instead of the raw
route path, so users see [[Project Plan]] rather than /docs/project-plan.

Apply: RewriteWikiLinks rewrites [[OldTitle]] → [[NewTitle]] on rename and
[[old/path]] → [[new/path]] for path hints on rename/move, respecting code
blocks and inline code spans. OldTitle/NewTitle added to RewriteRule so the
rename case carries title information through to the rewrite step.

Adds 11 unit tests covering both functions.
Copilot AI review requested due to automatic review settings June 4, 2026 15:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends LeafWiki’s page refactor (rename/move) link preview + apply steps to understand and rewrite [[...]] wiki-link syntax in addition to standard Markdown links, improving both the affected-pages preview display and the actual content rewrite behavior.

Changes:

  • Preview: detect [[Title]] / [[path/hint]] usage in page content and display those wiki-link forms in the affected-pages list.
  • Apply: rewrite [[OldTitle]] → [[NewTitle]] during rename and [[old/path]] → [[new/path]] for path hints during rename/move, while respecting code blocks/inline code.
  • Plumbing: extend RewriteRule to optionally carry title rename data through the rewrite pipeline; add tests for wiki-link rewriting.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
internal/wiki/pages/refactor.go Passes page title into preview matching; applies both Markdown and wiki-link rewrites when rewriting affected pages.
internal/links/refactor.go Extends rewrite rules to optionally include title rename information.
internal/links/link_refactor.go Adds wiki-link rewrite + wiki-link detection helpers to the refactor engine.
internal/links/link_refactor_wikilinks_test.go Adds unit tests for wiki-link rewriting and preview detection helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/links/link_refactor.go
Comment thread internal/links/link_refactor.go Outdated
Comment thread internal/links/link_refactor_wikilinks_test.go
Comment thread internal/links/link_refactor_wikilinks_test.go
1. Add \s* around target in regex patterns so [[ Project Plan ]] is
   rewritten just like [[Project Plan]], matching the extractor's
   TrimSpace behaviour.

2. Promote FindWikiLinksForPath to a method on MarkdownRefactorEngine
   so it can use collectCandidatesAndExcludedRanges and skip fenced code
   blocks / inline code, making preview and apply agree on which links
   would actually be rewritten.

3. Expand SkipsCodeBlocks test to cover inline code spans in addition
   to fenced code blocks.

4. Expand TitleRenameCaseInsensitive test with whitespace variants.
@perber
perber merged commit 3b9c009 into main Jun 4, 2026
9 checks passed
@perber
perber deleted the fix/wiki-links-refactor-preview branch June 8, 2026 20:25
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.

2 participants