The Markdown
syntax package for Sublime Text doesn’t handle Scala or YAML code blocks by default. It would be great if the package included this by default.
- Fix was inspired by https://superuser.com/a/1047076
- I installed the
PackageResourceViewer
via Package Control. Restart. Tools, Command Palette,prv
to findPackageResourceViewer: Open Resource
, choose theMarkdown
package, then open theMarkdown.sublime-syntax
resource. Search for.java.
to find this block:
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:java))
\s*$\n? # any whitespace until EOL
captures:
0: meta.code-fence.definition.begin.java.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
3: constant.other.language-name.markdown
embed: scope:source.java
embed_scope: markup.raw.code-fence.java.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.java.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- Copy and paste immediately after, replacing
java
withscala
in the copy:
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:scala))
\s*$\n? # any whitespace until EOL
captures:
0: meta.code-fence.definition.begin.scala.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
3: constant.other.language-name.markdown
embed: scope:source.scala
embed_scope: markup.raw.code-fence.scala.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.scala.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- Also add in YAML support similarly:
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:yml|yaml))
\s*$\n? # any whitespace until EOL
captures:
0: meta.code-fence.definition.begin.yaml.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
3: constant.other.language-name.markdown
embed: scope:source.yaml
embed_scope: markup.raw.code-fence.yaml.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.yaml.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- On my Mac, the modified file will be saved as “${HOME}/Library/Application Support/Sublime Text 3/Packages/Markdown/Markdown.sublime-syntax” if you want to back it up.