bat: man page display does not work correctly

Please notice that is is different from #2563 and different man colorization bugs where escape color codes are not interpreted.

What steps will reproduce the bug?

This is how man ls looks in most: image

Now let’s run PAGER="bat --style snip --theme gruvbox-dark" man ls. image

Notice two problems:

  1. ls option line is broken in the middle of color.
  2. Highlighting is broken.

The plain style looks a little bit better: the option line is not broken, but the highlighting is: image

If the --style option is omitted, there is still an erroneous line break. I was not able to get any changes by using a different colorscheme.

Bat was installed via cargo.

❯ bat --style plain --theme gruvbox-dark --diagnostic

Software version

bat 0.23.0

Operating system

freebsd 13.2-RELEASE

Command-line

bat --style plain --theme gruvbox-dark --diagnostic

Environment variables

SHELL=/usr/local/bin/bash
PAGER=most
LESS=<not set>
LANG=ru_RU.UTF-8
LC_ALL=<not set>
BAT_PAGER=<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=zenburn
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=<not set>
NO_COLOR=<not set>
MANPAGER=<not set>

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 ‘/home/alexey/.config/bat/config’: No such file or directory (os error 2).

Custom assets metadata

Could not read contents of ‘/home/alexey/.cache/bat/metadata.yaml’: No such file or directory (os error 2).

Custom assets

‘/home/alexey/.cache/bat’ not found

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-freebsd
  • Family: unix
  • OS: freebsd
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2
  • Host: x86_64-unknown-freebsd

Less version

> less --version
less 608 (POSIX regular expressions)
Copyright (C) 1984-2022  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

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 15

Commits related to this issue

Most upvoted comments

Same problem as @christianhauff. EDIT: Apparently the culprit is groff v1.23, so I added this to .zshrc and .bashrc export MANROFFOPT='-c' I don’t know what this actually does, but it seems to work.

I guess I’m following up here with a related issue. I’ve been using the MANPAGER-Snippet from the readme for several months now, and since some software updates two days ago, my manpages have some gibberish characters included:

grafik

When investigating, i found that col (included in util-linux) got updated exactly around that time and seems to behave differently, has anyone else experienced that too?

For myself, using bat-extras & less, this is how I could get proper coloring:

alias less='batpipe'
export MANPAGER="less -R --use-color -Dd+r -Du+b"
export MANROFFOPT='-c'

@ju1ius , thanks. I found this solution in the gnu groff forum, only to find it was documented in the bat readme all along!

Thanks @mjd-tech, your workaround works for me !

export MANROFFOPT=‘-c’ I don’t know what this actually does, but it seems to work.

$ man groff | grep -e '^\s*-c'
       -c     Start with color output disabled.