Skip to content

fix(legacy-html): keep $ sequences in template values as-is - #1186

Open
btea wants to merge 1 commit into
nodejs:mainfrom
btea:fix/template-dollar-sign-replacement
Open

btea wants to merge 1 commit into
nodejs:mainfrom
btea:fix/template-dollar-sign-replacement

Conversation

@btea

@btea btea commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Description

close #1181

Validation

Related Issues

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:check & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

@btea
btea requested a review from a team as a code owner October 26, 2026 14:06
@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
api-docs-tooling Ready Ready Preview Oct 26, 2026 2:07pm UTC

Request Review

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.69767% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.52%. Comparing base (7238bb1) to head (8197ece).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
packages/react/src/sitemap/generate.mjs 0.00% 5 Missing ⚠️
packages/node/src/man-page/generate.mjs 0.00% 2 Missing ⚠️
...cy/src/legacy-html/utils/replaceTemplateValues.mjs 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1186      +/-   ##
==========================================
+ Coverage   93.32%   93.52%   +0.20%     
==========================================
  Files         273      279       +6     
  Lines       27050    27887     +837     
  Branches     2722     2798      +76     
==========================================
+ Hits        25244    26082     +838     
+ Misses       1784     1783       -1     
  Partials       22       22              

☔ View full report in Codecov by Harness.
📢 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.

@github-actions

Copy link
Copy Markdown
Contributor

api-links Generator

Performance estimate (single CI run)

  • Generation time: 38.3% faster (1.07 s → 660.00 ms)
  • Peak memory: 5.9% higher (289.13 MB → 306.32 MB)

json Generator

Performance estimate (single CI run)

  • Generation time: 47.3% slower (7.46 s → 10.99 s)
  • Peak memory: 0.9% lower (1.18 GB → 1.17 GB)

legacy-html Generator

Output size: 1 file changed · net +1.00 B

File size details
File Main PR Change
addons.html 374.15 KB 374.15 KB +1.00 B (+0.0%)

Performance estimate (single CI run)

  • Generation time: 48.0% slower (10.58 s → 15.66 s)
  • Peak memory: 1.0% lower (1.79 GB → 1.77 GB)

legacy-json Generator

Performance estimate (single CI run)

  • Generation time: 1.9% slower (9.04 s → 9.21 s)
  • Peak memory: 3.6% lower (1.15 GB → 1.11 GB)

llms-txt Generator

Performance estimate (single CI run)

  • Generation time: 2.0% slower (8.10 s → 8.26 s)
  • Peak memory: 6.8% lower (1.19 GB → 1.11 GB)

orama-db Generator

Output size: 1 file changed · net +97.00 B

File size details
File Main PR Change
orama-db.json 29.24 MB 29.24 MB +97.00 B (+0.0%)

Performance estimate (single CI run)

  • Generation time: 18.2% slower (7.35 s → 8.69 s)
  • Peak memory: 0.4% lower (1.28 GB → 1.27 GB)

web Generator

Performance estimate (single CI run)

  • Generation time: 16.7% faster (22.42 s → 18.67 s)
  • Peak memory: 6.0% higher (1.90 GB → 2.02 GB)

@ovflowd ovflowd left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Really? Just passing them as wrapping functions fixes this?

But do we really need to pass everything as an anonymous function? 😅

Anyhow, thanks for the contribution! Can you attach some screenshots showing it fixing it?

@btea

btea commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Really? Just passing them as wrapping functions fixes this?

Yes — when the replacement is a function, its return value is inserted verbatim, without the $-pattern substitution that string replacements go through ($$ → $, $& → the match, $` / $' → the surrounding template). So () => content is the smallest change that opts out of that behavior.

But do we really need to pass everything as an anonymous function? 😅

Strictly speaking, only the doc-derived values (content, nav, toc, …) can contain $ sequences, but wrapping every line keeps it uniform and makes sure a future placeholder can't reintroduce the bug — which is also what you suggested in #1181

Anyhow, thanks for the contribution! Can you attach some screenshots showing it fixing it?

The modified build result is shown in the figure. (By the way, the preview links generated by each PR do not include the preview content of legacy-html. Perhaps we could add it? #1186 (comment))
image

This branch was successfully deployed

1 active deployment
Preview – api-docs-tooling — 8197ece6 Deployed Oct 26, 2026 by vercel[bot]
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.

legacy-html: $$ in the docs is rendered as $

2 participants