Sublime Forum

Adding more syntax highlight to code blocks in markdown

#1

Hi,

I am struggling to get the following working.

I have Gherkin syntax highlight installed in ST3. It works just fine. AFAIK it was installed via Package Control, but it doesn’t have a .sublime-syntax file in the bundle, but rather the .tmLanguage file that t my understanding describes the syntax highlighting rules.

I like to use markdown files and integrate code blocks into them. Syntax highlighting works fine for all off the languages apart from Gherkin.

I’ve tried to follow the path that was proposed in Syntax coloring Scala and YAML code blocks embedded in a Markdown document but no luck.

This is the code block that I’ve tried to add to Markdown.sublime-syntax:

    - match: |-
           (?x)
            {{fenced_code_block_start}}
            ((?i:feature|gherkin))
            \s*$\n?          # any whitespace until EOL
      captures:
        0: meta.code-fence.definition.begin.gherkin.markdown-gfm
        2: punctuation.definition.raw.code-fence.begin.markdown
        3: constant.other.language-name.markdown
      embed: scope:source.gherkin
      embed_scope: markup.raw.code-fence.gherkin.markdown-gfm
      escape: '{{code_fence_escape}}'
      escape_captures:
        0: meta.code-fence.definition.end.gherkin.markdown-gfm
        1: punctuation.definition.raw.code-fence.end.markdown

This is the text in the markdown file that I want to highlight:

Given I am
Then I 'exist'

Gherkin highlighting works here. How can I make it work in markdown in ST3?

0 Likes

Custom syntax highlighting in markdown code blocks
#2

Any errors in the ST console? (View menu -> Show Console)

0 Likes

#3

Nope, nothing.
I tried restarting the ST after I save the Markdown.sublime-syntax and still nothing. The console just says a bunch of “reloading plugin xyz”. No errors or anything. =(

0 Likes