Home Download Buy Blog Forum Support

Javascript Block Inside HTML -- Incorrect Color Coding

Javascript Block Inside HTML -- Incorrect Color Coding

Postby indiver on Sat Mar 05, 2011 2:32 am

Hi

This is the text block that I'm using for to illustrate the poing:
Code: Select all
<html>
   <head>
      <script>
         var test = "blah";
      </script>
   </head>
   <body>
   </body>
</html>


Set the color scheme to Monokai.

You should see something like this: https://skitch.com/indiver/rur6e/incorr ... ript-block

Or have a look at the attachment.

You'll notice that the closing </script> tag is not color coded correctly.

I've tried other color schemes as well, but the same issue. For any inline Javascript block, the closing script tag is not color coded correctly.

I discovered this issue in the ColdFusion color coding where a <cfscript> block would show the correct color. After looking at the language definition I found that it uses the inline Javascript (in HTML) code to render.

Can anything be done about it? It is not a biggie, but would be really nice to have a workaround or fix.

Thanks

Indy
Attachments
incorrect-color-coding-for-inline-javascript-block.jpg
incorrect-color-coding-for-inline-javascript-block.jpg (18.02 KiB) Viewed 872 times
indiver
 
Posts: 30
Joined: Fri Mar 04, 2011 5:40 am
Location: Auckland, New Zealand

Re: Javascript Block Inside HTML -- Incorrect Color Coding

Postby indiver on Sun Mar 06, 2011 2:56 am

Anyone? Any thoughts on how to fix this?
indiver
 
Posts: 30
Joined: Fri Mar 04, 2011 5:40 am
Location: Auckland, New Zealand

Re: Javascript Block Inside HTML -- Incorrect Color Coding

Postby atomi on Sun Mar 06, 2011 3:53 am

Hi again.

Problem lies in the Coldfusion.tmLanguage.
At line 262 you can replace with this:
Code: Select all
            <key>begin</key>
            <string>(?:^\s+)?&lt;((?i:script))\b(?![^&gt;]*/&gt;)</string>
            <key>beginCaptures</key>
            <dict>
               <key>1</key>
               <dict>
                  <key>name</key>
                  <string>entity.name.tag.script.html</string>
               </dict>
            </dict>
            <key>end</key>
            <string>(?&lt;=&lt;/(script|SCRIPT))&gt;(?:\s*\n)?</string>
            <key>endCaptures</key>
            <dict>
               <key>1</key>
               <dict>
                  <key>name</key>
                  <string>entity.name.tag.script.html</string>
               </dict>
            </dict>
            <key>name</key>
            <string>source.js.embedded.html</string>


I haven't tested this. In fact, there's a lot in that tmLanguage that can be fixed up to work better with Sublime.
You could gut a lot of the html stuff and just add the following for all the html.
Code: Select all
      <dict>
         <key>include</key>
         <string>text.html.basic</string>
      </dict>


It sounds like a fun project if you're up for it.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Javascript Block Inside HTML -- Incorrect Color Coding

Postby indiver on Sun Mar 06, 2011 10:20 am

Thanks for that pointer. I had make a few other change as well. I'm going to be pushing the changes to the repo.

Yes, it is a worthwhile project, however, I know that alone it would be too difficult to find time. However, my hope is that as it is on GitHub, others can fork and make it better.
indiver
 
Posts: 30
Joined: Fri Mar 04, 2011 5:40 am
Location: Auckland, New Zealand

Re: Javascript Block Inside HTML -- Incorrect Color Coding

Postby jbrooksuk on Mon Mar 07, 2011 10:54 am

The same thing occurs when you've got a structure of:

HTML -> Style Type = "text/css" -> PHP

ST must have a limit of how many styles it can highlight inside of each other.
jbrooksuk
 
Posts: 689
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: Javascript Block Inside HTML -- Incorrect Color Coding

Postby indiver on Mon Mar 07, 2011 11:06 am

One can fix it changing the bundle to use the same code as the HTML bundle.

Have a look at github commit where I made that change.

https://github.com/indynagpal/coldfusio ... d65c46358a
indiver
 
Posts: 30
Joined: Fri Mar 04, 2011 5:40 am
Location: Auckland, New Zealand


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 7 guests