Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 933
SiliconValley Avatar asked Oct 19 '25 15:10

SiliconValley


1 Answers

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.

like image 138
Mark Avatar answered Oct 22 '25 16:10

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!