SublimeText 3 Syntax Highlighting Markdown List Asterisk
I installed the packages MarkdownExtended
and MonokaiExtended
, which gives me an already quite good highlighting for markdown files. However, being a perfectionist, I want to color the asterisks of unordered lists in markdown. The color scheme is set to Monokai Extended
and I've edited that .tmTheme
file under Packages/User/Color Highlighter/themes/Monokai Extended.tmTheme
(careful, that's a big big text file) as follows:
<dict>
<key>name</key>
<string>Markdown: List Items Punctuation</string>
<key>scope</key>
<string>punctuation.definition.list_item.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#404b16</string>
</dict>
</dict>
This seems to be exactly what I am looking for, however, the color of the asterisks doesn't change. Is there some other file or position in the file I need to edit? What did I overlook?
EDIT#1
There seems to have been some issue with my Sublime Text 3. When I opened the Monokai Extended.tmTheme
the file inflated and got a hundred thousand lines. Now I opened it with another text editor and then changed the values like this:
<dict>
<key>name</key>
<string>Markdown: List Items Punctuation</string>
<key>scope</key>
<string>punctuation.definition.list_item.markdown</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#80Ab36</string>
</dict>
</dict>
This results in the following behavior:
So the first asterisk is already colored, only missing the other ones...
Summary
- SublimeText 3 (v3103)
- Packages:
Markdown Extended
,Monokai Extended
- Syntax Highlighting is set to
Markdown Extended
- Color Scheme is set to
Monokai Extended
- Want to color asterisks of unordered lists in markdown files
Chosen Solution
I used the code in the accepted answer, but I changed it a little bit, so that it includes indented asterisks:
list-paragraph:
- match: \G\s+(?=\S)
push:
- meta_scope: meta.paragraph.list.markdown
- match: ^\s*$
pop: true
- match: '^([ ]{0,4}|\t{0,1})([*+-])(?=\s)'
scope: punctuation.definition.list_item.markdown
- match: '^([ ]{0,4}|\t{0,1})([0-9]+)(\.)(?=\s)'
captures:
1: punctuation.definition.list_item.markdown punctuation.definition.list_item.number.markdown
2: punctuation.definition.list_item.markdown
- include: inline
EDIT#2
I've now changed it again in order to allow only certain indentations to cause the color change:
list-paragraph:
- match: \G\s+(?=\S)
push:
- meta_scope: meta.paragraph.list.markdown
- match: ^\s*$
pop: true
- match: '^([ ]{2}|[ ]{4}|[ ]{6}|[ ]{8}|[ ]{10}|[ ]{12}|\t{0,3})([*+-])(?=\s)'
scope: punctuation.definition.list_item.markdown
- match: '^([ ]{2}|[ ]{4}|[ ]{6}|[ ]{8}|[ ]{10}|[ ]{12}|\t{0,3})([0-9]+)(\.)(?=\s)'
captures:
1: punctuation.definition.list_item.markdown punctuation.definition.list_item.number.markdown
2: punctuation.definition.list_item.markdown
- include: inline
You'll need to edit the Markdown Extended
syntax definition file, which is locked up in a zipped .sublime-package
archive, so first you'll need to install PackageResourceViewer
. Once installed, open the Command Palette and type prv
to bring up the PackageResourceViewer options. Select PackageResourceViewer: Open Resource
, then Markdown Extended
, then Markdown Extended.sublime-syntax
. The selection menu will stay open, just hit Esc to get rid of it.
In Markdown Extended.sublime-syntax
, scroll down to approximately line 1172 (in the current version, it may change) to the section entitled list-paragraph
. It should look like this:
list-paragraph:
- match: \G\s+(?=\S)
push:
- meta_scope: meta.paragraph.list.markdown
- match: ^\s*$
pop: true
- include: inline
To make it recognize multiple list items, change that section to this:
list-paragraph:
- match: \G\s+(?=\S)
push:
- meta_scope: meta.paragraph.list.markdown
- match: ^\s*$
pop: true
- match: '^\s{0,4}([*+-])(?=\s)'
scope: punctuation.definition.list_item.markdown
- match: '^\s{0,4}([0-9]+)(\.)(?=\s)'
captures:
1: punctuation.definition.list_item.markdown punctuation.definition.list_item.number.markdown
2: punctuation.definition.list_item.markdown
- include: inline
Save the file (it should automatically save in the right spot), and your list items should now be highlighted appropriately.