Skip to content

Reject wikilinks with explicitly empty titles - #373

Open
ishu7w wants to merge 1 commit into
earwig:mainfrom
ishu7w:reject-empty-wikilink-titles
Open

ishu7w wants to merge 1 commit into
earwig:mainfrom
ishu7w:reject-empty-wikilink-titles

Conversation

@ishu7w

@ishu7w ishu7w commented Nov 27, 2026

Copy link
Copy Markdown

Fixes #292.

Summary

-[[]], [[|]], [[|||]] -> Wikilink nodes
+[[]], [[|]], [[|||]] -> literal Text

Reject explicitly empty wikilink titles in both the C and Python tokenizers. This keeps filter_wikilinks() from returning false links and prevents strip_code() from removing their literal text. Template-based titles such as [[{{echo|}}]] remain links: determining whether they expand to an empty title requires template expansion, which this parser does not perform. Whitespace-only or other semantically invalid titles are outside this change.

Evidence

  • Before: the three corrected empty-link fixtures fail in both tokenizers: 6 failures, with all 3 round-trip checks passing.
    After: full suite: 2,019 passed, 1 skipped. The wikilink tokenizer subset passes all 96 cases, including C/Python checks and round trips. Added coverage for text extraction, dynamic titles, and a valid link following an empty one.
  • Ruff 0.15.6 lint and formatting checks pass for the changed Python files. The added C blocks follow the repository's clang-format settings. git diff --check passes.
  • AI assistance was used for investigation, implementation, and tests.

Merge Danger

Door: two-way

No serialized data or public API changes; the behavior can be reverted normally.

Blast Radius: parsing

Callers that previously counted literal empty bracket pairs as wikilinks will now receive Text nodes, as requested in #292. Titles containing templates retain their current behavior.

This branch has not been deployed

No deployments
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.

[[]] and [[|]] should not be treated as wikilinks

1 participant