title: What's wrong with my syntax highlighting grammar injection?
body: <p>I am following <a href="https://github.com/mjbvz/vscode-fenced-code-block-grammar-injection-example/blob/master/syntaxes/codeblock.json" rel="nofollow noreferrer">this example</a> for a simple grammar injection in markdown.</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "fileTypes": [],
      "injectionSelector": "L:markup.fenced_code.block.markdown",
      "patterns": [
          {
              "include": "#superjs-code-block"
          }
      ],
      "repository": {
          "superjs-code-block": {
              "begin": "superjs",
              "end": "(^|\\G)(?=\\s*[`~]{3,}\\s*$)",
              "contentName": "meta.embedded.block.superjs",
              "patterns": [
                  {
                      "include": "source.js"
                  }
              ]
          }
      },
      "scopeName": "markdown.superjs.codeblock"
  }
  </code></pre>
  
  <p>There is a small problem with the above code - As long as there is a string <code>superjs</code> appear in the fenced code block, the remaining would always be rendered as superjs, which would break fenced code block syntax highlighting for other embedded languages.</p>
  
  <pre class="lang-json prettyprint-override"><code>{
     "foo": "superjs"
  }
  </code></pre>
  
  <p>I would like to fix it by following <a href="https://github.com/Microsoft/vscode/blob/a09175a59e0d1dfbc42b962ee735437dcd473a16/extensions/markdown-basics/syntaxes/markdown.tmLanguage.json" rel="nofollow noreferrer">markdown.tmLanguage.json</a>.</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "fileTypes": [],
      "injectionSelector": "text.html.markdown",
      "patterns": [
          {
              "include": "#fenced_code_block_superjs"
          }
      ],
      "repository": {
          "fenced_code_block_superjs": {
              "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(superjs)(\\s+[^`~]*)?$)", 
              "beginCaptures": {
                  "3": {
                      "name": "punctuation.definition.markdown"
                  }, 
                  "5": {
                      "name": "fenced_code.block.language"
                  }, 
                  "6": {
                      "name": "fenced_code.block.language.attributes"
                  }
              }, 
              "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", 
              "endCaptures": {
                  "3": {
                      "name": "punctuation.definition.markdown"
                  }
              }, 
              "name": "markup.fenced_code.block.markdown", 
              "patterns": [
                  {
                      "begin": "(^|\\G)(\\s*)(.*)", 
                      "contentName": "meta.embedded.block.superjs", 
                      "patterns": [
                          {
                              "include": "source.js"
                          }
                      ], 
                      "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)"
                  }
              ]
          }
      },
      "scopeName": "markdown.superjs.codeblock"
  }
  </code></pre>
  
  <p>However it doesn't work, and I don't know how to debug it either.</p>