Skip to content

Commit

Permalink
tools: fix man pages linking regex
Browse files Browse the repository at this point in the history
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
  • Loading branch information
DiegoRBaquero committed Dec 19, 2017
1 parent 5af4822 commit fa42177
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,10 @@ 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(
/ ([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})`;
const displayAs = `${beginning}${name}(${number}${optionalCharacter})`;
if (BSD_ONLY_SYSCALLS.has(name)) {
return ` <a href="https://www.freebsd.org/cgi/man.cgi?query=${name}` +
`&sektion=${number}">${displayAs}</a>`;
Expand Down

0 comments on commit fa42177

Please sign in to comment.