Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: fix man pages linking regex #17724

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})`;
const displayAs = `${beginning}${name}(${number}${optionalCharacter})`;
if (BSD_ONLY_SYSCALLS.has(name)) {
return ` <a href="https://www.freebsd.org/cgi/man.cgi?query=${name}` +
return `<a href="https://www.freebsd.org/cgi/man.cgi?query=${name}` +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think beginning should be used here, replacing the space.

Copy link
Member

@Trott Trott Dec 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lpinca Same applies to line 427 too? Or am I mistaken about that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's correct.

`&sektion=${number}">${displayAs}</a>`;
} else {
return ` <a href="http://man7.org/linux/man-pages/man${number}` +
return `<a href="http://man7.org/linux/man-pages/man${number}` +
`/${name}.${number}${optionalCharacter}.html">${displayAs}</a>`;
}
});
Expand Down