Skip to content

Citation validator false negative: Internal links with backticks in anchor IDs #27

@WesleyMFrederick

Description

@WesleyMFrederick

Problem

The citation validator incorrectly flags valid internal links as "Unknown citation pattern" when the anchor ID contains backticks.

Reproduction Steps

  1. Validate markdown containing backtick anchors:
[**\`hasAnchor(anchorId: string): boolean\`**](#\`hasAnchor(anchorId%20string)%20boolean\`)
  1. Observe false negative:
Line 88: [**\`hasAnchor(anchorId: string): boolean\`**](#\`hasAnchor(anchorId%20string)
│  └─ Unknown citation pattern
│  └─ Suggestion: Use one of: cross-document [text](file.md#anchor), caret ^FR1, or wiki-style [[#anchor|text]]

Root Cause

The citation validator's regex patterns don't handle:

  1. Backticks within anchor IDs
  2. Special characters like parentheses and colons in anchor IDs
  3. URL-encoded spaces (%20) in anchor IDs

Expected Behavior

Internal links with complex anchor IDs (containing backticks, parentheses, URL-encoded characters) should be recognized as valid when:

  • The anchor format follows Obsidian/GitHub markdown conventions
  • The link renders correctly in Obsidian

Impact

  • False negatives block legitimate edits
  • Documentation authors must work around validator limitations
  • Reduces trust in validation tool

Related


Acceptance Criteria

  • Internal link regex handles backticks in anchor IDs
  • URL-encoded characters in anchors recognized (%20, %28, %29)
  • Parentheses and colons in anchor IDs do not break pattern matching
  • Valid backtick-anchored links pass validation
  • No regression on existing valid/invalid citation detection

Definition of Done

  • Failing test written: backtick-anchored internal link flagged as unknown pattern (RED phase)
  • Fix implemented: enhanced regex or parser handles special characters in anchors (GREEN phase)
  • All existing citation-manager tests pass
  • Build succeeds: npm run build -w tools/citation-manager && npm link -w tools/citation-manager
  • Manual verification: ParsedDocument Implementation Guide validates without false negatives
  • Committed with conventional commit message referencing this issue

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions