Home Download Buy Blog Forum Support

Code coloring for html tags like TABLE and INPUT

Code coloring for html tags like TABLE and INPUT

Postby skabr on Wed Sep 25, 2013 3:21 pm

Hi,

I'm using a color scheme that have custom colors for the table and input tags, colors that are different from the other html tags like div. But my issue is: these tags that have different color are not coloring different they are using the same colors of the rest of the tags.

What can I do to correct this problem?

In the attachment will be the color scheme file.

Thx a lot.

Bruno Cavenaghi
skabr
 
Posts: 1
Joined: Wed Sep 25, 2013 3:16 pm

Re: Code coloring for html tags like TABLE and INPUT

Postby Fatbat on Fri Nov 01, 2013 7:02 pm

I see the response to your question has been overwhelming.

I'd like to add IMG to the list, along with a bunch of others.

Does anyone know how to get individual HTML tag types to be coloured differently? Any help would be greatly appreciated.
Fatbat
 
Posts: 70
Joined: Sun Feb 19, 2012 6:54 pm

Re: Code coloring for html tags like TABLE and INPUT

Postby Fatbat on Wed Nov 06, 2013 1:22 pm

Really trying to get an answer on this one.

Does anyone know if there's a way to colour individual HTML tags in your theme? I'd like different colours for IMG, TABLE, FORM, INPUT, etc. but everything I've tried doesn't seem to work.
Fatbat
 
Posts: 70
Joined: Sun Feb 19, 2012 6:54 pm

Re: Code coloring for html tags like TABLE and INPUT

Postby Orlmente on Wed Nov 06, 2013 3:30 pm

I think, for what I understood about colour-schemes, that you have to edit the language definition in order to create specific scopes, and then create the colour rules for the new created scopes in your colour-scheme.
Orlmente
 
Posts: 96
Joined: Mon Mar 18, 2013 12:37 pm

Re: Code coloring for html tags like TABLE and INPUT

Postby Fatbat on Wed Nov 06, 2013 7:47 pm

Thanks for the reply Orlmente. Is the language definition in the theme itself? Any idea how to create these specific scopes? The thing is that I haven't actually found a theme with this kind of colour highlighting, otherwise I could just follow their example.
Fatbat
 
Posts: 70
Joined: Sun Feb 19, 2012 6:54 pm

Re: Code coloring for html tags like TABLE and INPUT

Postby Orlmente on Thu Nov 07, 2013 1:33 am

Well, language definitions are *.tmLanguage files that you can find into package folders, for example, if you take a look into HTML package you can find the one for html language.
At the following links you can find more info about tmLanguage files:
https://sublime-text-unofficial-documen ... xdefs.html
https://sublime-text-unofficial-documen ... xdefs.html
Orlmente
 
Posts: 96
Joined: Mon Mar 18, 2013 12:37 pm

Re: Code coloring for html tags like TABLE and INPUT

Postby Fatbat on Thu Nov 14, 2013 11:20 pm

I appreciate the reading material Orlmente. That's a lot to take in and make sense of though.

Can anyone tell me if it is even possible to apply unique colors to the tags we're talking about here, such as: table, tr, td, img, form, field, input, button, header, footer, nav, etc.?

If it is possible can you please give me an example or two? I can't find any, in any existing themes. I can't believe I'm the only one that wants to make IMG tags stand out.

Thanks.
Fatbat
 
Posts: 70
Joined: Sun Feb 19, 2012 6:54 pm

Re: Code coloring for html tags like TABLE and INPUT

Postby jellyalex978 on Fri Nov 15, 2013 4:19 pm

i think Orlmente's answer is good
and i am trying XD

(
i already try to use Syntax Definitions
it's work !!
but ..... https://sublime-text-unofficial-documen ... xdefs.html
Additionally, Sublime Text also understands the hidden-tmLanguage extension,
which can not be selected by the user but only by set by plugins.
“Find in Files” makes use of this.
The downsite is that these can not be included by import statements in other language definitions.

)

====================================

i had edit the Packages\HTML file and fix the color
Color Scheme need match Scope
you can install

ScopeAlways or ScopeHunter (use Package Control)

====================================

Color Scheme you need add a dict
when sublime find the Scope , sublime will follow your setting
Code: Select all
<dict>
   <key>name</key>
   <string>you can input a name , like HTML Tag Table</string>
   <key>scope</key>
   <string>you can setting a Scope , like meta.tag.table.html</string>
   <key>settings</key>
   <dict>
      <key>fontStyle</key>
      <string></string>
      <key>foreground</key>
      <string>#009999</string>
   </dict>
</dict>


====================================

but .... sublime Scope about HTML tag
default 2
meta.tag.block.any.html
meta.tag.inline.any.html

so you need add new Scope "Packages\HTML\HTML.tmLanguage"
Code: Select all
<dict>
   <key>begin</key>
   <string>(&lt;/?)((?i:table|thead|tbody|tfoot|tr|th|td)\b)</string>
   <key>beginCaptures</key>
   <dict>
      <key>1</key>
      <dict>
         <key>name</key>
         <string>punctuation.definition.tag.table.begin.html</string>
      </dict>
      <key>2</key>
      <dict>
         <key>name</key>
         <string>entity.name.tag.table.html</string>
      </dict>
   </dict>
   <key>end</key>
   <string>(&gt;)</string>
   <key>endCaptures</key>
   <dict>
      <key>1</key>
      <dict>
         <key>name</key>
         <string>punctuation.definition.tag.table.end.html</string>
      </dict>
   </dict>
   <key>name</key>
   <string>meta.tag.table.html</string>
   <key>patterns</key>
   <array>
      <dict>
         <key>include</key>
         <string>#tag-stuff</string>
      </dict>
   </array>
</dict>


Image

sorry my english not good
i hope you can understand
jellyalex978
 
Posts: 3
Joined: Fri Nov 15, 2013 2:09 pm

Re: Code coloring for html tags like TABLE and INPUT

Postby Fatbat on Sun Nov 24, 2013 12:25 pm

A wealth of information Jelly, thank you very much. Although I'm still struggling to understand adding various scopes to "Packages\HTML\HTML.tmLanguage", I have managed to hack together colouring the various tags I wanted to colour in Sublime Text 2.

If I wanted to do the same thing in Sublime Text 3, how would I do that? "Packages\HTML\HTML.tmLanguage" doesn't exist in ST3. I tried adding it, but nothing happened. Where do you scope additional HTML tags in ST3?
Fatbat
 
Posts: 70
Joined: Sun Feb 19, 2012 6:54 pm

Re: Code coloring for html tags like TABLE and INPUT

Postby Fatbat on Mon Nov 25, 2013 6:54 pm

Anyone know the answer to the last question about scoping HTML tags in Sublime Text 3?

Thanks!
Fatbat
 
Posts: 70
Joined: Sun Feb 19, 2012 6:54 pm

Next

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 23 guests