Jane
Jane

Reputation: 36

Sublime Text 3 - edit of syntax highlight

I need edit syntax highlight for php (or maybe html). I started using html comments to optimize loading of web pages on mobile viewports. Simply I comment out part of the html code I don't want visible on mobile version, then in desktop version javascript uncomment that part of code. It looks like this:

<!-- @media only all and (min-width:400px)
    <p>
        <h2>Hello World !!</h2>
    </p>
-->

Sublime text naturally hightligh that code as comment - in my theme it will show with dark gray color.

What I need is that when I use normal comment, it will be dakr gray, but when I use this special comment (<!-- @media ...) it will not act like a comment and display normal html hightligts for tags.

I already found out how to change syntax and theme files with PackageDev. I just don't know what precisely write to these files. And if I need to change php syntax or html syntax, because it's html written in php files.

Upvotes: 1

Views: 67

Answers (1)

Jane
Jane

Reputation: 36

Ok, I finally made it. I added this code to html.sublime-syntax, it has to be before comment definition.

- match: '<!-- @media'
  scope: markup.other.html
  push:
    - meta_scope: markup.other.html
    - match: '--'
      pop: true

- match: '-->'
  scope: markup.other.htm

Upvotes: 1

Related Questions