diff --git a/tools/doc/html.js b/tools/doc/html.js
index f2d3fcdbba6860..f2e7ed396b7cc4 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -416,15 +416,15 @@ const BSD_ONLY_SYSCALLS = new Set(['lchmod']);
// 'open(2)'
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 ` ${displayAs}`;
} else {
- return ` ${displayAs}`;
}
});