Skip to content

Commit fa42177

Browse files
tools: fix man pages linking regex
The change to word boundary was breaking many doc pages. This replace the word boundary with a matching group of space or beginning of line. Fixes: nodejs#17637 Fixes: nodejs#17694 Refs: nodejs#17479
1 parent 5af4822 commit fa42177

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/doc/html.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,10 @@ const BSD_ONLY_SYSCALLS = new Set(['lchmod']);
416416
// '<a href="http://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>'
417417
function linkManPages(text) {
418418
return text.replace(
419-
/ ([a-z.]+)\((\d)([a-z]?)\)/gm,
420-
(match, name, number, optionalCharacter) => {
419+
/(^|\s)([a-z.]+)\((\d)([a-z]?)\)/gm,
420+
(match, beginning, name, number, optionalCharacter) => {
421421
// name consists of lowercase letters, number is a single digit
422-
const displayAs = `${name}(${number}${optionalCharacter})`;
422+
const displayAs = `${beginning}${name}(${number}${optionalCharacter})`;
423423
if (BSD_ONLY_SYSCALLS.has(name)) {
424424
return ` <a href="https://www.freebsd.org/cgi/man.cgi?query=${name}` +
425425
`&sektion=${number}">${displayAs}</a>`;

0 commit comments

Comments
 (0)