mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 14:34:05 +00:00
__fish_print_help: Fix unicode characters
This is nroff/groff being broken. It turns "→" into "â". This is even if we select `-Tutf8` and friends. So, if mandoc exists, we prefer that, and otherwise, run preconv on the file first (if it exists). Really, what we would need to to is tell nroff to pass `-KUTF-8` to groff, but that doesn't appear to be possible.
This commit is contained in:
parent
45de6d167d
commit
9e86ffe3bc
1 changed files with 20 additions and 8 deletions
|
@ -22,7 +22,13 @@ function __fish_print_help --description "Print help message for the specified f
|
||||||
end
|
end
|
||||||
|
|
||||||
# Pick which command we are using to render output or fail if none
|
# Pick which command we are using to render output or fail if none
|
||||||
if command -qs nroff
|
# We prefer mandoc because that doesn't break with unicode input.
|
||||||
|
if command -qs mandoc
|
||||||
|
set format mandoc -c
|
||||||
|
if test -n "$cols"
|
||||||
|
set -a format -O width=$cols
|
||||||
|
end
|
||||||
|
else if command -qs nroff
|
||||||
set format nroff -c -man -t
|
set format nroff -c -man -t
|
||||||
if test -e $__fish_data_dir/groff/fish.tmac
|
if test -e $__fish_data_dir/groff/fish.tmac
|
||||||
set -a format -M$__fish_data_dir/groff -mfish
|
set -a format -M$__fish_data_dir/groff -mfish
|
||||||
|
@ -30,21 +36,27 @@ function __fish_print_help --description "Print help message for the specified f
|
||||||
if test -n "$cols"
|
if test -n "$cols"
|
||||||
set -a format -rLL={$cols}n
|
set -a format -rLL={$cols}n
|
||||||
end
|
end
|
||||||
else if command -qs mandoc
|
|
||||||
set format mandoc -c
|
|
||||||
if test -n "$cols"
|
|
||||||
set -a format -O width=$cols
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
echo fish: (_ "Cannot format help; no parser found")
|
echo fish: (_ "Cannot format help; no parser found")
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if test -e "$__fish_data_dir/man/man1/$item.1"
|
if test -e "$__fish_data_dir/man/man1/$item.1"
|
||||||
|
# Some nroff versions screw up non-ascii characters.
|
||||||
|
# (even with the locale set correctly!)
|
||||||
|
# Work around that by running preconv first.
|
||||||
|
if command -sq preconv; and test "$format[1]" = nroff
|
||||||
|
set help (preconv -e UTF-8 "$__fish_data_dir/man/man1/$item.1" | $format 2>/dev/null)
|
||||||
|
else
|
||||||
set help ($format "$__fish_data_dir/man/man1/$item.1" 2>/dev/null)
|
set help ($format "$__fish_data_dir/man/man1/$item.1" 2>/dev/null)
|
||||||
|
end
|
||||||
else if test -e "$__fish_data_dir/man/man1/$item.1.gz"
|
else if test -e "$__fish_data_dir/man/man1/$item.1.gz"
|
||||||
|
if command -sq preconv; and test "$format[1]" = nroff
|
||||||
|
set help (gunzip -c "$__fish_data_dir/man/man1/$item.1.gz" 2>/dev/null | preconv -e UTF-8 | $format 2>/dev/null)
|
||||||
|
else
|
||||||
set help (gunzip -c "$__fish_data_dir/man/man1/$item.1.gz" 2>/dev/null | $format 2>/dev/null)
|
set help (gunzip -c "$__fish_data_dir/man/man1/$item.1.gz" 2>/dev/null | $format 2>/dev/null)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# The original implementation trimmed off the top 5 lines and bottom 3 lines
|
# The original implementation trimmed off the top 5 lines and bottom 3 lines
|
||||||
# from the nroff output. Perhaps that's reliable, but the magic numbers make
|
# from the nroff output. Perhaps that's reliable, but the magic numbers make
|
||||||
|
|
Loading…
Reference in a new issue