Skip to content

feat(markdown-parser): support Obsidian wiki-link extraction ([[target|display]]) #5

@WesleyMFrederick

Description

@WesleyMFrederick

Problem

Citation-manager cannot extract content from Obsidian wiki-links ([[target|display]], [[target#header|display]], [[target#^block-id|display]]). When reading a document containing wiki-links with %%force-extract%% tags, the citation-extractor hook returns zero extracted content because the markdown parser doesn't recognize wiki-link syntax as links.

This breaks the progressive-disclosure workflow: design documents that reference PRDs and whiteboards via wiki-links get no auto-extracted context.

Reproduction Steps

  1. Create a markdown file with wiki-links:
    **Inputs**: [[continuous-learning-port-prd|PRD]]%%force-extract%%
  2. Run: citation-manager extract links <file>
  3. Observe output:
    {
      "extractedContentBlocks": { "_totalContentCharacterLength": 2 },
      "outgoingLinksReport": { "processedLinks": [] },
      "stats": { "totalLinks": 0 }
    }
  4. Expected: PRD content extracted. Actual: 0 links found.

Root Cause

The markdown parser (likely marked) does not recognize Obsidian wiki-link syntax ([[...]]) as link tokens. Wiki-links appear as plain text in the AST, so the content extractor never processes them.

The AST output confirms wiki-links are embedded inside paragraphtext tokens with no link-type node generated.

Expected Behavior

  • [[target|display]] resolved to a file path relative to the document's directory
  • [[target#header|display]] resolved to file + header section extraction
  • [[target#^block-id|display]] resolved to file + block anchor extraction
  • %%force-extract%% tag works with wiki-links (extracts full file content)
  • Citation-validator hook auto-extracts linked content when reading .md files

Related

Note

This is a high priority issue because the entire vault uses Obsidian wiki-links. Without this, citation-extractor provides zero value for design docs, PRDs, and whiteboards that cross-reference each other. The %%force-extract%% workflow is broken for the primary link format in use.

Wiki-link resolution rules (Obsidian):

  • [[filename]] — resolves to closest matching .md file by name (no path needed)
  • [[filename|display]] — same resolution, display text differs
  • [[filename#Header]] — file + header section
  • [[filename#^block-id]] — file + block anchor
  • Resolution is relative to vault root, with shortest-path matching

Acceptance Criteria

  • Parser detects [[target]] wiki-link syntax in markdown content
  • Parser detects [[target|display]] with display text
  • Parser detects [[target#header]] with header references
  • Parser detects [[target#^block-id]] with block anchor references
  • Wiki-links resolve to actual file paths relative to document location
  • %%force-extract%% tag works with wiki-links (full file extraction)
  • citation-manager extract links returns extracted content from wiki-linked files
  • Citation-extractor hook fires correctly for wiki-link references
  • Existing markdown link extraction ([text](path)) unchanged (no regression)

Definition of Done

  • Failing tests written (RED phase)
  • Implementation complete (GREEN phase)
  • All existing tests pass (no regression)
  • New tests cover all wiki-link variants
  • Build succeeds
  • Committed with conventional commit

Component Guides

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions