Highlighting code blocks in Markdown


#1

I have a color scheme I like, but it treats stuff like

`some CLI command`

as plain text when it is in-line and also doesn’t highlight 4-space-indented code blocks. I want it highlighted to be at least all a solid color as a literal code block. How can I add something to styles.less to do that?


#2

The inline code sections are tokenized but are not colored differently than other text in the default themes. You can change this by adding the following to your styles.less:

atom-text-editor::shadow {
  .markup.raw.gfm {
    // Or however you want to format it
    color: yellow;
  }
}

You can find these classes for yourself by following the instructions in the documentation or by using the Editor: Log Cursor Scope command from the Command Palette or Alt+Cmd+P on OS X or Ctrl+Alt+Shift+P on other platforms.

The 4-space-indented sections are not tokenized as anything other than regular Markdown text. To change that, you would have to suggest or implement a change to the language-gfm package.


#3

The markdown-preview package uses the syntax-variables file to obtain the correct highlighting. Each syntax theme should provide this file at the following location: theme-name/styles/syntax-variables.less. I suspect the syntax-theme you are using has it located elsewhere, which means that packages that rely on the syntax-variables file to do their colorization cannot find it and thus use default colors.

What syntax-theme are you using? If the above is indeed the case, it is probably best to alert the author by making a ticket. Many packages that try and give the editor a uniform look rely on the file to be present.


#4

The theme I am using has that file in the right place. That’s not the issue. Thanks though


#5

Thanks, that does it, and I saw the issues there already have tikets about the lack of indented code block support.