1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-11-23 21:54:45 +02:00

man: escape all hyphens in flag names

Apparently, if we don't do this, some roff renderers with use a special
Unicode hyphen. That in turn makes searching a man page not work as one
would expect.

Fixes #3140
This commit is contained in:
Andrew Gallant
2025-09-06 14:50:22 -04:00
parent 78383de9b2
commit 74959a14cb
3 changed files with 7 additions and 5 deletions

View File

@@ -53,7 +53,7 @@ fn generate_flag(flag: &'static dyn Flag, out: &mut String) {
write!(out, r", ");
}
let name = flag.name_long();
let name = flag.name_long().replace("-", r"\-");
write!(out, r"\fB\-\-{name}\fP");
if let Some(var) = flag.doc_variable() {
write!(out, r"=\fI{var}\fP");
@@ -71,7 +71,7 @@ fn generate_flag(flag: &'static dyn Flag, out: &mut String) {
if let Some(name) = flag.name_short() {
write!(out, r"\-{}/", char::from(name));
}
write!(out, r"\-\-{}", flag.name_long());
write!(out, r"\-\-{}", flag.name_long().replace("-", r"\-"));
out.push_str(r"\fP");
});
// Convert \flag-negate{foo} into something nicer.