Search code examples
visual-studio-codemarkdowntextmate

How to make a token bold+italic in VS TextMateRules


In Visual Studio Code I edit markdown files.

In the editor the text marked **bold** is rendered bold and the one marked *italic* is rendered in italic. But the text marked ***bold and italic*** is rendered simply as italic.

I tried to put in editor.tokenColorCustomizations.TextMateRules the following rule:

{
  "scope": ["markup.italic.markdown", "markup.bold.markdown"],
  "settings": {
     "fontStyle": "italic",
     "fontWeight": "bold"
  }
}

But VSC complains that fontWeight does not exist in settings and fontStyle accepts either bold or italic but not a combination of the two.

Any idea? Thanks! mario


Solution

  • This works for me:

    "editor.tokenColorCustomizations": {
      "textMateRules": [
        {
          "scope": "markup.bold.markdown markup.italic.markdown",
          "settings": {
            // "foreground": "#00ff00",
            "fontStyle": "italic bold",
          }
        },
      ]
    },
    

    For some reason, the markup.bold.markdown needs to be listed first, before markup.italic.markdown. Despite actually being listed second in the Scopes hover box.

    I would consider that a bug unless someone has a good explanation.

    Also note that your form:

    "scope": ["markup.italic.markdown", "markup.bold.markdown"],
    

    treats the scopes as two separate scopes (because of the , separator it doesn't combine the scopes - they are treated as two separate scopes, so either one gets both bolded and italicized which I assume is not what you actually want.