{
  "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
  "scopeName": "kscript.pages.injection",
  "comment": "Highlights KScript { expressions } in the HTML and Markdown pages that kscript serve renders, on top of VS Code's own HTML grammar. VS Code opens .html files with text.html.derivative (which embeds text.html.basic), so the selector uses the shared text.html prefix. <script> and <style> (source.*) and comments are left alone.",
  "injectionSelector": "L:text.html -source -comment, L:text.html.markdown -markup.fenced_code -markup.inline.raw -comment",
  "patterns": [
    {
      "include": "#escaped"
    },
    {
      "include": "source.kscript#tag-shorthand"
    },
    {
      "include": "#page-command"
    },
    {
      "include": "#self-closing"
    },
    {
      "include": "source.kscript#interpolation"
    }
  ],
  "repository": {
    "escaped": {
      "name": "constant.character.escape.kscript",
      "match": "\\{\\{|\\}\\}"
    },
    "page-command": {
      "begin": "(</?)(?i:(case|default|do|elif|else|for|if|import|include|layout|let|live|markdown|match|prop|respond|set|slot|state|while))(?=[\\s/>])",
      "beginCaptures": {
        "1": { "name": "punctuation.definition.tag.kscript" },
        "2": { "name": "entity.name.tag.kscript keyword.control.page.kscript" }
      },
      "end": "(/?>)",
      "endCaptures": {
        "1": { "name": "punctuation.definition.tag.kscript" }
      },
      "name": "meta.tag.kscript",
      "patterns": [
        { "include": "source.kscript#attribute-value-double" },
        { "include": "source.kscript#attribute-value-single" },
        { "include": "source.kscript#interpolation" },
        { "name": "entity.other.attribute-name.kscript", "match": "[A-Za-z_][\\w.:-]*(?=\\s|=|/?>)" }
      ]
    },
    "self-closing": {
      "comment": "KScript pages close any element with />, e.g. <slot /> or <hero />. The HTML grammar marks the / on non-void elements as illegal.",
      "name": "punctuation.definition.tag.end.html",
      "match": "/(?=>)"
    }
  }
}
