Skip to content

fix(markdown): parse link reference definitions with titles#1017

Open
gs0428 wants to merge 3 commits into
TanStack:mainfrom
gs0428:fix-comment-visible
Open

fix(markdown): parse link reference definitions with titles#1017
gs0428 wants to merge 3 commits into
TanStack:mainfrom
gs0428:fix-comment-visible

Conversation

@gs0428

@gs0428 gs0428 commented Jun 30, 2026

Copy link
Copy Markdown

Summary

Fixes Markdown link reference definitions with optional titles being rendered as visible text in docs pages.

This affects Markdown comments such as:

[//]: # 'SomeLabel'

These are valid CommonMark link reference definitions where # is the destination and 'SomeLabel' is the optional title, so they should be removed from rendered output.

close #1015

Changes

  • Adds a pnpm patch for @tanstack/markdown@0.0.5
  • Updates the link reference definition regex to allow optional single-quoted, double-quoted, or parenthesized titles
  • Adds a regression test for all three title forms

Validation

  • pnpm test

Summary by CodeRabbit

  • Bug Fixes

    • Improved parsing of markdown link reference definitions to support optional titles written in double quotes, single quotes, or parentheses, resulting in more reliable resolved links.
    • Ensured reference-definition content is handled as metadata and is not rendered as visible output.
  • Tests

    • Added coverage for reference-definition titles in the supported formats, including checks that resolved links include the expected href and title.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b5cd0cc-5990-450f-905d-a1234308ccdf

📥 Commits

Reviewing files that changed from the base of the PR and between 861553a and 0a1d770.

📒 Files selected for processing (1)
  • tests/markdown-link-reference-definitions.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/markdown-link-reference-definitions.test.ts

📝 Walkthrough

Walkthrough

A patch for @tanstack/markdown@0.0.5 now parses optional link titles in reference definitions. The patch is registered in pnpm-workspace.yaml, and new tests cover single-quoted, double-quoted, and parenthesized title forms.

Changes

Markdown Link Reference Definition Fix

Layer / File(s) Summary
Regex patch and workspace wiring
patches/@tanstack__markdown@0.0.5.patch, pnpm-workspace.yaml
extractDefinitions now captures an optional title after the destination, and pnpm is configured to apply the local patch.
Tests for reference definition title variants
tests/markdown-link-reference-definitions.test.ts
Adds fixtures and assertions for three title syntaxes, checking both rendered omission and parsed link metadata.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit found a title way,
In quotes and parens, bright and gay.
The refs now hush, not show their face,
And links resolve with tidy grace.
🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely matches the main change: parsing link reference definitions with optional titles.
Linked Issues check ✅ Passed The patch addresses the reported docs rendering bug by supporting optional link titles and removing those definitions from output.
Out of Scope Changes check ✅ Passed The workspace patch and regression test are directly in scope for the markdown parsing fix, with no unrelated changes evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/markdown-link-reference-definitions.test.ts (1)

19-40: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert definition extraction, not just output suppression.

These assertions still pass if extractDefinitions merely drops [...]: ... lines. Since this patch changes reference-definition parsing, add a check that a real reference resolves or that the parsed reference table contains the definition as well.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/markdown-link-reference-definitions.test.ts` around lines 19 - 40, The
current test only verifies that reference-definition lines disappear from the
rendered output, so it can still pass even if `extractDefinitions` simply strips
those lines. Update `markdown-link-reference-definitions.test.ts` to also assert
the actual reference parsing behavior by checking that a reference link in
`parseSiteMarkdown` resolves correctly or that the parsed definition table on
the returned document contains the expected definition entry; use the existing
`markdownCases` loop and `parseSiteMarkdown` result to add this validation
alongside the current paragraph assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@patches/`@tanstack__markdown@0.0.5.patch:
- Around line 9-12: The reference-definition parser in the markdown patch now
matches titled links, but the `references` map still only stores `href`, so the
title metadata is lost. Update the logic around `definition` parsing to capture
the optional title from the regex and persist it alongside `href` when assigning
`references[normalizeReferenceLabel(...)]`, keeping the handling in the
reference-definition path consistent with the new pattern.

---

Nitpick comments:
In `@tests/markdown-link-reference-definitions.test.ts`:
- Around line 19-40: The current test only verifies that reference-definition
lines disappear from the rendered output, so it can still pass even if
`extractDefinitions` simply strips those lines. Update
`markdown-link-reference-definitions.test.ts` to also assert the actual
reference parsing behavior by checking that a reference link in
`parseSiteMarkdown` resolves correctly or that the parsed definition table on
the returned document contains the expected definition entry; use the existing
`markdownCases` loop and `parseSiteMarkdown` result to add this validation
alongside the current paragraph assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bbf7044a-748c-4d41-ba71-fb4fe0050e1f

📥 Commits

Reviewing files that changed from the base of the PR and between 57c5060 and 25cd43b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • patches/@tanstack__markdown@0.0.5.patch
  • pnpm-workspace.yaml
  • tests/markdown-link-reference-definitions.test.ts

Comment thread patches/@tanstack__markdown@0.0.5.patch Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/markdown-link-reference-definitions.test.ts`:
- Around line 8-24: Add a focused regression case in
markdown-link-reference-definitions.test.ts for the exact comment-style/hash
reference path: use the existing markdown reference parsing setup to exercise
[Example][//] against the [//]: # ... definition and assert the resolved link
has href set to # and the expected title. Update the relevant table-driven cases
near the existing referenceMarkdown/title fixtures so the test specifically
covers the [//] symbol handled by the parser, not just normal example
references.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa0cfc1d-71c6-4b2c-9c4e-01b16ecbad4f

📥 Commits

Reviewing files that changed from the base of the PR and between 25cd43b and 861553a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • patches/@tanstack__markdown@0.0.5.patch
  • tests/markdown-link-reference-definitions.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)

Comment thread tests/markdown-link-reference-definitions.test.ts
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.

Markdown link reference comments render as visible text in docs

1 participant