Sublime Forum

Create ST3 Markdown syntax with code blocks

#1

Hi all,

I would like to create my own syntax for Markdown files with .sublime-color-scheme (not tmLanguage). I tested the first draft of my theme, and I noticed the code blocks aren’t identified and not colored.

Does anyone know how to implement the code block colors in .md files ?
Is it possible to do this without defining all the themes of each selectable language for the code block ? Maybe with tmLanguage ?

Thanks !

0 Likes

#2

Syntax highlighting works in two steps.

  1. content/text is parsed using patterns/rules from a syntax definition (e.g.: *:tmLanguage or *.sublime-syntax) to assign scope names to tokens.
    see: https://www.sublimetext.com/docs/syntax.html

  2. colors are assigned to tokens using rules from color schemes (e.g.: *.tmTheme or *.sublime-color-scheme).
    see: https://www.sublimetext.com/docs/color_schemes.html

I guess, you want to write your own color scheme to highlight markdown files using existing syntax definition?

A color scheme needs to specify rules for whatever is to be highlighted other than plain text.

A list of least scopes, which should be covered by a color schemes can be found at https://www.sublimetext.com/docs/scope_naming.html#minimal-scope-coverage, but way more may be required for a complete color scheme.

To learn more you could have a look at some builtin color schemes of ST or one of MarkdownEditing’s color schemes, which are optimized Markdown files (even though some color choices are questionable).

0 Likes

#3

Hi,

Thanks for the links.
I’m not specifically looking to create a color scheme from existing syntax, but if it allows to have colors in the code blocks, then I’ll be happy with it.

I will rely on your advice to move forward.

0 Likes