Home Download Buy Blog Forum Support

Syntax Highlighting Bug

Syntax Highlighting Bug

Postby hexplor on Sat Jan 28, 2012 4:29 pm

Hey Guys,
I'm a developer of phpBB3 styles. Recently i switched to Sublime and noticed following bug. In phpBB3 there are simple conditionals which are used mainly in head and body area. Sublime seems to recognize it wrong. See my screenshot:

http://www.karolorzel.com/files/screens ... 172008.jpg

As you can see. After the phpBB3 Conditional syntax is broken. Sublime seems to interpret phpBB3 conditionals as html comments. Never had any troubles with other editors. Any possibility to fix that ? It makes phpBB3 templating almost impossible. I'm attaching the example file.
Attachments
example.html.zip
(522 Bytes) Downloaded 56 times
hexplor
 
Posts: 4
Joined: Sat Jan 28, 2012 4:22 pm

Re: Syntax Highlighting Bug

Postby facelessuser on Sat Jan 28, 2012 4:56 pm

Have you tried setting the syntax to HTML?

HTML usually provides PHP syntax highlighting as well, and properly handles HTML comment blocks. It might not highlight the conditional statement, but it will not break the HTML highlighting. The conditional statement will just look like a comment.
facelessuser
 
Posts: 1446
Joined: Tue Apr 05, 2011 7:38 pm

Re: Syntax Highlighting Bug

Postby hexplor on Sat Jan 28, 2012 5:23 pm

Yes. I tried that just to be sure. Result is the same... :(
hexplor
 
Posts: 4
Joined: Sat Jan 28, 2012 4:22 pm

Re: Syntax Highlighting Bug

Postby facelessuser on Sat Jan 28, 2012 8:16 pm

Yeah, it appears that the syntax highlighting does not pick up on the html comment syntax inside the style block or script blocks. It could be added though, maybe I will take a look later.
facelessuser
 
Posts: 1446
Joined: Tue Apr 05, 2011 7:38 pm

Re: Syntax Highlighting Bug

Postby facelessuser on Sat Jan 28, 2012 8:31 pm

You can try this. I just inserted the code below in the HTML tmLanguage file under the embedded javascript and css. This would have to be done for all embedded languages. Probably in a cleaner fashion where it is defined once, and each embedded language includes it.
Code: Select all
                  <dict>
                     <key>begin</key>
                     <string>&lt;!--</string>
                     <key>captures</key>
                     <dict>
                        <key>0</key>
                        <dict>
                           <key>name</key>
                           <string>punctuation.definition.comment.html</string>
                        </dict>
                     </dict>
                     <key>end</key>
                     <string>--\s*&gt;</string>
                     <key>name</key>
                     <string>comment.block.html</string>
                     <key>patterns</key>
                     <array>
                        <dict>
                           <key>match</key>
                           <string>--</string>
                           <key>name</key>
                           <string>invalid.illegal.bad-comments-or-CDATA.html</string>
                        </dict>
                        <dict>
                           <key>include</key>
                           <string>#embedded-code</string>
                        </dict>
                     </array>
                  </dict>


You can try out the file here
HTML.tmLanguage.zip
(2.98 KiB) Downloaded 54 times


It should work okay for css and javascript at least.
facelessuser
 
Posts: 1446
Joined: Tue Apr 05, 2011 7:38 pm

Re: Syntax Highlighting Bug

Postby hexplor on Mon Jan 30, 2012 11:58 am

It works :) at least partially. If I do something like that:
Code: Select all
<!-- IF DEFAULT_PHPBB3_CONDITIONAL_STATEMENT -->
   body {font-size: {SOME_DEFINED_FONTSIZE}px;}
<!-- ENDIF -->


(just added {SOME_DEFINED_FONTSIZE} )

then it's broken again..
hexplor
 
Posts: 4
Joined: Sat Jan 28, 2012 4:22 pm

Re: Syntax Highlighting Bug

Postby facelessuser on Mon Jan 30, 2012 4:32 pm

Yeah. In order to make it really work well, I might have to descend into the CSS tmLanguage since the HTML language just includes the rules for CSS form the CSS.tmLanguage file. The CSS.tmLanguage isn't designed to expect such things.

That is really how the HTML is doing the embedded code. It is literally just including the scripting language's tmLanguage file. There might be a way to make the the scripts recognize the defines as such without altering the included languages, but I would have to spend quite a bit more time analyzing the dynamics of the rules and figuring out how to insert the new rules to be picked up. It is pretty easy targeting the comments because they are so different than the syntax of most languages.

I am not used to using these kinds of defines; therefore I don't really know all of their rules and usage at this time, so it is hard for me to really put something together at this time.
facelessuser
 
Posts: 1446
Joined: Tue Apr 05, 2011 7:38 pm

Re: Syntax Highlighting Bug

Postby hexplor on Tue Jan 31, 2012 10:45 am

ok :) Thanks for your help and further explanation. I really appreciate it :)
hexplor
 
Posts: 4
Joined: Sat Jan 28, 2012 4:22 pm


Return to Technical Support

Who is online

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