Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline #20

Closed
jclusso opened this issue Nov 19, 2014 · 35 comments
Closed

Multiline #20

jclusso opened this issue Nov 19, 2014 · 35 comments

Comments

@jclusso
Copy link

jclusso commented Nov 19, 2014

multiline code highlighting doesn't work in ruby haml.

=link_to settings_campaign_url(@campaign),
            class: active_page == "settings" ? "active" : "" do
@cannikin
Copy link
Collaborator

I've recently merged in a couple of pull requests, did that fix this for anyone?

@jclusso
Copy link
Author

jclusso commented Nov 24, 2014

Nope. @cannikin, you gotta merge #22 which fixes a lot of things with multiline support. This however still is not resolved there as of last I checked.

screen shot 2014-11-24 at 3 36 26 pm

@cannikin
Copy link
Collaborator

Okay, watch to check out my master and make sure it works? GitHub was telling me it couldn't be automatically merged via pull request but when I did it locally it worked just fine, so I hope I didn't break something!

@cannikin
Copy link
Collaborator

If it looks good then I'll release an official version.

@jclusso
Copy link
Author

jclusso commented Nov 24, 2014

Appears to fix everything but the ruby lines now.
screen shot 2014-11-24 at 4 15 40 pm

@jclusso
Copy link
Author

jclusso commented Nov 24, 2014

I tried to fix the ruby lines myself but I was struggling and it looked like @richrace was doing a good job on the other stuff. Maybe he can figure it out. My regex skills are weak and I have little experience writing these language files.

@richrace
Copy link
Contributor

Right, for the multiline ruby code it's a bit complicated and not sure how to go about getting it to work.

