davidrios / pug-tmbundle

A comprehensive textmate / sublime text bundle for the Pug (formerly Jade) template language.
https://github.com/davidrios/pug-tmbundle
MIT License
48 stars 20 forks source link

Missing support for ES2015 backtick interpolations involving "//" #1

Closed jceipek closed 1 year ago

jceipek commented 8 years ago

Pug no longer supports interpolation inside attributes using the hash brace syntax "#{ }". It does support ES2015 template literals ${ } (see https://github.com/pugjs/pug/issues/2346).

However, the syntax definition in pug-tmbundle breaks when these literals include //, which shows up near the start of URI schemes like http, file, etc...

Here's an example usecase:

a(href=`http://twitter.com/${twitter_handle}`) @#{twitter_handle}

Everything from the // onwards on the same line gets treated as a comment and the remainder of the file stops syntax highlighting properly.

screen shot 2016-05-06 at 6 33 14 pm
davidrios commented 8 years ago

I could fix this on my end, but I'm wondering if I should. If you're writing ES6 code you probably should have an ES6 plugin, like Babel, in which case you won't have that problem. On the other hand, if I fix it on my end you'll loose ES6 highlighting if you do use a plugin, like this:

If you use Babel: screenshot - 05072016 - 02 32 50 pm

and if I fix it on my end: screenshot - 05072016 - 02 33 08 pm

jceipek commented 8 years ago

As far as I can tell, pug uses the node.js javascript engine, which has supported template literals for a long time (see http://node.green/#template-literals).

I would be fine using an ES2015 (ES6) plugin; in fact I have https://github.com/babel/babel-sublime installed right now. I could be missing something obvious, but I'm not sure how to "stack" the syntax highlighting for Pug and ES2015 in Sublime Text without manually editing tmbundles. Is that possible?

davidrios commented 8 years ago

I was indeed talking about the editor, not the interpreter. tmbundle highlighters can reference one another, I reference the javascript highlighter when I detect a javascript code block. I also have babel-sublime installed and for some reason in my editor it automatically replace the default javascript bundle when another bundle includes javascript. I'll have to investigate why that happens here.

jceipek commented 8 years ago

That's interesting. There's two immediate things I can think of that might be the culprit: