Comments (12)
I don't settle for bugs, so: no.
from language-ruby.
I tried playing around with this and learned a few things:
- There are a few different rules that apply to heredocs:
a. vanilla heredoc:language-ruby/grammars/ruby.cson
Lines 1817 to 1838 in d88a4cf
b. special heredocs that signal other languages (HTML, XML, SQL, GRAPHQL, CSS, CPP, C, JS, JQUERY, SH, LUA, and RUBY):language-ruby/grammars/ruby.cson
Lines 1409 to 1816 in d88a4cf
c. a more complicated vanilla pattern that covers opening multiple heredocs in the same line:language-ruby/grammars/ruby.cson
Lines 1839 to 1861 in d88a4cf
Though Atom's guide for creating a grammar is still WIP, the TextMate Manual is very helpful.
For most cases, it shouldn't be too hard to fix things. If we add a capture group for the remainder of the line, we can apply a beginCapture pattern to include source.ruby for that group.
This naive approach broke down for me when I tried to adjust the rule for multiple heredocs per line. For example, this bit of code:
<<-ONE + <<-TWO
Hello,
ONE
world!
TWO
# => "Hello, \nworld!\n"
I could sort of approximate the right behavior here, but ran into some hurdles. I think we'll have to settle for something less than perfection here, because:
the regular expressions are matched against only a single line of the document at a time.
http://manual.macromates.com/en/language_grammars#language_rules
from language-ruby.
Is there anyone looking at this? Is there anything I can do to help move the needle forward?
from language-ruby.
@envygeeks and @SampsonCrowley your comments were deleted as a violation of the Atom Code of Conduct as they were insulting or derogatory. You may both consider this an official warning.
from language-ruby.
Since this issue has been open for over three years now, I would welcome even a partial fix at this point. I agree, I don't want to settle for a partial fix indefinitely, but @SamGerber's proposed solution would solve the problem for a majority of cases.
from language-ruby.
@kevinsawicki also adding that this ends up in some funky highlighting of everything after the heredoc:
<<-SQL
"
SQL
It doesn't happen with STR but it does happen when invoking SQL, Liquid and others!
from language-ruby.
from language-ruby.
😞
I would expect line 3 to use proper highlighting at , locals: { params: params }
. In Vim:
from language-ruby.
).where(blackout_dates: { id: nil })
is all highlighted as SQL.
from language-ruby.
I'm not sure this is obtainable using regex.
from language-ruby.
@envygeeks then you'll need to test #225, because as @SamGerber and I have both discovered you'll be waiting here forever if you want a bug-free regex fix. Though I should say that your attitude is pretty discouraging for someone who just wants to help out :/.
from language-ruby.
I didn't say it had to be a "bug-free regex fix", I didn't even mention regex at all; I said, I don't settle for unfixed bugs, or being told that bugs can't be fixed. And my "attitude" is not discouraging, stop trying to shame people because they dissent to an opinion expressed.
And I am happy to test #225, but that pull-request states no way to test it, without having to build my own package, and ship into Atom editor, manually, I think it there were a beta pipeline for such testing then my comment would have never of been made in the first place as I would have traced it back here and tried it already, and started commenting.
from language-ruby.
Related Issues (20)
- Inconsistent highlighting of constants HOT 1
- Tree Sitter doesn't highlight public/private/protected HOT 1
- Symbol literals have incorrect class HOT 4
- Final `end` does not get highlighted after a block with a rescue inside a method HOT 2
- Inconsistency in Ruby symbol with TreeSitter HOT 2
- where is the path language-ruby get installed to on Windows HOT 1
- Hello HOT 1
- Failed to load a language-ruby package grammar - RHEL 7.7 HOT 20
- Failed to load a language-ruby package grammar HOT 1
- Syntax highlighting stops after <<base in for-each statement
- VS code support HOT 1
- Regex causes Gray (discolored) for large portion of Beginning HOT 13
- Abandoned? HOT 7
- Inconsistent highlighting of heredocs HOT 1
- Syntax highlighting broken in Markdown with inline comment at method definition line
- No release since Nov 2019 HOT 5
- Escaped characters in Ruby regex throws off color syntax highlighter HOT 3
- self.public shouldn't be colored as keyword
- Heredoc wrong colors
- Inconsistent color of local variable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from language-ruby.