Closed calebmeyer closed 7 years ago
Thanks for the report. You're right, I wasn't aware that the multi-line syntax requires a trailing pipe. I usually don't use pipes, so that's why I didn't catch it. I'll get a fix out soon.
I haven't forgotten about this, it's just proven a lot harder to fix than I initially thought. Hopefully I'll have some time this weekend to work on it a bit more.
No problem. Thanks for your work!
This is happening because a region of embedded Ruby highlighting isn't terminating at the closing }
character:
If you remove the trailing pipe from the line containing the closing brace, everything suddenly highlights fine:
This line is to blame. I've attached a patch below that fixes this. However, I don't know a single thing about Haml, so I have no idea if these changes are valid syntax or not. I'll leave it up to you.
diff --git a/grammars/ruby haml.cson b/grammars/ruby haml.cson
index d6aab60..a3db55c 100644
--- a/grammars/ruby haml.cson
+++ b/grammars/ruby haml.cson
@@ -18,6 +18,9 @@
]
}
{
+ 'include': '#continuation'
+ }
+ {
'match': '^(!!!)($|\\s.*)'
'name': 'meta.prolog.haml'
'captures':
@@ -78,14 +81,14 @@
}
{
'begin': '(?<!\\#)\\{(?=.+(,|(do)|\\{|\\}|\\||(\\#.*))\\s*)'
- 'end': '\\s*\\}(?!\\s*\\,)(?!\\s*\\|)(?!\\#\\{.*\\})'
+ 'end': '\\s*\\}'
'name': 'meta.section.attributes.haml'
'patterns': [
{
- 'include': 'source.ruby.rails'
+ 'include': '#continuation'
}
{
- 'include': '#continuation'
+ 'include': 'source.ruby.rails'
}
{
'include': '#rubyline'
@@ -147,10 +150,10 @@
'name': 'meta.section.object.haml'
'patterns': [
{
- 'include': 'source.ruby.rails'
+ 'include': '#continuation'
}
{
- 'include': '#continuation'
+ 'include': 'source.ruby.rails'
}
{
'include': '#rubyline'
@@ -288,7 +291,7 @@
]
'repository':
'continuation':
- 'match': '(\\|)\\s*\\n'
+ 'match': '(\\|)\\s*$\\n?'
'captures':
'1':
'name': 'punctuation.separator.continuation.haml'
@Alhadis from my tests that works great. I'll cut another patch release in a minute. Appreciate the help in getting this cleaned up. 🙂
Actually, it might be worth waiting until another issue is fixed with comments. See here.
Here's an example of an affected code block:
/ HAML comment
- # ruby comment
string
= "string"
= "string" #comment
= "string #{not_comment}" # comment
Notice how #{not_comment}
is being coloured like, well, a comment.
Hmm, it renders fine in Atom. Do you know why it's rendering different on GitHub?
Thats currently what I'm waiting on GitHub staff to help with before I can properly investigate. =) The webapp we use to preview syntax highlighting is showing the same result as Atom does. This is probably due to outdated dependencies (it's using an ancient version of Linguist to generate previews), so... we'll see once the upgrade is finished.
Gotcha! Sounds good. I'll subscribe that issue so I'll know if I need to do anything, then I can cut a new patch release for this issue once that's all figured out.
OS: Ubuntu 16.04 Atom: 1.17.0 language-haml: 0.24.2
EDIT: This issue presented itself after updating to 0.24.2.
Hi! This seems related, but if it's not, I can create a new issue. I'm seeing syntax highlighting breaking on line continuation as well. But I'm not using the pipe character, I'm breaking to the next line after a comma, which is allowed according to the Haml docs. Removing the line break after the comma un-breaks the syntax highlighting.
@ayaankazerouni could you try the latest patch version?
Ok, everything looks good now. Thanks!
I took this screenshot with One Dark Syntax so that we'd have a common test ground. The markup:
It appears that pipe characters break the syntax highlighting. They also are highlighted differently (under my usual syntax theme, photon syntax) sometimes. Randomly they'll be white or purple, and I can't really figure out why. Also if you have an id before the attribute braces in the anchor tag above, it doesn't fix the highlighting (everything after the
#
is comment colored)