{
  "scopeName": "source.ocaml.ocamldoc",
  "name": "OCamldoc",
  "fileTypes": ["mld"],
  "patterns": [{ "include": "#markup" }],
  "repository": {
    "markup": {
      "patterns": [
        {
          "comment": "ocamldoc documentation tag @raise",
          "match": "(@raises?)[[:space:]]+([^[:space:]]+)",
          "captures": {
            "1": { "name": "keyword.doc-tag.ocamldoc" },
            "2": {
              "name": "markup.inline.raw.ocamldoc source.embedded.ocamldoc constant.language.capital-identifier.ocaml"
            }
          }
        },
        {
          "comment": "ocamldoc documentation tag @param",
          "match": "(@param)[[:space:]]+([^[:space:]]+)",
          "captures": {
            "1": { "name": "keyword.doc-tag.ocamldoc" },
            "2": {
              "name": "markup.inline.raw.ocamldoc source.embedded.ocamldoc"
            }
          }
        },
        {
          "comment": "ocamldoc documentation tag @see",
          "match": "(@see)[[:space:]]+(<.*?>|\".*?\"|'.*?')",
          "captures": {
            "1": { "name": "keyword.doc-tag.ocamldoc" },
            "2": {
              "name": "markup.underline.link.ocamldoc meta.link.ocamldoc"
            }
          }
        },
        {
          "comment": "ocamldoc documentation tag",
          "name": "keyword.doc-tag.ocamldoc",
          "match": "@[[:lower:]]+"
        },
        {
          "comment": "embedded ocaml source",
          "begin": "(?<!\\\\)\\[",
          "end": "(?<!\\\\)\\]",
          "name": "markup.inline.raw.ocamldoc",
          "contentName": "source.embedded.ocamldoc",
          "patterns": [{ "include": "source.ocaml" }]
        },
        {
          "comment": "embedded preformatted ocaml source",
          "begin": "(?<!\\\\)\\{(@ocaml([[:space:]].*?)?)?\\[",
          "end": "(?<!\\\\)\\]\\}",
          "name": "markup.inline.raw.ocamldoc",
          "contentName": "source.embedded.ocamldoc",
          "patterns": [{ "include": "source.ocaml" }]
        },
        {
          "comment": "embedded other language source",
          "begin": "(?<!\\\\)\\{@.+?\\[",
          "end": "(?<!\\\\)\\]\\}",
          "name": "markup.inline.raw.odoc",
          "contentName": "source.embedded.odoc"
        },
        {
          "comment": "cross-reference",
          "begin": "(?<!\\\\)\\{!((modules?|modtype|module-type|class|classtype|class-type|val|value|type|exception|exn|attribute|method|section|const|recfield|field|extension|extension-decl|instance-variable|label|page):)?",
          "end": "(?<!\\\\)\\}",
          "name": "markup.inline.raw.ocamldoc",
          "contentName": "source.embedded.ocamldoc",
          "patterns": [{ "include": "source.ocaml" }]
        },
        {
          "comment": "cross-reference with alt text",
          "begin": "(?<!\\\\)\\{(\\{!((module|modtype|module-type|class|classtype|class-type|val|value|type|exception|exn|attribute|method|section|const|recfield|field|extension|extension-decl|instance-variable|label|page):)?)",
          "end": "(\\}).*?(?<!\\\\)\\}",
          "name": "markup.underline.link.ocamldoc meta.link.ocamldoc",
          "contentName": "markup.inline.raw.ocamldoc source.embedded.ocamldoc",
          "patterns": [{ "include": "source.ocaml" }],
          "beginCaptures": {
            "1": { "name": "markup.inline.raw.ocamldoc" }
          },
          "endCaptures": {
            "1": { "name": "markup.inline.raw.ocamldoc" }
          }
        },
        {
          "comment": "ocamldoc heading tag",
          "begin": "(?<!\\\\){[[:digit:]]+(:[^[:space:]]*)?[[:space:]]",
          "end": "(?<!\\\\)}",
          "name": "markup.heading.ocamldoc",
          "patterns": [{ "include": "#markup" }],
          "beginCaptures": {
            "1": { "name": "meta.link.label.ocamldoc" }
          }
        },
        {
          "comment": "ocamldoc bold",
          "begin": "(?<!\\\\){b[[:space:]]",
          "end": "(?<!\\\\)}",
          "name": "markup.bold.ocamldoc",
          "patterns": [{ "include": "#markup" }]
        },
        {
          "comment": "ocamldoc italic/emph",
          "begin": "(?<!\\\\){(i|e)[[:space:]]",
          "end": "(?<!\\\\)}",
          "name": "markup.italic.ocamldoc",
          "patterns": [{ "include": "#markup" }]
        },
        {
          "comment": "ocamldoc verbatim",
          "begin": "(?<!\\\\){v[[:space:]]",
          "end": "\\bv}",
          "name": "markup.inline.raw.ocamldoc"
        },
        {
          "comment": "ocamldoc exponent/index",
          "begin": "(?<!\\\\){(\\^|\\_)[[:space:]]",
          "end": "(?<!\\\\)}",
          "name": "markup.exponent.ocamldoc",
          "patterns": [{ "include": "#markup" }]
        },
        {
          "comment": "odoc inline math",
          "begin": "(?<!\\\\){m[[:space:]]",
          "end": "(?<!\\\\)\\}",
          "name": "support.class.math.odoc markup.math.inline.odoc meta.math.inline.odoc",
          "patterns": [{ "include": "#braces" }]
        },
        {
          "comment": "odoc math block",
          "begin": "(?<!\\\\){math[[:space:]]",
          "end": "(?<!\\\\)\\}",
          "name": "support.class.math.odoc markup.math.block.odoc meta.math.block.odoc",
          "patterns": [{ "include": "#braces" }]
        },
        {
          "comment": "ocamldoc simple lists",
          "match": "^[[:space:]]*(\\-|\\+)",
          "name": "punctuation.definition.list.begin.markdown.ocamldoc"
        },
        {
          "comment": "ocamldoc lists",
          "begin": "((?<!\\\\){(ul|ol)[[:space:]])",
          "end": "((?<!\\\\)})",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.ocamldoc"
            }
          },
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.ocamldoc"
            }
          },
          "patterns": [{ "include": "#lists" }]
        },
        {
          "comment": "ocamldoc tables",
          "begin": "((?<!\\\\){table[[:space:]])",
          "end": "((?<!\\\\)})",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.table.ocamldoc"
            }
          },
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.table.ocamldoc"
            }
          },
          "patterns": [{ "include": "#table" }]
        },
        {
          "comment": "ocamldoc light tables",
          "begin": "((?<!\\\\){t[[:space:]])",
          "end": "((?<!\\\\)})",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.table.light.ocamldoc"
            }
          },
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.table.light.ocamldoc"
            }
          },
          "patterns": [{ "include": "#lighttable" }]
        },
        {
          "comment": "ocamldoc links with alt-text",
          "begin": "(?<!\\\\){({:.*?})",
          "beginCaptures": {
            "1": { "name": "string.other.link.title.markdown.ocamldoc" }
          },
          "end": "(?<!\\\\)\\}",
          "patterns": [{ "include": "#markup" }],
          "name": "markup.underline.link.ocamldoc meta.link.ocamldoc"
        },
        {
          "comment": "ocamldoc links",
          "match": "(?<!\\\\)({:.*?})",
          "captures": {
            "1": { "name": "string.other.link.title.markdown.ocamldoc" }
          }
        },
        {
          "comment": "ocamldoc latex",
          "begin": "(?<!\\\\){\\%([[:space:]]|latex:)",
          "end": "\\%}",
          "name": "markup.inline.raw.ocamldoc",
          "patterns": [{ "include": "text.tex.latex" }]
        },
        {
          "comment": "ocamldoc html",
          "begin": "(?<!\\\\){\\%html:",
          "end": "\\%}",
          "name": "markup.inline.raw.ocamldoc",
          "patterns": [{ "include": "text.html.derivative" }]
        }
      ]
    },
    "lists": {
      "patterns": [
        {
          "comment": "ocamldoc list element",
          "begin": "((?<!\\\\){(\\-|li)[[:space:]])",
          "end": "((?<!\\\\)})",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.ocamldoc"
            }
          },
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.ocamldoc"
            }
          },
          "patterns": [{ "include": "#markup" }]
        }
      ]
    },
    "table": {
      "patterns": [
        {
          "comment": "ocamldoc table row",
          "begin": "((?<!\\\\){tr[[:space:]])",
          "end": "((?<!\\\\)})",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.table.row.ocamldoc"
            }
          },
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.table.row.ocamldoc"
            }
          },
          "patterns": [{ "include": "#tablerow" }]
        }
      ]
    },
    "tablerow": {
      "patterns": [
        {
          "comment": "ocamldoc table cell",
          "begin": "((?<!\\\\){td[[:space:]])",
          "end": "((?<!\\\\)})",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.table.cell.ocamldoc"
            }
          },
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.table.cell.ocamldoc"
            }
          },
          "patterns": [{ "include": "#markup" }]
        },
        {
          "comment": "ocamldoc table header cell",
          "begin": "((?<!\\\\){th[[:space:]])",
          "end": "((?<!\\\\)})",
          "contentName": "markup.bold.tableheader.ocamldoc",
          "beginCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.tableheader.ocamldoc"
            }
          },
          "endCaptures": {
            "1": {
              "name": "punctuation.definition.list.begin.markdown.tableheader.ocamldoc"
            }
          },
          "patterns": [{ "include": "#markup" }]
        }
      ]
    },
    "lighttable": {
      "patterns": [
        { "include": "#markup" },
        {
          "comment": "table characters",
          "match": "\\||(\\-\\-\\-+)|(:\\-\\-\\-+:)|(:\\-\\-+)|(\\-\\-+:)",
          "name": "punctuation.definition.list.begin.markdown.tableheader.tablechars.ocamldoc"
        }
      ]
    },
    "braces": {
      "patterns": [
        {
          "begin": "(?<!\\\\){",
          "end": "(?<!\\\\)\\}",
          "patterns": [{ "include": "#braces" }]
        }
      ]
    }
  }
}
