Home Download Buy Blog Forum Support

PHP syntax highlighting between HTML quotes

PHP syntax highlighting between HTML quotes

Postby chaptera on Fri Mar 08, 2013 3:25 pm

I am THIS close in to purchasing a ST licence, it really is a beautiful program and i really want to get rid of editing in Dreamweaver.

But i just can't seem to find how it's possible to get the right PHP syntax highlighting when working with a PHP / HTML combination.
And that's kind of important.

One may use PHP code inside HTML quotes like in the screenshot, but the the PHP syntax isn't right anymore.

The screenshot where highlighting is good is in Dreamweaver, how to get it functioning like that in ST2?
Attachments
dwhighlight.png
dwhighlight.png (16.75 KiB) Viewed 10841 times
st2highlight.png
st2highlight.png (19.13 KiB) Viewed 10847 times
chaptera
 
Posts: 6
Joined: Fri Mar 08, 2013 10:58 am

Re: PHP syntax highlighting between HTML quotes

Postby LONGMAN on Fri Mar 08, 2013 6:25 pm

You must edit your .tmTheme file
AutoBackups: ST2 / ST3
CodeFormatter: ST2 / ST3
StringUtilities: ST2 / ST3
LONGMAN
 
Posts: 68
Joined: Mon Nov 26, 2012 5:03 pm
Location: Tbilisi, Georgia

Re: PHP syntax highlighting between HTML quotes

Postby chaptera on Sat Mar 09, 2013 12:49 pm

Yes it seems to be that way, but i've no clue where or how, even when going through the docs.

I keep reading from sublime text lovers and users how active it is with the community and all, but i get the feeling it's more dead than alive since there are way more questions than good answers really..
chaptera
 
Posts: 6
Joined: Fri Mar 08, 2013 10:58 am

Re: PHP syntax highlighting between HTML quotes

Postby dku on Sat Mar 09, 2013 4:39 pm

I notice this too, this seems happens for all default color schemes. You can use some of Tomorrow Color Schemes: https://github.com/chriskempson/tomorro ... r/textmate

Than it's look like this:
Attachments
syntax.png
syntax.png (8.53 KiB) Viewed 10795 times
dku
 
Posts: 2
Joined: Sat Mar 09, 2013 2:03 am

Re: PHP syntax highlighting between HTML quotes

Postby agibsonsw on Sat Mar 09, 2013 5:28 pm

If you don't wish tackle the customization yourself then you might find a theme, such as Tomorrow, that already includes some embedded-php highlighting.

Otherwise, you might modify (copy and save etc.) your current theme to include rules such as the following:

Code: Select all
         <key>name</key>
         <string>Embedded begin (PHP)</string>
         <key>scope</key>
         <string>text.html.basic source.php.embedded.block.html punctuation.section.embedded.begin.php</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#FF0000</string>
         </dict>
      </dict>
      <dict>
         <key>name</key>
         <string>Embedded end (PHP)</string>
         <key>scope</key>
         <string>text.html.basic source.php.embedded.block.html punctuation.section.embedded.end.php</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#FF0000</string>
         </dict>
      </dict>

Use Ctrl-Alt-Shift-P to discover the current scope for particular text that you wish to colour - it appears in the statusbar - or install the ScopeHunter package.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: PHP syntax highlighting between HTML quotes

Postby LONGMAN on Sat Mar 09, 2013 10:51 pm

I have question about scope. Look at my screen, why sublime detect scope as wrong? Why not as embed php in javascript string quotes?
Attachments
screen-2013-03-10-[02-07-20].jpg
Screen
screen-2013-03-10-[02-07-20].jpg (205.35 KiB) Viewed 10791 times
AutoBackups: ST2 / ST3
CodeFormatter: ST2 / ST3
StringUtilities: ST2 / ST3
LONGMAN
 
Posts: 68
Joined: Mon Nov 26, 2012 5:03 pm
Location: Tbilisi, Georgia

Re: PHP syntax highlighting between HTML quotes

Postby chaptera on Sun Mar 10, 2013 10:17 am

Thanks everybody for their great answers.
ST is such a great editor with superbe modification possibilities so i'll to learn many new things.

In the meanwhile i got what a wanted!

I've found a Monokai expanded theme which includes embedded php highlighting like it should.

For every who's still searching check this out: http://travisjbeck.com/blog/php/monokai ... edded-php/

Also have a look at that great theme editor ( open in chrome ): http://tmtheme-editor.herokuapp.com/#/Monokai


I'm going to purchase Sublime now becuase i want this editor to be supported as much as possible!
chaptera
 
Posts: 6
Joined: Fri Mar 08, 2013 10:58 am

Re: PHP syntax highlighting between HTML quotes

Postby agibsonsw on Sat Mar 16, 2013 11:15 pm

LONGMAN wrote:I have question about scope. Look at my screen, why sublime detect scope as wrong? Why not as embed php in javascript string quotes?

Your echo statements should be semi-colon terminated, although this probably doesn't account for the scope issue. I don't think ST-scoping extends as far as HTML > JS > STRING > PHP.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 19 guests