visual-studio-codegrammarcode-injectiontextmate

VSCode Extension - Grammar Injection Into Multiple Languages


I'd like my extension to apply to both HTMl and Markdown.

I understand I can use

"injectTo": [
    "text.html.derivative"
    "text.html.markdown"
],

But that doesn't work on it's own because I need to somehow have both in

"injectionSelector": "L:text.html.derivative",

How do I add Markdown to my injectionSelection in addition to HTML?


Solution

  • You can comma , separate scopes in the injectionSelector
    pipe (or) | also works

    "injectionSelector": "L:text.html.derivative, L:text.html.markdown"
    

    JavaScript just so happens to convert an array into a string with the elements comma separated
    so this also happens to work (not officially supported)

    "injectionSelector": [
      "L:text.html.derivative",
      "L:text.html.markdown"
    ]