asciidoctor / atom-language-asciidoc

⚛ AsciiDoc language package for the Atom editor.
https://atom.io/packages/language-asciidoc
MIT License
42 stars 20 forks source link

`if` keyword in bash source leaks highlighting outside code block #191

Open chaitanyathengdi opened 6 years ago

chaitanyathengdi commented 6 years ago

Description

I was writing code snippets in an AsciiDoc document using the bash syntax highlighter, and I noticed that the highlighting was leaking outside the [source,bash] block. This is evident after the "let's" in the bottom of the screenshot below:

Screenshots

leaking highlighting

Syntax example

[source,bash]
----
~/poems/The Road Not Taken$ git checkout my_first_poem
Switched to branch 'my_first_poem'
~/poems/The Road Not Taken$ cat >> poem.txt
Oh, I kept the first for another day!
Yet knowing how way leads on to way,
I doubted if I should ever come back.
~/poems/The Road Not Taken$ git add poem.txt
~/poems/The Road Not Taken$ git commit -m "A Road Not Taken: Add the third verse, second part"
[my_first_poem d68c1b5] A Road Not Taken: Add the third verse, second part
 1 file changed, 3 insertions(+)
~/poems/The Road Not Taken$
----

Okay. Now Let's bring both the changes together.

If I remove the "if" in the poem above or replace it with something else, the problem goes away:

screenshot from 2018-08-14 16-59-25

This is problematic. I can't just remove that "if" because I need it to be there, and in any case this shouldn't happen.

ldez commented 6 years ago

This needs to be reported here: https://github.com/atom/language-shellscript. This language simply delegates to that language, so if that language grammar does not terminate, the parsing bleeds outside of the listing block.

chaitanyathengdi commented 6 years ago

I've found this also happens with single quoted strings. Isn't there a way to limit the highlighting to the ending ----?

ZxCine commented 5 years ago

Hello!

The same thing happens when there are multiple sequential square brackets in the source block - e.g.

[attr 1 value 1 [attr2 value2...]] -> source syntax exceeds block bounds [attr 1 value 1 [attr2 value2...] ] -> whitespace added between ]], source syntax does not exceed block bounds

On top of that, if the source block is contained in another block, such as an example one, the issue does not appear.