Skip to content

Match whole words when bolding member names in MDN comments - #2576

Merged
github-actions[bot] merged 1 commit into
microsoft:mainfrom
NgoQuocViet2001:fix-mdn-comment-bolding
Nov 3, 2026
Merged

github-actions[bot] merged 1 commit into
microsoft:mainfrom
NgoQuocViet2001:fix-mdn-comment-bolding

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown
Contributor

The MDN comment generator bolds the first regex match of the member name, but the pattern has no word boundaries, so short names get matched inside other words. The current baselines ship comments like:

- The DOMPointReadOnl**`y`** interface's y property holds the vertical coordinate ...
+ The DOMPointReadOnly interface's **`y`** property holds the vertical coordinate ...

The same thing happens for HTMLImageElement.y and SVGMaskElement.y ("read-onl**y** y property"), for Window.top and the global top ("**topmost window") and for TextEvent.initTextEvent ("initTextEvent**Event()").

This adds \b around the name in the regex, in line with the space-delimited matching suggested in the #2171 review. Interface.name and name() matches still work. "topmost" and MDN's "initTextEventEvent()" typo have no standalone match, so those two summaries are now left unbolded. Only these comment lines change in the dom and worker baselines.

Ran:

  • npm run generate, then npm test: pass
  • npx tsgo: pass

Checked:

  • With the regenerated baselines and the old regex, node ./src/test.ts fails on the DOMPointReadOnly.y comment in dom.generated.d.ts.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the PR!

This section of the codebase is owned by Kagami Sascha Rosylight (@saschanaz) - if they write a comment saying "LGTM" then it will be merged.

@saschanaz

Copy link
Copy Markdown
Contributor

Great find. Thanks! LGTM

@github-actions
github-actions Bot merged commit a372aad into microsoft:main Nov 3, 2026
7 checks passed
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Merging because Kagami Sascha Rosylight (@saschanaz) is a code-owner of all the changes - thanks!

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