ttscoff/mdless

Escape codes visible in code block

atsaloli opened this issue · 12 comments

Hello,

Just started using mdless. Really excited to adopt this tool, I plan to use this to teach a class, my materials are in Markdown format and I can use mdless to render them for the students live.

Small problem -- I am seeing escape codes in the code block:

image

This is with mdless 1.0.15.

pygments has my code language:

[root@ip-172-31-16-17 source]# pygmentize -L | grep cfengine
* cfengine3, cf3:
[root@ip-172-31-16-17 source]#

I am on Windows 10, and the above screenshot is in Windows Terminal. I have the same issue in the Windows console (what I get when I run bash.exe):

image

Is it me? Or is it something in mdless?

Here is my source file (just take out the backslashes), to reproduce:

The promise type is always followed by a single colon.


\```cfengine3
files:

    "/etc/nologin"

        create  => "true",
        comment => "Prevent non-root users from logging in";
\```

If I run mdless with --no-color, the escape codes disappear -- but I want the color. :)

I do not see escape codes when running pygmentize directly:

image

Here is another data point. I moved to another system (moved my development from an AWS EC2 instance to a Vagrant VM). Also moved from RHEL 8.3 to CentOS 7. What I'm seeing now is extra blank lines inserted after the line with files: in it. Also the bottom line (horizontal line) is broken:

image

Oops, I just realized I didn't install pygments. So I've installed python-pygments (python2) and now I get:

image

Well, that older pygmentize doesn't know about my language:

[root@localhost source]# pygmentize -L|grep cf3
[root@localhost source]#

Okay, I've reproduced the issue (escape codes visible in code block) using the latest pygmentize:

image

One more data point: If I add a header to my markdown source, the escape codes in the code block disappear.

image

Here is my markdown source:

image

I don't know if it is the case for you, but I worked out that I was seeing the Escape codes because my PAGER was most

export PAGER=most
 echo '#h1
' | mdless 

^[[0;1;47;90mh1 ===

The workaround is to disable the PAGER with the -P switch or change your PAGER to less or something else.

Workaround

export PAGER=less

or

echo '#h1
' | PAGER=less mdless

Sorry it took me so long to get back around to this, @atsaloli . Did you ever find a resolution for the issue?

I found a workaround @ttscoff -- see atsaloli/cf3-tutorial@fee89be

As noted in #60 (comment) my workaround is to add a header

Thanks for following up! :)

I was very happy to be able to teach my class using mdless