Skip to content

fix(core): ignore wikilinks in inline code - #1348

Merged
phernandez merged 1 commit into
mainfrom
fix/1332-inline-code-wikilinks
Aug 28, 2026
Merged

fix(core): ignore wikilinks in inline code#1348
phernandez merged 1 commit into
mainfrom
fix/1332-inline-code-wikilinks

Conversation

@phernandez

Copy link
Copy Markdown
Member

Supersedes #1337 by @yaodong-shen — their commit is cherry-picked here unchanged, with authorship and sign-off preserved, so the full CI matrix runs (fork PRs only get DCO/CLA/CodeQL). Will be rebase-merged so the contributor commit lands on main as-is.

Fixes #1332.

Summary

A [[wikilink]] inside an inline code span was parsed as a relation, so prose that quotes a relation line as an example minted a real graph edge (the reporter's retired hub note kept an inbound link from a backticked template example). Fenced blocks were already ignored; inline spans were not.

MarkdownIt already tokenizes code_inline before Basic Memory's relation rule runs. The fix records the exact source ranges MarkdownIt classifies as inline code (by wrapping its own backtick rule, so CommonMark delimiter/escape semantics and its linear-time unmatched-run cache are reused rather than re-implemented), then masks only the [/] characters inside those spans before relation detection. Masking is position-preserving, so targets and context are still sliced from the original source text — escapes, formatting and trailing code in relation context are retained.

Review history on #1337

Codex raised five P2s on the original PR (source preservation, escaped backticks, trailing code in explicit relations, quadratic rescans, code-span brackets inside outer wikilink targets); the author addressed each with a follow-up push and regression cases. The final push (7caf720) never got a Codex re-review, so this PR will pick that up.

Verification (local, this branch)

  • uv run pytest tests/markdown tests/services tests/importers -q --no-cov — 555 passed, 2 skipped
  • uv run ruff check / ruff format --check on the touched files — clean
  • uv run --all-extras ty check src tests test-int — clean

🤖 Generated with Claude Code

https://claude.ai/code/session_017STCpbNsYjZgUdftxgEAZ4

Signed-off-by: buduoqiu <shenyaodong@hhu.edu.cn>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: d2a3933b68

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@phernandez
phernandez merged commit 29b1433 into main Aug 28, 2026
25 checks passed
@phernandez
phernandez deleted the fix/1332-inline-code-wikilinks branch August 28, 2026 18:23
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.

[BUG] Wikilinks inside inline code spans are parsed as relations (fenced blocks are correctly ignored)

2 participants