Basically I have this regex: ((do|\{)( \|[^|]+\|)?)$|((\w|\}|"|\'|\))\s*(\|?)$) which when tested on these strings:

  = link_to_remote "Add to cart",
      :url => { :action => "add", :id => product.id },
      :update => { :success => "cart", :failure => "error" }
  .div
  = link_to_remote "Add to cart"
  .div
  = link_to_remote 'Add to cart'
  .div
  = link object
  .div
  = render(object,
    :template => "Test"
    )
  .div
  = link_to_remote "Add to cart", |
    :url => { :action => "add", :id => product.id }, |
    :update => { :success => "cart", :failure => "error" } |
  .div
  = link_to_remote "Add to cart", |
    :url => { :action => "add", :id => product.id }, |
    :update => "test" |
  .div

Should get the last terminator, and I believe it should go on this line: https://github.com/cannikin/language-haml/blob/master/grammars/ruby%20haml.cson#L207

However, I can't get it to work for all instances. For example, it works with the pipe terminators, but if you remove them then it breaks the rest of the formatting until there is a pipe.

I hope this helps you @jclusso and others :)

(This is the properly escaped regex for Atom: ((do|\\{)( \\|[^|]+\\|)?)$|((\\w|\\}|"|\'|\\))\\s*(\\|?)$))

@jclusso
Copy link
Author

jclusso commented Nov 24, 2014

@richrace, this is for vim but tpope is a vim boss and his works :) https://github.com/tpope/vim-haml/blob/master/syntax/haml.vim Maybe you can get some ideas from that?

Either way, I'm gonna get my buddy who is much better at regex to help me look it. I'll update later tonight when I get a chance to play around with this.

@richrace
Copy link
Contributor

Seems like the TextMate bundle, which this is based off, is having the same issue: textmate/ruby-haml.tmbundle#9

@jclusso
Copy link
Author

jclusso commented Nov 24, 2014

@richrace textmate and sublime both are broken on this functionality unfortunately :(

@jclusso
Copy link
Author

jclusso commented Dec 23, 2014

I was unable to make any progress. Anyone else have any luck?

@iRet
Copy link
Contributor

iRet commented Mar 4, 2015

I found a problem with end of attributes '}' regex it works wrong when I'm using hashes inside attributes
image

Just created PR to fix it
image

@jclusso
Copy link
Author

jclusso commented Mar 4, 2015

@iRet do you have any idea how to fix the ruby syntax?

@iRet
Copy link
Contributor

iRet commented Mar 4, 2015

@jclusso oh, haven't seen it yet, let me try

@jclusso
Copy link
Author

jclusso commented Mar 4, 2015

@iRet if you fix that I'll be so happy :)! I gave up and I think @richrace did to because we both couldn't figure it out.

@iRet
Copy link
Contributor

iRet commented Mar 4, 2015

@jclusso just fixed ruby strings and updated PR
Still see some issues with html tags but that's enough for today :) will dig it later
image

@jclusso
Copy link
Author

jclusso commented Mar 5, 2015

Awesome, @iRet! I'll try it out and see how it works

@iRet
Copy link
Contributor

iRet commented Mar 5, 2015

@jclusso sorry but it still buggy. Actually I can figure it out for sublime haml package, it's pretty same ported textmate bundle with a minor changes, but python regexp support negative lookahead, so we can say 'end of line but not prepended with comma'. Will try again this weekends.

@jclusso
Copy link
Author

jclusso commented Mar 5, 2015

@iRet cool! I appreciate you trying to fix this

@jclusso
Copy link
Author

jclusso commented Mar 17, 2015

@iRet did you ever get the ruby line working?

@cannikin
Copy link
Collaborator

Anything mergeable or we still looking at fixes?

@iRet
Copy link
Contributor

iRet commented Mar 17, 2015

@jclusso not fully, actually attributes and ruby lines looks ok now, but it caused new issues with haml/html tags
test_html_haml_-_users_artyom_desktop-_atom
Still had no time for a deeper look into it. And switched to sublime, where I'm using similar fixes but it not causes this tags bug.
I've just updated updated my PR if you interested in testing, another things seems fine as far as I tested.

@iRet
Copy link
Contributor

iRet commented Mar 17, 2015

It seems like problem not in rubyline end pattern, just tried to add quotes to it, no effect. And tags higlighted as text not as ruby code.
It could be in html tag start pattern, but it is almost the same like in sublime package, so weird.

@jclusso
Copy link
Author

jclusso commented Mar 17, 2015

Yea, idk if it's of any use but I linked above to a working syntax highlighter for vim written by tpope. I'm not well enough versed to pick the regex apart or i'd do it myself. @iRet

https://github.com/tpope/vim-haml/blob/master/syntax/haml.vim

@olivierlacan
Copy link

Anyone still working on this? This is still an issue in 0.21.0.

@cannikin
Copy link
Collaborator

cannikin commented Sep 1, 2015

Sorry, I was supposed to be transferring ownership of this to someone who had the time to devote to maintaining it. @ezekg offered to take it over a few months ago but I dropped the ball. Anyone else?

@ezekg
Copy link
Collaborator

ezekg commented Sep 17, 2015

@cannikin, if needed, I would like to help out with this still. I use this package every day.

@cannikin
Copy link
Collaborator

Great! Any idea what steps we go through to transfer ownership? Moving the repo should be easy? But I don't know about the APM package...

@ezekg
Copy link
Collaborator

ezekg commented Sep 17, 2015

I'm not entirely sure. I've never done that. I can look into it later today, though.

As far as I can tell, I think I have this issue resolved by rewriting the ruby haml.cson file (essentially just copying the current Sublime text implementation), and cleaning up a couple regexes (adding a little recursion for commas/blocks). I'll post it here soon and see if we can get a new version out to test.

When this issue is fixed, I want to start work on a PHP Haml grammar. I'll also need people to test the Coffee Haml, because I've never used that.

@olivierlacan
Copy link

I'd be down to help out once @ezekg takes over.

This is how you transfer ownership: https://atom.io/docs/latest/behind-atom-maintaining-your-packages#transferring-ownership

@cannikin
Copy link
Collaborator

Great! Transfer initiated! Apparently you just transfer ownership of the repo and the package will magically go over as well.

@ezekg
Copy link
Collaborator

ezekg commented Sep 17, 2015

I think I have everything working nicely. Still a couple issues with filters and trimmed whitespace, but nothing huge. Looking good. I'll continue to test this week before creating a new beta version. 👍

image

Anything I should know about going package releases? Does it go by tagged releases?

@jclusso
Copy link
Author

jclusso commented Sep 17, 2015

Nice that this finally looks to be getting fixed! Too bad we've started a heavy migration to Slim since Haml is just not nearly as fast. :(

@olivierlacan
Copy link

@ezekg More 🍰 for you!

@ezekg
Copy link
Collaborator

ezekg commented Sep 18, 2015

Everybody test out the new version (0.22.0). Let me know if you find any new issues or edge cases I missed. I'm going to close this issue until told otherwise. 👌

@ezekg ezekg closed this as completed Sep 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants