Sublime Forum

Edit color for new syntax in html

#1

I use Monokai theme and i want to edit color of a new syntax <%…%>
I open theme file and add this:

<dict>
			<key>match</key>
			<string>^(\<\%).*</string>
			<key>settings</key>
			<dict>
				<key>foreground</key>
				<string>#DA2000</string>
			</dict>
		</dict>

But it is error. Thanks advances!

0 Likes

#2

It looks like you are trying to add regex rules directly to the color scheme (.tmTheme) file. This is not possible. Color schemes operate on scopes applied by syntax definitions. Probably you want to work with the ASP syntax or something as opposed to plain HTML if you are using <%%> constructs?

0 Likes

#3

i did not use key name, i used key match.
I think it is possible, and i try to replace ASCII, then it change color all tag.
<string>^\77\45</string>

0 Likes

#4

No, it’s not possible.

It works like this:

                                    produce                             consume
sublime-syntax / tmLanguage files -----------> { scopes (as strings) } <------- tmTheme files
2 Likes

#5

I’m sure it’s possible to do what you want, but I’m not quite sure what you want.

It sounds like you want syntax highlighting that works like the existing HTML highlighting, but also highlights the <% %> construct. This is a common idiom in some templating languages. Are you using some sort of template language or preprocessor? If so, there may be a ready-made package that does what you want.

If there is no package that does what you want, then you can create a new syntax definition that extends HTML with new functionality using my own YAML Macros package.

2 Likes