Sublime Forum

Help with custom syntax highlighting

#1

I’m creating a custom syntax highlighting for a wiki. I got some snippets from the built in HTML highlighting and it works fine for the most part, but I need to take it further. Below is an example text:

<file bash>
Sample code
</file>

This is the highlighting code:

- match: (</?)([a-zA-Z0-9:]+)
  captures:
    1: meta.tag
    2: entity.name.tag
  push:
    - meta_scope: meta.tag
    - match: '>'
      scope: meta.tag
      pop: true
    - include: tag-stuff
    - match: '.'
      scope: markup.inserted

This works good for highlighting the tags and strings inside the tags, but the actual Sample code looks the same as any regular text. I’m trying to get it highlighted as a block comment or something similar so it will stand out. Any suggestions how to get that done? Thanks.

0 Likes

#2

isn’t it enough to just add a match for anything other than a < character? assuming you don’t care about entities etc.

- match: (</?)([a-zA-Z0-9:]+)
  captures:
    1: meta.tag
    2: entity.name.tag
  push:
    - meta_scope: meta.tag
    - match: '>'
      scope: meta.tag
      pop: true
    - include: tag-stuff
    - match: '.'
      scope: markup.inserted
- match: '[^<]+'
  scope: comment.block.sublimer1
0 Likes

#3

looks like this has been cross posted here: http://stackoverflow.com/questions/39879737/sublime-text-custom-syntax-highlighting

0 Likes