Closed olivierlacan closed 8 years ago
Thanks. I've had a really tough time with this one. I can't find a good regex for matching a filter's 'end' when the white space gets trimmed. If you left the white space there, it would work fine. But, since it gets trimmed, the regex thinks that the filter has been exited and that the remaining text is plaintext. You can see the issue with the trimmed whitespace below (one has been trimmed, the other hasn't):
If I do it the way it was done before, all text below the filter gets highlighted wrong if there's no newline between the filter and any regular Haml directly following the filter (sometimes the highlighting is wrong regardless of whether there's a newline or not, oddly). I chose the lesser of the 2 evils for now, because having an entire file with broken syntax highlighting isn't fun.
Maybe there's a way to track the amount of indentation and only exit when that goes below a certain threshold, but I'm not entirely sure that's possible with just a couple regexes.
I knew my pedantic whitespace trimming ways would one day come to bite me again. :-)
This is really a tricky one. I'll ask people more familiar with fancy regex.
Let me know if you figure anything out. I've tried multiple ways, but nothing seems to handle every edge case. If only a regex could keep a counter... lol.
Digging in more. You would have to be able to handle cases like this:
- some_ruby do
:coffee
class Klass
constructor: () ->
do someFunc
# ...
Some plain text here...
- some_more_ruby do
:coffee
do something -> @.somethingElse()
# ...
- ruby_stuff "after", :filters
= and_more_ruby "here"
As you can see, I think Github's syntax highlighting handles this the same way I'm currently handling it. (...unless it's actually depending on this package :boom:)
Figured it out. Let me know if you find any issues. :+1:
Nice! Checking it out :-)
Fix confirmed, great work @ezekg! :smile_cat:
Boom! 0 open issues.
( •_•)
( •_•)>⌐■-■
(⌐■_■)
@ezekg You asked for feedback and this is the only odd thing I've noticed since the last release (0.22.2):
This
:javascript
filter is highlighted properly:While this one isn't:
If I remove the new line between the first
var
declaration and the second, the highlighting turns back on: