ttscoff / mdless

MIT License
871 stars 39 forks source link

Escape codes visible in code block #60

Closed atsaloli closed 3 years ago

atsaloli commented 3 years ago

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. :)

atsaloli commented 3 years ago

I do not see escape codes when running pygmentize directly:

image

ttscoff commented 3 years ago

I'll have to look into this, can't guarantee I'll get to it right away.

-Brett

On 14 Jan 2021, at 23:18, Aleksey Tsalolikhin wrote:

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. :)

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/ttscoff/mdless/issues/60

atsaloli commented 3 years ago

Got it, and thank you very much for the acknowledgement, Brett! :)

Best, Aleksey

On Fri, Jan 15, 2021 at 4:17 AM Brett Terpstra notifications@github.com wrote:

I'll have to look into this, can't guarantee I'll get to it right away.

-Brett

On 14 Jan 2021, at 23:18, Aleksey Tsalolikhin wrote:

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. :)

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/ttscoff/mdless/issues/60

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ttscoff/mdless/issues/60#issuecomment-760909040, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD4GIDANW223RVJR6HY3P3S2AW5JANCNFSM4WDQZMEA .

-- Achieve real learning. Email training@verticalsysadmin.com.

atsaloli commented 3 years ago

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

atsaloli commented 3 years ago

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

image

atsaloli commented 3 years ago

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

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

atsaloli commented 3 years ago

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

image

atsaloli commented 3 years ago

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

sebastianoc commented 3 years ago

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
atsaloli commented 3 years ago

Thanks, sebastiano. My pager is "less". :)

Best, Aleksey

On Mon, Jan 18, 2021 at 2:50 AM sebastiano notifications@github.com wrote:

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ttscoff/mdless/issues/60#issuecomment-762164516, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD4GIGCI5FSK2BLG5EUY2TS2QG7FANCNFSM4WDQZMEA .

-- Achieve real learning. Email training@verticalsysadmin.com.

ttscoff commented 3 years ago

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

atsaloli commented 3 years ago

I found a workaround @ttscoff -- see https://github.com/atsaloli/cf3-tutorial/commit/fee89bed625a7ce2103371443a3444a91956f9da

As noted in https://github.com/ttscoff/mdless/issues/60#issuecomment-761881981 my workaround is to add a header

Thanks for following up! :)

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