[SVN] Re: Javascript Syntax Highlighting Tweaks (with Patch)

Thomas Aylott - subtleGradient textmate at subtleGradient.com
Wed Jul 2 17:10:20 UTC 2008


Committed to the Review branch of the Javascript bundle.
With some minor tweaks.

Also pushed to github: http://github.com/subtleGradient/javascript.tmbundle/tree/master

Thanks for the help.
I'll see what I can do about the rest.

On Jun 27, 2008, at 5:53 PM, Joseph Pecoraro wrote:

> I made some changes to the Javascript Syntax to take care of some  
> cases:
>
> (1) Scientific notation => Ex, 1e5 and 2.5E5
> (2) Regular Expressions in an array or parameter list => Ex. [/test/],
> or new Array(/test/, /test/)
> (3) Highlighting params in a nameless function => Ex. (function(a){}) 
> ()
>
> The patch is available at this pastie:
> http://pastie.textmate.org/private/hxkpy8qkahofrxwyvp4coq
>
> Originally this started on the regular mailing list as a question but
> with some help we got this done:
> http://lists.macromates.com/textmate/2008-June/025973.html
>
> I took a look at the jQuery, Prototype, and prettify.js sources using
> the patch above and could only find a few more edge cases that aren't
> handled that were failing before as well, but I don't think they are
> too important:
> (1) var $continue... highlights "continue" as a keyword but it
> shouldn't be because of the '$' in front of it.  \b worked a little
> too well here =)
> (2) .5 * .5.... In javascript digits before the decimal point are
> optional but the highlighting right now keeps the decimal point
> white.  I tried to get around this with a backreference (?<=\.) but
> failed.  Here is what I tried:
>
>         // Currently is
>         match = '\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\.[0-9]+)?([eE][-+]?
> [0-9]+)?))\b';
>         // Try a longer version which starts with a required .#?
> [FAILED]
>         match = '\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\.[0-9]+)?([eE][-+]?
> [0-9]+)?)|((\.[0-9]+)([eE][-+]?[0-9]+)?))\b';
>         // Use a backreference for the dot? [FAILED]
>         match = '\b((0(x|X)[0-9a-fA-F]+)|(([0-9](\.[0-9]+)?|(?<=\.)
> [0-9]+)([eE][-+]?[0-9]+)?))\b';
>
>
> If these look good could you add this?
>
> Thanks in advance,
> Joseph Pecoraro
> _______________________________________________
> textmate-dev mailing list
> textmate-dev at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate-dev




More information about the textmate-dev mailing list