Skip to content

Allow styling of code fences #612

@tomhundt

Description

@tomhundt

Code fences have scope text.html.markdown.gfm which makes them un-styleable. Please give them a unique scope. Other Markdown punctuation has its own scope.

Background and Motivation

Code fences are three backquotes in a row, on their own line, optionally followed by a language specifier for the starting fence. The language specifier tells the parser how to interpret the code between the fences. For example, py for Python code, or sh for shell scripts. Those then can get styled appropriately for the language.

I wish to style code fences themselves grey, so they fade into the background, as I do all of the markdown "punctuation" -- things like the ### heading markers, brackets around links, and single backquote fences around inline code. I've been able to do that with all of these except the triple-backquote fences. This would be helpful since I read Markdown mostly in source form, i.e., in Sublime Text.

Here's an example of what I mean. Notice your eye just skips over the grey stuff and you can read the text easily:
larger example showing grey punctuation

But I can't make triple-backquotes grey, because presently, these code fences are marked either just with scope text.html.markdown.gfm (the same as regular surrounding text) or text.html.markdown.gfm markup.raw.block.markdown markup.raw.block.fenced.markdown (the same as the enclosed code).

In contrast, single-backquote (inline) code fences are marked with a "punctuation" scope (text.html.markdown.gfm meta.paragraph.markdown markup.raw.inline.markdown punctuation.definition.raw.markdown) and headings are text.html.markdown.gfm meta.block-level.markdown markup.heading.markdown punctuation.definition.heading.markdown.

Here's an example (I've done Tools > Developer > Show scope name to display the scope in a little popup box, below the example):
code fence w scope
(Notice the fences are white, just like regular text.)

Here's a second example, where the scope of the fence is the same as the scope of the fenced code (and as a result, the fences are green, like the code text):

larger example showing green fence

So, my request is to please add a "punctuation" scope for the 3-backquote code fences. I've looked at the syntax file and... it's complicated.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions