eraserhd / kak-ansi

Kakoune support for rendering ANSI-colored text.
https://github.com/eraserhd/kak-ansi
The Unlicense
41 stars 5 forks source link

Does not work as a pager in `man` #8

Closed Akiiino closed 3 years ago

Akiiino commented 3 years ago

Hi! Not sure if this is within the intended scope of the project — I'm not really familiar with the details of formatting text in terminals, but:

I've installed this plugin via plug.kak, and it seems to work well as a pager: PAGER=kak git log has colors and looks great. PAGER=kak man man however — not so much:

       man - format and display the on-line manual pages                                                                                                                                    

S�SY�YN�NO�OP�PS�SI�IS�S                                                                                                                                                                    
       m�ma�an�n [-�-a�ac�cd�df�fF�Fh�hk�kK�Kt�tw�wW�W] [-�--�-p�pa�at�th�h] [-�-m�m _�s_�y_�s_�t_�e_�m] [-�-p�p _�s_�t_�r_�i_�n_�g] [-�-C�C _�c_�o_�n_�f_�i_�g_�__�f_�i_�l_�e] [-�-M�M     
       _�p_�a_�t_�h_�l_�i_�s_�t] [-�-P�P _�p_�a_�g_�e_�r] [-�-B�B _�b_�r_�o_�w_�s_�e_�r] [-�-H�H _�h_�t_�m_�l_�p_�a_�g_�e_�r] [-�-S�S _�s_�e_�c_�t_�i_�o_�n_�__�l_�i_�s_�t]                 
       [_�s_�e_�c_�t_�i_�o_�n] _�n_�a_�m_�e _�._�._�.                                                                                                                                       

D�DE�ES�SC�CR�RI�IP�PT�TI�IO�ON�N                                                                                                                                                           
       m�ma�an�n  formats  and  displays the on-line manual pages.  If you specify _�s_�e_�c_�t_�i_�o_�n, m�ma�an�n only looks in that section of the manual.  _�n_�a_�m_�e is normally the 
       name of the manual                                                                                                                                                                   
       page, which is typically the name of a command, function, or file.  However, if _�n_�a_�m_�e contains a slash (/�/) then m�ma�an�n interprets it as a file specification, so that you

       can do m�ma�an�n .�./�/f�fo�oo�o.�.5�5 or even m�ma�an�n /�/c�cd�d/�/f�fo�oo�o/�/b�ba�ar�r.�.1�1.�.g�gz�z.                                                                           

       See below for a description of where m�ma�an�n looks for the manual page files.                                                                                                      

M�MA�AN�NU�UA�AL�L S�SE�EC�CT�TI�IO�ON�NS�S                                                                                                                                                 
       The standard sections of the manual include:                                                                                                                                        
[...]

Without any styling, of course.

I've tried all combinations of ansi-enable/disable/render/clear without any changes. Am I doing something wrong? I'm using macOS with kitty as my terminal, if that's relevant.

eraserhd commented 3 years ago

Interesting. I never noticed this, since I have a shell function to run kakoune that predates kak-ansi:

man () {
    if (( $# == 2 ))
    then
        kak -e "man $2($1)"
        return $?
    else
        kak -e "man $*"
        return $?
    fi
}

Anyway, the same thing happens here (surprisingly!). These are not technically ANSI escapes, but really old line printer hacks -- but:

  1. We should support them, as there is no reason not to.
  2. My man page for man says it can use color, so I wonder why it isn't using ANSI escapes.
eraserhd commented 3 years ago

After investigating, on Mac OS, in /etc/man.conf, groff is passed -c which disables color and uses this old format.

eraserhd commented 3 years ago

This has been implemented in v0.2.4, which I just released. Specifically bolding and underline and bold+underline have been covered, and I suspect that's all there is. It looks good for me, but if you see something amiss, let me know.