junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
61.81k stars 2.35k forks source link

[man] Escape hyphens to prevent conversion to Unicode hyphens #3885

Closed akinomyoga closed 1 week ago

akinomyoga commented 1 week ago

ASCII hyphens (U+002D HYPHEN-MINUS) in the option names (e.g. -x and --extended) and the code examples in the man page source should be escaped as \- (e.g. \-x and \-\-extended) to prevent them being converted to Unicode hyphens in some environments.

For example, in openSUSE Tumbleweed, the raw ASCII hyphens in the man-page sources are configured to become the Unicode hyphen (U+2010 HYPHEN). This makes it impossible to search the option names on the fzf man page by e.g. /--extendedRET. A problem also arises in copying and pasting option names and code examples from the man page. It appears to be a normal ASCII hyphen by appearance (in typical terminal fonts) but is not recognized as the ASCII hyphen when specified in command-line arguments of the fzf command.

An explanation can also be found in the corresponding section in man man-pages:

   Generating optimal glyphs
       Where a real minus character is required (e.g., for numbers such as -1,
       for man page cross references such as utf-8(7), or when writing options
       that  have a leading dash, such as in ls -l), use the following form in
       the man page source:

           \-

       This guideline applies also to code examples.

       The use of real minus signs serves the following purposes:

       o  To provide better renderings on various  targets  other  than  ASCII
          terminals, notably in PDF and on Unicode/UTF-8-capable terminals.

       o  To generate glyphs that when copied from rendered pages will produce
          real minus signs when pasted into a terminal.
junegunn commented 1 week ago

Thanks for the patch.

This is painful, though. So this is the only way?

akinomyoga commented 1 week ago

I added another fix: 49356cb6fc726145357235b9261e3c6566c4eef9.

akinomyoga commented 1 week ago

This is painful, though. So this is the only way?

Yeah, I agree, but as far as I know, there is no other way. Usually the option names are escaped like \-\-help in man-page sources.

junegunn commented 1 week ago

Merged, thanks!

akinomyoga commented 1 week ago

Thanks!