ThisIsMissEm / jade-tmbundle

[DEPRECATED] A textmate bundle for the Jade language
http://jade-lang.com
220 stars 81 forks source link

source.js.embedded.jade end issue #15

Open aoberoi opened 12 years ago

aoberoi commented 12 years ago

there seems to be a problem with the way the source.js.embedded.jade scope is terminated. let me show you what i mean:

(A) these work

  1. working example
  2. working example
  3. working example
  4. working example

    (B) these don't, but should

notice the change in color of the body tag, this should be blue like all the other tags

  1. not working example
  2. not working example
  3. not working example
  4. not working example
  5. not working example

the weirdest issue is that (A1) and (A2) work, the only difference being how much white space there is on line 5; but (B3), (B4), and (B5) do not. (B3) actually puts the newline between (A1) and (A2) and intermediately doesn't want to work.

i'm aware you're no longer actively maintaining this project and that you are accepting pull requests. my regex-foo isn't good enough to make a fix and i think for now this is the best place to make issues visible.

aoberoi commented 12 years ago

looking at this a little more carefully i'm trying to destruct the regex for source.js.embedded.jade. the following definition in the property for 'end' looks problematic:

^((?=(\1)([\w#\.]|$\n?))|^$\n?)

the capturing group only captures exactly the same number of spaces that is before the 'script' keyword in the 'begin' property. the result is that direct siblings of the source tag look fine, but any higher (uncle, grand-uncle, etc) look like they are still part of the script block because it didn't match the requirement for 'end'.

i'm not sure how to solve it because im not that good at regex, but it seems like the correct logic would be to change that to match anything equal to that number of spaces or less. is this a good place to use the recursion available in defining textmate language grammars to do pseudo-counting?

efolio commented 11 years ago

Hi,

I'm not sure if I understand the bug here, since the examples in the 1st post are 404-ing, but my issue resembles this one:

To reproduce:

script
    test("test");

Fun thing, the single quote doesn't do the same (but fails anyway):

script
    test('test');

Additionnaly, the // of URLs in the script comment the rest of the line too (and thus highlights in the comment's color):

script
    window.jQuery    || window.loadLib("//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js");
    window.angular   || window.loadLib("//cdnjs.cloudflare.com/ajax/libs/angular.js/1.0.2/angular.min.js");

My understanding is that in a script tag, everything is not passed to source.js without any processing. I found that the rule tag_attributes (jade.tmLanguage:603) applies on the script's content and destroys the highlighting (and even the one of rest of the file after the script tag)! Another rule for the comments might apply as well...

I'm not good enough to find a way to fix this, but it seems that the highlighting of scripts inlined inside a jade file is completely failing...

I hope someone will find out what to do!

bm-w commented 9 years ago

@aoberoi I fixed this by changing source.js.embedded.jade’s end expression to the following:

^((?=(\1|(?!\1)\s*)([\w#\.]|$\n?))|^$\n?)