axiros/terminal_markdown_viewer

Code block highlight becomes broken if code block contains ${variable} and symbol '<'

slavniyteo opened this issue · 3 comments

Hello. I printscrined the problem:
2017-07-27 09-52-33

I used next markdown sources (you may use it for test, for example):

# Hello

Look at next code block.

    command -stdin <<EOP
    first line in stdin
    second line in stdin
    EOP

This is similar code block with ${variable} highlighted. But it looks broken.

    command -stdin ${variable} <<EOP
    first line in stdin
    second line in stdin
    EOP

It looks broken even if ${variable} present anywhere in code block.

    command -stdin <<EOP
    first line in stdin
    second line in stdin
    EOP

    ${variable}

Actually it works if code block contains ${variable} and <:

    First string <
    Second string with ${var}.
    Third string.

# The end.
axgkl commented

hey, verified, not exactly pretty...

The problem is the which lexer pygments chooses to take. With your file it seems to choose "TextLexer".

You can influence that decision.

1. Via the markdown source, e.g.:

screen shot 2017-07-28 at 00 56 31

renders to:
screen shot 2017-07-28 at 00 56 46

2. Via the cli:

screen shot 2017-07-28 at 00 57 10

( -x switches off the guessing and -X bash says default to take is the bash lexer)

hope one of those options is feasible for you - or should I introduce a mode where all code is gray always if not explicitly given... Hmmm...

axgkl commented

re-open if not happy.

Thank you for detailed answer.
I like ```bash-like style (I have not a lot of experience with Markdown), it provides explicit language declaration. It is good, I think.

But may markdown viewer highlight all lines in block <<EOF ... EOF instead only first <<EOF?

I have not permissions to reopen the issue.