tools: fix man pages linking regex
The change to word boundary was breaking many doc pages. This reverts the word boundary back to space. PR-URL: https://github.com/nodejs/node/pull/17724 Fixes: https://github.com/nodejs/node/issues/17694 Refs: https://github.com/nodejs/node/pull/17479 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
4d1baf82ae
commit
66e6affb42
@ -416,15 +416,15 @@ const BSD_ONLY_SYSCALLS = new Set(['lchmod']);
|
||||
// '<a href="http://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>'
|
||||
function linkManPages(text) {
|
||||
return text.replace(
|
||||
/\b([a-z.]+)\((\d)([a-z]?)\)/gm,
|
||||
(match, name, number, optionalCharacter) => {
|
||||
/(^|\s)([a-z.]+)\((\d)([a-z]?)\)/gm,
|
||||
(match, beginning, name, number, optionalCharacter) => {
|
||||
// name consists of lowercase letters, number is a single digit
|
||||
const displayAs = `${name}(${number}${optionalCharacter})`;
|
||||
if (BSD_ONLY_SYSCALLS.has(name)) {
|
||||
return ` <a href="https://www.freebsd.org/cgi/man.cgi?query=${name}` +
|
||||
return `${beginning}<a href="https://www.freebsd.org/cgi/man.cgi?query=${name}` +
|
||||
`&sektion=${number}">${displayAs}</a>`;
|
||||
} else {
|
||||
return ` <a href="http://man7.org/linux/man-pages/man${number}` +
|
||||
return `${beginning}<a href="http://man7.org/linux/man-pages/man${number}` +
|
||||
`/${name}.${number}${optionalCharacter}.html">${displayAs}</a>`;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user