jonschlinkert / sublime-markdown-extended

Top 100 Sublime Text plugin! Markdown syntax highlighter for Sublime Text, with extended support for GFM fenced code blocks, with language-specific syntax highlighting. YAML Front Matter. Works with ST2/ST3. Goes great with Assemble.
https://github.com/jonschlinkert
MIT License
660 stars 96 forks source link

Color code generic fenced block #159

Open suryasaha opened 7 years ago

suryasaha commented 7 years ago

Is it possible to highlight a generic fenced code block like the one below? This is useful when the language is not specified.

code
blag commented 7 years ago

Yes, this is possible. GitHub has a project called Linguist that guesses the language directly from the syntax.

Luckily, Linguist uses a set of language grammars that are language-agnostic, so this can be implemented in a similar manner.

So when can we expect your PR implementing this? 😜

tomhundt commented 3 years ago

This is already supported by the syntax. You just have to have colors assigned to the scope.

The hard way

Add color(s) to your active .tmTheme file for the scope of a generic fenced code block, which is text.html.markdown markup.raw.block.markdown markup.raw.block.fenced.markdown (from Tools > Developer > Show scope name).

So, for example, this makes it green on light grey:

    <dict>
      <key>name</key>
      <string>Markup: Raw (code) block</string>
      <key>scope</key>
      <string>markup.raw.block</string>
      <key>settings</key>
      <dict>
        <key>foreground</key>
        <string>#aaffaad0</string>
        <key>background</key>
        <string>#222</string>
      </dict>
    </dict>

I think there's a way to edit a .yaml file to do the same thing, but I can't remember right now and I know this works.

The easy way

Try out different color schemes (themes) 'til you find one that already has something like this implemented. Look in Package Control.
(Looks like issue #108 has a suggestion near the bottom.)