Skip to content

fix(metadata): strip directory prefix when converting nested .md link to .html#768

Open
TusharThakur04 wants to merge 2 commits intonodejs:mainfrom
TusharThakur04:fix/markdown-to-html-link
Open

fix(metadata): strip directory prefix when converting nested .md link to .html#768
TusharThakur04 wants to merge 2 commits intonodejs:mainfrom
TusharThakur04:fix/markdown-to-html-link

Conversation

@TusharThakur04
Copy link
Copy Markdown
Contributor

Description

This PR reinforce the link conversion logic for nested .md files by stripping the directory prefix.

Validation

before :

Screencast.from.2026-04-14.05-00-18.webm

after :

Screencast.from.2026-04-14.04-36-15.webm

Related Issues

n/a

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

@TusharThakur04 TusharThakur04 requested a review from a team as a code owner April 13, 2026 23:35
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Apr 27, 2026 10:27pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 13, 2026

PR Summary

Low Risk
Low risk: small, localized change to Markdown link normalization plus added unit coverage; main risk is unintended link rewriting differences for edge-case relative URLs.

Overview
Fixes API-doc Markdown link rewriting so namespaces/foo.md (and #fragments) become foo.html by stripping any directory prefix during conversion.

Adds a safeguard to skip rewriting any link that already includes a protocol (e.g. http:, https:, file:), and extends unit tests to cover nested paths, fragment preservation, and protocol URLs.

Reviewed by Cursor Bugbot for commit f2f1fc1. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

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

Can you elaborate on this?

@TusharThakur04
Copy link
Copy Markdown
Contributor Author

TusharThakur04 commented Apr 15, 2026

earlier a markdown link such as namespaces/compileBooleanMatcher.md was converted to
namespaces/compileBooleanMatcher.html
but all pages are generated at root -- compileBooleanMatcher.html
so we need namespaces/compileBooleanMatcher.md to be converted to compileBooleanMatcher.html instead of namespaces/compileBooleanMatcher.html

this pr strips the directory prefix

@avivkeller
Copy link
Copy Markdown
Member

But doesn't this break cases where a full URL is needed?

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.01%. Comparing base (3d00fa8) to head (f2f1fc1).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/generators/metadata/utils/visitors.mjs 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #768      +/-   ##
==========================================
- Coverage   78.43%   78.01%   -0.42%     
==========================================
  Files         157      159       +2     
  Lines       13962    14112     +150     
  Branches     1152     1157       +5     
==========================================
+ Hits        10951    11010      +59     
- Misses       3006     3097      +91     
  Partials        5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TusharThakur04
Copy link
Copy Markdown
Contributor Author

i can add guard for :
eg: https://github.com/facebook/react/blob/main/README.md
these type of links will be ignored

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.

2 participants