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

Syntax highlighting doesn't work properly for fish man pages #3025

Open
injust opened this issue Jul 1, 2024 · 3 comments
Open

Syntax highlighting doesn't work properly for fish man pages #3025

injust opened this issue Jul 1, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@injust
Copy link

injust commented Jul 1, 2024

What steps will reproduce the bug?

  1. Use fish shell
  2. set -Ux MANPAGER "sh -c 'col -bx | bat -l man -p'"
  3. type --help, fish_add_path --help, etc.

What happens?
Anything that isn't indented is syntax highlighted orange, ignoring any actual formatting.

What did you expect to happen instead?
The man page should be highlighted reasonably.

I think this might be happening because fish's man pages aren't indented? But I couldn't find anything suggesting that man page sections have to be indented, so if this is the reason, then the syntax highlighting should be able to tolerate fish's non-indented man page format.

Screenshots

SCR-ls
SCR-type
SCR-fish_add_path

How did you install bat?

Homebrew


Software version

bat 0.24.0

Operating system

macOS 14.5 (Darwin 23.5.0)

Command-line

bat --diagnostic 

Environment variables

SHELL=/usr/local/bin/fish
PAGER=<not set>
LESS=<not set>
LANG=en_CA.UTF-8
LC_ALL=<not set>
BAT_PAGER=<not set>
BAT_PAGING=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER='sh -c '\''col -bx | bat --language=man --style=plain'\'''

System Config file

Could not read contents of '/etc/bat/config': No such file or directory (os error 2).

Config file

Could not read contents of '/Users/jsu/.config/bat/config': No such file or directory (os error 2).

Custom assets metadata

bat_version: 0.24.0
creation_time:
  secs_since_epoch: 1719638264
  nanos_since_epoch: 856140000

Custom assets

  • metadata.yaml, 97 bytes
  • syntaxes.bin, 915557 bytes
  • themes.bin, 57307 bytes

Compile time information

  • Profile: release
  • Target triple: x86_64-apple-darwin
  • Family: unix
  • OS: macos
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: cmpxchg16b,fxsr,popcnt,sse,sse2,sse3,sse4.1,sse4.2,ssse3
  • Host: x86_64-apple-darwin

Less version

> less --version 
less 643 (PCRE2 regular expressions)
Copyright (C) 1984-2023  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less
@injust injust added the bug Something isn't working label Jul 1, 2024
@flohw
Copy link

flohw commented Jul 5, 2024

Hi,

I have a similar issue, I think. I use zsh 5.9, bat 0.24 (installed via arch official repository) and I have MANPAGER=sh -c 'col -bx | bat -l man -p' too.
Not everything is orange for me but I have some color character which make it hard to read.

2024-07-05-153013_553x329_scrot

It works better with MANPAGER="bat -l man"`
2024-07-05-153233_586x306_scrot

But sometimes the behavior is very strange.
2024-07-05-153334_804x532_scrot

Let me know if you need more info.

Thank you

@anurag-roy
Copy link

@flohw Think your issue is different.

Can you check your groff version using

groff -v

And if it's 1.23.0, try adding MANROFFOPT='-c' and that should fix it.

@flohw
Copy link

flohw commented Jul 8, 2024

After some experimentations with my env vars, defining this variable worked fine.
Thank you

Some explanation if anyone struggle to configure it to their need:

 # For global use across the system (in your bashrc/zshrc)
export MANROFFOPT='-c'
# For local script global useage
MANROFFOPT='-c'
man -P "$MANPAGER' --paging always'" <man entry>
# For online usage
MANROFFOPT='-c' man -P $MANPAGER <man entry>

Note that I haven't tested each one and only based them on my experience. I hope to not have make mistake. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants