<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language
[
  <!--
  https://yaml.org/spec/1.2.2/#1032-tag-resolution with extensions
  -->

  <!ENTITY tab            "&#9;">

  <!-- For correct highlight range between selected brackets... -->
  <!ENTITY listOpen "[">
  <!ENTITY listClose "]">
  <!ENTITY hashOpen "{">
  <!ENTITY hashClose "}">

  <!--
  @{ Literal
  -->
  <!ENTITY null "(?:null|Null|NULL|~)">
  <!ENTITY bool "(?:y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF)">

  <!ENTITY int         "[1-9](?:_*+[0-9]++)*+">
  <!-- Hex, Octal, Binary -->
  <!ENTITY intOther    "0(?:x(?:_*+[0-9a-fA-F]++)++|o(?:_*+[0-7]++)++|(?:_*+[0-7]++)*+|b(?:_*+[01]++)++)">
  <!ENTITY intBase60   "[1-9][0-9_]*(?::[0-5]?[0-9])+">
  <!ENTITY allInt      "[-+]?(?:&intBase60;|&intOther;|&int;)">

  <!ENTITY date           "[0-9]{4}-[0-9]{2}-[0-9]{2}">
  <!ENTITY time           "[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]*)?">
  <!ENTITY time_canonical "T&time;Z?">
  <!ENTITY time_iso8601   "t&time;(?:[-+][0-9]+(?::[0-9]{2})?)?">
  <!ENTITY time_spaced    " +&time;(?: +[-+][0-9]+)?">
  <!ENTITY timestamp      "&date;(?:&time_canonical;|&time_iso8601;|&time_spaced;)?">

  <!ENTITY floatExp    "(?:[eE][-+]?[0-9]+)">
  <!ENTITY float1      "[0-9][0-9_]*+(?:&floatExp;|\.(?:_*+[0-9]++)*+(?:_*+&floatExp;)?)">
  <!ENTITY float2      "\._*+[0-9]++(?:_*+[0-9]++)*+(?:_*+&floatExp;)?">
  <!ENTITY floatBase60 "[0-9][0-9_]*(?::[0-5]?[0-9])+\.(?:_*+[0-9]++)*+">
  <!ENTITY inf         "\.(?:inf|Inf|INF)">
  <!ENTITY nan         "\.(?:nan|NaN|NAN)">
  <!ENTITY allFloat    "(?:[-+]?(?:&float1;|&float2;|&floatBase60;|&inf;)|&nan;)">

  <!ENTITY firstLitChar "nN~yYnNtTfFoO-+0123456789.">

  <!-- Key quoted -->
  <!ENTITY keyDQ          '"(?:\\.|[^"])*+"'>
  <!ENTITY keySQ          "'(?:[^']|'')*+'">

  <!ENTITY endValue       "(?:$|\s++(?:#|$))">
  <!ENTITY inlineSep      "[,\[\]{}]|:(?:\s|$)">
  <!ENTITY endValueInline "(?:$|&inlineSep;|\s++(?:#|$|&inlineSep;))">
  <!--
  @} Literal
  -->

  <!--
  @{ Key attribute
  - key: value
    ~~~
  -->
  <!ENTITY keyPlainData             "(?:[^: \t]++|:(?! |$)|[\t ]++(?!#))">
  <!ENTITY listKeyPlainData "(?:[^,{}\[\]?: \t]++|:(?! |$)|[\t ]++(?!#)|[?](?! |$))">
  <!ENTITY keyPlain "&keyPlainData;++">
  <!ENTITY isKeyPoint "(?=:(?: |$))">
  <!ENTITY isPlain "(?!['&quot;&#37;\&listClose;\&hashClose;])">
  <!ENTITY keyAttr "(?:&keyDQ;[\t ]*+|&keySQ;[\t ]*+|&isPlain;&keyPlain;)?+&isKeyPoint;">

  <!-- string attributes in a list or hash have an optional space after ':' (json compatibility) -->
  <!ENTITY keyAttrDQEnd  '"[\t ]*+&isKeyPoint;'>
  <!ENTITY jsonAttrDQEnd '"[\t ]*+(?=:)'>
  <!ENTITY keyAttrSQEnd  "'[\t ]*+&isKeyPoint;">
  <!ENTITY jsonAttrSQEnd "'[\t ]*+(?=:)">
  <!ENTITY keyDQWithEscape  '"[^"\\]*+(?:&keyAttrDQEnd;|(?=\\.(\\.|[^"])*+&keyAttrDQEnd;))'>
  <!ENTITY jsonDQWithEscape '"[^"\\]*+(?:&jsonAttrDQEnd;|(?=\\.(\\.|[^"])*+&jsonAttrDQEnd;))'>
  <!ENTITY keySQWithEscape  "'[^']*+(?:&keyAttrSQEnd;|(?=''(?:[^']|'')*+&keyAttrSQEnd;))">
  <!ENTITY jsonSQWithEscape "'[^']*+(?:&jsonAttrSQEnd;|(?=''(?:[^']|'')*+&jsonAttrSQEnd;))">

  <!ENTITY keyAttrWithEscape  "&keyDQWithEscape;|&keySQWithEscape;|&isPlain;&keyPlainData;++&isKeyPoint;">
  <!ENTITY jsonAttrWithEscape "&jsonDQWithEscape;|&jsonSQWithEscape;|&isPlain;&listKeyPlainData;++&isKeyPoint;">
  <!--
  @} Key attribute
  -->

  <!-- Detect indentation with at most 4 symbols:
       >  - - - - key: value
          ~ ~ ~ ~ symbols

  Indentation level:

  - -   key: value
          value
      # ^ final indent
  - -   value
       value
  # ^ final indent
  - -   |
              line 1
               line 2
           # ^ final indent
  # ^ minimal final indent

  Captures spaces at the start of a line as well as spaces between -, : and ?.
  The captures between symbols are in 2 parts:
  - a single space which replaces the symbol in the dynamic construction rules
  - and the spaces which follow

     -   -   - bla
  ~~~         capture 1
      ~   ~   capture 2 and 4
       ~~  ~~ capture 3 and 5
     ^   ^    replaced with capture 2 and 4 for dynamic indent

  The empty capture at the end is necessary to ensure
  that the number of captures is always at least 9.
  Otherwise, %N in dynamic rules are not replaced with empty string. -->
  <!ENTITY spaceAndOpPrefix "^( ++)(?![|>&#37;])&afterSpaceLookAheadPrefix;">
  <!ENTITY spaceAndOpNewPrefix "^( ++)&afterSpaceLookAheadPrefix;">
  <!ENTITY afterSpaceLookAheadPrefix "(?=[-:?](?: |$)|&keyAttrOrSeq;)&lookAheadPrefix;()">
  <!ENTITY opPrefix "^(?=[-:?](?: |$)|(?!---(?:$| )|\.\.\.(?:$| ))&keyAttr;)()&lookAheadPrefix;.()">
  <!ENTITY keyAttrOrSeq "(?:[\&listOpen;\&hashOpen;]|&keyAttr;)">
  <!ENTITY noLastAttrOp  "[-:?]( )( *+)(?=[-:?](?: |$))">
  <!ENTITY tooManySym    "[-:?] ++[-:?](?: |$)">
  <!ENTITY noLastAttrOps "(?:&noLastAttrOp;(?:&noLastAttrOp;(?:&noLastAttrOp;)?+)?+)?+">
  <!ENTITY lookAheadPrefix "(?=&noLastAttrOps;(?!&tooManySym;)(?:(?:[-:?]( ))?+( *+)&keyAttrOrSeq;)?+)">
  <!ENTITY indent  "&#37;1&#37;2&#37;2&#37;3&#37;4&#37;4&#37;5&#37;6&#37;6&#37;7&#37;8&#37;8&#37;9 ">

  <!ENTITY newValueContexts "BlockPrefix!ValueTextIndent!ExplicitValueIndent!ExplicitKeyTextIndent!KeyOrValueIndent!KeyOrValue">
]>

<!-- Author: Dr Orlovsky MA <maxim@orlovsky.info> //-->
<!-- Modifications (YAML 1.2), values & support for literal/folded style:
       Nibaldo González S. <nibgonz@gmail.com>
       These modifications are under the MIT license. //-->
<!-- https://yaml.org/spec/1.2.2/#chapter-4-syntax-conventions -->
<language name="YAML" alternativeNames="YML" version="17" kateversion="6.22" section="Markup"
          extensions="*.yaml;*.yml;.clang-format;.clang-tidy;metadata;*.ksy" mimetype="text/yaml" priority="9"
          author="Dr Orlovsky MA (dr.orlovsky@gmail.com), Nibaldo González (nibgonz@gmail.com)" license="LGPL">
  <highlighting>
    <contexts>
      <context attribute="Normal Text" lineEndContext="#stay" name="normal" fallthroughContext="Lvl0Text">
        <IncludeRules context="FindSingleComment"/>

        <RegExpr attribute="Normal Text" context="&newValueContexts;" String="&spaceAndOpPrefix;" column="0"/>
        <AnyChar lookAhead="1" context="FindSpaces" String=" &tab;"/>
        <RegExpr lookAhead="1" context="&newValueContexts;" String="&opPrefix;" column="0"/>

        <AnyChar lookAhead="1" context="Lvl0Prefix" String="*!&amp;"/>
        <IncludeRules context="FindSeq"/>
        <IncludeRules context="FindStr"/>
        <AnyChar attribute="Literal/Folded Operator" context="Lvl0BlockPrefix!BlockHeader" String="|>" beginRegion="Block"/>
        <DetectChar attribute="Directive" context="Directive" char="%" column="0"/>
        <AnyChar lookAhead="1" context="Lvl0MaybeHeader" String="-" column="0"/>
        <AnyChar lookAhead="1" context="Lvl0SymIndent" String=":?"/>
        <AnyChar lookAhead="1" context="Lvl0MaybeEOD" String="." column="0"/>
        <AnyChar attribute="Error" context="Lvl0Text" String="%&listClose;&hashClose;"/>
        <AnyChar lookAhead="1" context="Lvl0Literal" String="&firstLitChar;"/>
      </context>

      <context name="FindSeq" attribute="Normal Text">
        <DetectChar attribute="Operator" context="List" char="&listOpen;" beginRegion="List"/>
        <DetectChar attribute="Operator" context="Hash" char="&hashOpen;" beginRegion="Hash"/>
      </context>

      <context name="FindStr" attribute="Normal Text">
        <DetectChar attribute="String" context="StringSq" char="'" beginRegion="String"/>
        <DetectChar attribute="String" context="StringDq" char='"' beginRegion="String"/>
      </context>


      <!--
      @{ No indented text

      Normally, `lineEndContext` should be set to `#stay`,
      but this prevents the embedding of code blocks such as Markdown:

      ```
      text
      continuation (LvL0 context)
      ``` <- continuation also (LvL0 context, no top level context),

      This is not compliant and displays incorrectly in some cases:

      ```
      text
      [ a # should be text, not a list
      ```
      -->
      <context name="Lvl0Prefix" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="Lvl0Text">
        <DetectSpaces/>
        <IncludeRules context="FindMarker"/>
        <IncludeRules context="FindSeq"/>
        <IncludeRules context="FindStr"/>
        <DetectChar attribute="Comment" context="#pop!comment" char="#"/>
        <AnyChar lookAhead="1" context="#pop!Lvl0Literal" String="&firstLitChar;"/>
        <AnyChar attribute="Literal/Folded Operator" context="#pop!Lvl0BlockPrefix!BlockHeader" String="|>" beginRegion="Block"/>
      </context>

      <context name="Lvl0Literal" attribute="Attribute" lineEndContext="#pop" fallthroughContext="Lvl0Text">
        <RegExpr attribute="Integer" context="#pop!Lvl0Text" String="&allInt;(?=&endValue;)"/>
        <RegExpr attribute="Boolean" context="#pop!Lvl0Text" String="&bool;(?=&endValue;)"/>
        <RegExpr attribute="Float" context="#pop!Lvl0Text" String="&allFloat;(?=&endValue;)"/>
        <RegExpr attribute="Null" context="#pop!Lvl0Text" String="&null;(?=&endValue;)"/>
        <RegExpr attribute="Timestamp" context="#pop!Lvl0Text" String="&timestamp;(?=&endValue;)"/>
      </context>

      <context name="Lvl0Text" attribute="Attribute" lineEndContext="#pop">
        <StringDetect attribute="Comment" context="#pop!comment" String="#" column="0"/>
        <StringDetect attribute="Comment" context="#pop!comment" String=" #"/>
        <StringDetect attribute="Comment" context="#pop!comment" String="&tab;#"/>
        <StringDetect attribute="Error" String=": "/>
        <StringDetect attribute="Error" String=":&tab;"/>
        <LineContinue attribute="Error" char=":"/>
      </context>

      <context name="Lvl0SymIndent" attribute="Normal Text" fallthroughContext="#pop" lineEndContext="#pop">
        <DetectSpaces/>
        <StringDetect attribute="Operator" String="- "/>
        <StringDetect attribute="Operator" String="-&tab;"/>
        <StringDetect attribute="Operator" String="? "/>
        <StringDetect attribute="Operator" String="?&tab;"/>
        <StringDetect attribute="Key Points Operator" String=": "/>
        <StringDetect attribute="Key Points Operator" String=":&tab;"/>
        <LineContinue lookAhead="1" context="Lvl0SymIndentEndLineOp" char="-"/>
        <LineContinue lookAhead="1" context="Lvl0SymIndentEndLineOp" char="?"/>
        <LineContinue lookAhead="1" context="Lvl0SymIndentEndLineKpOp" char=":"/>
        <RegExpr attribute="Key" String="&keyAttrWithEscape;" context="#pop"/>
      </context>
      <context name="Lvl0SymIndentEndLineOp" attribute="Attribute">
        <AnyChar attribute="Operator" context="#pop#pop" String="?-"/>
      </context>
      <context name="Lvl0SymIndentEndLineKpOp" attribute="Attribute">
        <StringDetect attribute="Operator" context="#pop#pop" String=":"/>
      </context>

      <context name="Lvl0MaybeHeader" attribute="Attribute" fallthroughContext="#pop!Lvl0Text">
        <RegExpr attribute="Document Header" context="#pop" String="^---( +|$)" column="0"/>
        <RegExpr attribute="Integer" context="#pop!Lvl0Text" String="&allInt;(?=&endValue;)"/>
        <RegExpr attribute="Float" context="#pop!Lvl0Text" String="&allFloat;(?=&endValue;)"/>
        <StringDetect attribute="Operator" context="#pop!Lvl0SymIndent" String="- "/>
        <StringDetect attribute="Operator" context="#pop!Lvl0SymIndent" String="-&tab;"/>
        <LineContinue lookAhead="1" context="Lvl0SymIndentEndLineOp" char="-"/>
      </context>

      <context name="Lvl0MaybeEOD" attribute="Attribute" fallthroughContext="#pop!Lvl0Text">
        <RegExpr attribute="End of Document" context="#pop!EOD" String="^\.\.\.($| +(?=#|$))" column="0"/>
        <RegExpr attribute="Float" context="#pop!Lvl0Text" String="&allFloat;(?=&endValue;)"/>
      </context>
      <!--
      @} No indented text
      -->


      <!--
      @{ Find whitespace
      -->
      <context name="FindSpaces" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
        <StringDetect attribute="Normal Text" String=" "/>
        <StringDetect attribute="Alert" String="&tab;"/>
      </context>

      <context name="FindBlankLine" attribute="Attribute">
        <RegExpr String="^\s+(?=#|$)" column="0"/>
      </context>
      <!--
      @} Find whitespace
      -->


      <!--
      @{ # ...
      -->
      <context attribute="Comment" lineEndContext="#pop" name="comment">
        <DetectSpaces/>
        <IncludeRules context="##Comments"/>
        <DetectIdentifier/>
      </context>

      <context name="FindSingleComment" attribute="Attribute">
        <DetectChar attribute="Comment" context="comment" char="#"/>
      </context>
      <!--
      @} # ...
      -->


      <!--
      @{ '...'
      -->
      <context name="StringSq" attribute="String" noIndentationBasedFolding="true">
        <StringDetect attribute="Escaped Character" String="''"/>
        <DetectChar attribute="String" context="#pop" char="'" endRegion="String"/>
      </context>

      <context name="StringSqAsKey" attribute="Key" noIndentationBasedFolding="true">
        <StringDetect attribute="Escaped Character" String="''"/>
        <DetectChar attribute="Key" context="#pop" char="'" endRegion="String"/>
      </context>
      <!--
      @} '...'
      -->


      <!--
      @{ "..."
      -->
      <context name="StringDq" attribute="String" noIndentationBasedFolding="true">
        <DetectChar lookAhead="true" context="EscapeDq" char="\"/>
        <DetectChar attribute="String" context="#pop" char="&quot;" endRegion="String"/>
      </context>

      <context name="StringDqAsKey" attribute="Key" noIndentationBasedFolding="true">
        <DetectChar lookAhead="true" context="EscapeDq" char="\"/>
        <DetectChar attribute="Key" context="#pop" char="&quot;" endRegion="String"/>
      </context>

      <context name="EscapeDq" attribute="Normal Text">
        <RegExpr attribute="Escaped Character" context="#pop" String="\\([0abtnvfre &tab;&quot;/\\N_LP]|x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|$)"/>
        <RegExpr attribute="Error" context="#pop" String="\\(?:x[a-fA-F0-9]?|u[a-fA-F0-9]{0,3}|U[a-fA-F0-9]{0,7})?"/>
      </context>
      <!--
      @} "..."
      -->


      <!--
      @{ KeyOrValue
        - ? xxx
        ~~~~
        key:
        ~~~~
      -->
      <context name="KeyOrValueIndent" attribute="Normal Text" fallthroughContext="#pop#pop#pop#pop#pop">
        <IncludeRules context="FindSingleComment"/>
        <RegExpr attribute="Normal Text" context="#pop#pop#pop#pop#pop!&newValueContexts;" String="&spaceAndOpNewPrefix;" column="0"/>
        <IncludeRules context="FindBlankLine"/>
        <StringDetect context="KeyOrValue" String="&indent;" dynamic="1" column="0"/>
      </context>

      <context name="KeyOrValue" attribute="Normal Text" lineEndContext="#pop"  fallthroughContext="#pop#pop#pop#pop!ValueText">
        <IncludeRules context="KeyOrValueCommonBase"/>
        <RegExpr attribute="Key" String="&keyAttrWithEscape;" context="#pop#pop#pop!KeyOrValueKey"/>
        <IncludeRules context="KeyOrValueCommonStr"/>
        <AnyChar lookAhead="1" String="-:?" context="KeyOrValueMaybeOp"/>
        <AnyChar lookAhead="1" context="#pop#pop#pop#pop!ValueLiteral" String="&firstLitChar;"/>
        <AnyChar attribute="Error" context="#pop#pop#pop#pop!ValueText" String="%&listClose;&hashClose;"/>
      </context>

      <context name="KeyOrValueAsKey" attribute="Normal Text" lineEndContext="#pop"  fallthroughContext="#pop#pop!ExplicitKeyText">
        <IncludeRules context="KeyOrValueCommonBase"/>
        <IncludeRules context="KeyOrValueCommonStr"/>
        <AnyChar String="-:?" lookAhead="1" context="KeyOrValueAsKeyMaybeOp"/>
        <AnyChar attribute="Error" context="#pop#pop!ExplicitKeyText" String="%&listClose;&hashClose;"/>
      </context>

      <context name="KeyOrValueKey" attribute="Key" fallthroughContext="StringDqAsKey!EscapeDq">
        <StringDetect String=":" attribute="Key Points Operator" context="#pop!ExplicitValuePrefix"/>
        <DetectSpaces attribute="Key"/>
        <StringDetect attribute="Escaped Character" context="StringSqAsKey" String="''"/>
      </context>

      <context name="KeyOrValueMaybeOp" attribute="Attribute">
        <IncludeRules context="KeyOrValueOp"/>
        <AnyChar lookAhead="1" context="#pop#pop#pop#pop!ValueLiteral" String="-"/>
        <AnyChar String="-:?" context="#pop#pop#pop#pop#pop!ValueText"/>
      </context>

      <context name="KeyOrValueAsKeyMaybeOp" attribute="Attribute">
        <IncludeRules context="KeyOrValueOp"/>
        <AnyChar String="-:?" context="#pop#pop#pop!ExplicitKeyText"/>
      </context>

      <context name="KeyOrValueOp" attribute="Attribute">
        <LineContinue attribute="Operator" context="#pop#pop" char="-"/>
        <LineContinue attribute="Operator" context="#pop#pop" char="?"/>
        <LineContinue attribute="Key Points Operator" context="#pop#pop" char=":"/>
      </context>

      <context name="KeyOrValueCommonBase" attribute="Attribute">
        <StringDetect attribute="Operator" String="- "/>
        <StringDetect attribute="Key Points Operator" context="#pop!KeyOrValue" String=": "/>
        <StringDetect attribute="Key Points Operator" context="#pop!KeyOrValue" String=":&tab;"/>
        <StringDetect attribute="Operator" context="#pop!KeyOrValueAsKey" String="? "/>
        <StringDetect attribute="Operator" context="#pop!KeyOrValueAsKey" String="?&tab;"/>

        <IncludeRules context="FindSpaces"/>

        <DetectChar attribute="Comment" context="#pop!comment" char="#"/>

        <IncludeRules context="FindMarker"/>

        <DetectChar attribute="Operator" context="ValueSepOrRoot!List" char="&listOpen;" beginRegion="List"/>
        <DetectChar attribute="Operator" context="ValueSepOrRoot!Hash" char="&hashOpen;" beginRegion="Hash"/>

        <AnyChar attribute="Literal/Folded Operator" context="#pop#pop#pop#pop#pop!BlockHeader" String="|>" beginRegion="Block"/>
      </context>

      <context name="KeyOrValueCommonStr" attribute="Attribute">
        <DetectChar attribute="String" context="ValueSepOrRoot!StringSq" char="'" beginRegion="String"/>
        <DetectChar attribute="String" context="ValueSepOrRoot!StringDq" char='"' beginRegion="String"/>
      </context>

      <context name="ValueSepOrRoot" attribute="Attribute" lineEndContext="#pop#pop#pop#pop#pop#pop#pop" fallthroughContext="#pop">
        <DetectSpaces/>
        <DetectChar attribute="Comment" context="#pop#pop#pop#pop#pop#pop#pop!comment" char="#"/>
        <StringDetect attribute="Key Points Operator" context="#pop#pop#pop#pop!ExplicitValuePrefix" String=": "/>
        <StringDetect attribute="Key Points Operator" context="#pop#pop#pop#pop!ExplicitValuePrefix" String=":&tab;"/>
        <LineContinue attribute="Key Points Operator" context="#pop#pop#pop#pop" char=":"/>
      </context>
      <!--
      @} KeyOrValue
      -->


      <!--
      @{ marker (alias, reference, tag)
      https://yaml.org/spec/1.2.2/#6821-tag-handles
      https://yaml.org/spec/1.2.2/#692-node-anchors
      https://yaml.org/spec/1.2.2/#71-alias-nodes
      -->
      <context name="FindMarker" attribute="Attribute">
        <DetectChar char="*" attribute="Reference" context="Reference"/>
        <DetectChar char="&amp;" attribute="Alias" context="Alias"/>
        <DetectChar char="!" context="Tag" lookAhead="1"/>
      </context>

      <!-- &alias -->
      <context name="Alias" attribute="Alias" lineEndContext="#pop">
        <AnyChar String=" &tab;,[]{}:" lookAhead="1" context="#pop"/>
      </context>

      <!-- *ref -->
      <context name="Reference" attribute="Reference" lineEndContext="#pop">
        <IncludeRules context="Alias"/>
      </context>

      <context name="Tag" attribute="Attribute">
        <!-- ns_word_char = [-0-9a-zA-Z] -->
        <!-- named tag: !ns_word_char!ns_tag_char -->
        <!-- primary tag: !ns_tag_char -->
        <!-- secondary tag: !!ns_tag_char -->
        <!-- verbatim tag: !<ns_tag_char> -->
        <StringDetect String="!!" attribute="Data Types" context="SecondaryTag"/>
        <StringDetect String="!&lt;" attribute="Tag" context="VerbatimTag"/>
        <StringDetect String="!" attribute="Tag" context="PrimaryTag"/>
      </context>
      <context name="FindTagError" attribute="Tag">
        <StringDetect String="!!" attribute="Error" context="#pop!SecondaryTag"/>
        <StringDetect String="!&lt;" attribute="Error" context="#pop!VerbatimTag"/>
        <StringDetect String="!" attribute="Error" context="#pop!PrimaryTag"/>
      </context>
      <context name="PrimaryTag" attribute="Tag" lineEndContext="#pop#pop" fallthroughContext="#pop#pop">
        <IncludeRules context="ns_tag_char"/>
        <DetectChar char="!" attribute="Tag" context="#pop!NamedTag"/>
      </context>
      <context name="NamedTag" attribute="Tag" lineEndContext="#pop#pop" fallthroughContext="#pop#pop">
        <IncludeRules context="ns_tag_char"/>
        <IncludeRules context="FindTagError"/>
      </context>
      <context name="SecondaryTag" attribute="Data Types" lineEndContext="#pop#pop" fallthroughContext="#pop#pop">
        <IncludeRules context="ns_tag_char"/>
        <IncludeRules context="FindTagError"/>
      </context>
      <context name="VerbatimTag" attribute="Tag" lineEndContext="#pop#pop" fallthroughContext="#pop#pop">
        <IncludeRules context="ns_tag_char"/>
        <DetectChar char=">" attribute="Tag" context="#pop#pop"/>
        <IncludeRules context="FindTagError"/>
      </context>
      <context name="ns_tag_char" attribute="Tag">
        <!-- ns_tag_char + "^," -->
        <AnyChar String="-0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz%#;/?:@&amp;=+$_.~*'()^,"/>
      </context>
      <!--
      @} marker (alias, reference, tag)
      -->


      <!--
      @{ | and >
      https://yaml.org/spec/1.2.2/#812-literal-style
      https://yaml.org/spec/1.2.2/#813-folded-style

      ```yaml
      - key:
              |
           text
      # ^ final indent (for current indent)
        # ^ final indent for block (last space)
      ```

      ```yaml
              |
           text
        # ^ final indent for block (last space)
      ```
      -->
      <!-- |1+ # dsds
            ~~~~~~~~~
      -->
      <context name="BlockHeader" attribute="Error" lineEndContext="#pop" fallthroughContext="BlockHeaderNoText">
        <AnyChar attribute="Literal/Folded Operator" String="-+123456789"/>
      </context>
      <context name="BlockHeaderNoText" attribute="Error" lineEndContext="#pop#pop">
        <DetectSpaces attribute="Literal/Folded Operator"/>
        <DetectChar attribute="Comment" context="#pop#pop!comment" char="#"/>
      </context>

      <context name="BlockPrefix" attribute="Literal/Folded Block" fallthroughContext="BlockEnd" noIndentationBasedFolding="true">
        <IncludeRules context="FindEmptyLine"/>
        <RegExpr context="BlockIndent!BlockText" String="^(&indent; *)" dynamic="1" column="0"/>
      </context>

      <context name="Lvl0BlockPrefix" attribute="Literal/Folded Block" fallthroughContext="BlockEnd" noIndentationBasedFolding="true">
        <IncludeRules context="FindEmptyLine"/>
        <RegExpr context="BlockIndent!BlockText" String="^( +)" column="0"/>
      </context>

      <context name="BlockIndent" attribute="Literal/Folded Block" fallthroughContext="#pop!BlockEnd" noIndentationBasedFolding="true">
        <StringDetect context="BlockText" String="%1" dynamic="1"/>
        <IncludeRules context="FindEmptyLine"/>
      </context>

      <context name="BlockText" attribute="Literal/Folded Block" lineEndContext="#pop">
      </context>

      <context name="BlockEnd" attribute="Literal/Folded Block">
        <RegExpr lookAhead="1" context="#pop#pop" String="." endRegion="Block"/>
      </context>

      <context name="FindEmptyLine" attribute="Attribute">
        <RegExpr String="^\s+$" column="0"/>
      </context>
      <!--
      @} | and >
      -->


      <!--
      @{ Value

                   (fallthrough) -> root
                         ^
                        / \
         "ValueTextIndent!ExplicitValueIndent"
          ^         |            |          ^
      (endline)  (indent)     (indent)  (endline)
          |         v            v          |
          \____ ValueText <~.  ExplicitValuePrefix
                 |          |          |
           (fallthrough)    |    (fallthrough)
                 v          |          v
               root         +~~~~ ValueLiteral
                            |          |
                            \___ (fallthrough)
      -->
      <context name="ExplicitValueIndent" attribute="Normal Text" fallthroughContext="#pop#pop#pop">
        <IncludeRules context="FindSingleComment"/>
        <RegExpr attribute="Normal Text" context="#pop#pop#pop!&newValueContexts;" String="&spaceAndOpNewPrefix;" column="0"/>
        <IncludeRules context="FindBlankLine"/>
        <StringDetect context="ExplicitValuePrefix" String="&indent;" dynamic="1" column="0"/>
      </context>

      <context name="ExplicitValuePrefix" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop#pop!ValueText">
        <DetectSpaces/>
        <IncludeRules context="FindMarker"/>
        <DetectChar attribute="Comment" context="#pop!comment" char="#"/>

        <IncludeRules context="FindStr"/>
        <IncludeRules context="FindSeq"/>
        <AnyChar attribute="Literal/Folded Operator" context="#pop#pop#pop!BlockHeader" String="|>" beginRegion="Block"/>

        <StringDetect attribute="Operator" String="- "/>
        <StringDetect attribute="Operator" String="? "/>
        <StringDetect attribute="Operator" String="?&tab;"/>
        <LineContinue context="#pop" attribute="Operator" char="?"/>
        <LineContinue context="#pop" attribute="Operator" char="-"/>
        <AnyChar lookAhead="1" context="#pop#pop!ValueLiteral" String="&firstLitChar;"/>
        <AnyChar attribute="Error" context="#pop#pop!ValueText" String="%&listClose;&hashClose;"/>
      </context>


      <context name="ValueLiteral" attribute="Attribute" fallthroughContext="#pop!ValueText">
        <RegExpr attribute="Integer" context="#pop!ValueText" String="&allInt;(?=&endValue;)"/>
        <RegExpr attribute="Boolean" context="#pop!ValueText" String="&bool;(?=&endValue;)"/>
        <RegExpr attribute="Float" context="#pop!ValueText" String="&allFloat;(?=&endValue;)"/>
        <RegExpr attribute="Null" context="#pop!ValueText" String="&null;(?=&endValue;)"/>
        <RegExpr attribute="Timestamp" context="#pop!ValueText" String="&timestamp;(?=&endValue;)"/>
      </context>


      <context name="ValueTextIndent" attribute="Attribute" fallthroughContext="#pop#pop">
        <DetectChar attribute="Comment" context="#pop#pop!comment" char="#"/>
        <IncludeRules context="FindBlankLine"/>
        <StringDetect context="ValueText" String="&indent;" dynamic="1" column="0"/>
      </context>

      <context name="ValueText" attribute="Attribute" lineEndContext="#pop">
        <StringDetect attribute="Comment" context="#pop#pop#pop!comment" String="#" column="0"/>
        <StringDetect attribute="Comment" context="#pop#pop#pop!comment" String=" #"/>
        <StringDetect attribute="Comment" context="#pop#pop#pop!comment" String="&tab;#"/>
        <StringDetect attribute="Error" context="#pop#pop#pop" String=": "/>
        <StringDetect attribute="Error" context="#pop#pop#pop" String=":&tab;"/>
        <LineContinue attribute="Error" context="#pop#pop#pop" char=":"/>
      </context>
      <!--
      @} Value
      -->


      <!--
      @{ Key

      '? ' key
      -->
      <context name="ExplicitKeyTextIndent" attribute="Key" fallthroughContext="#pop#pop#pop#pop#pop">
        <DetectChar attribute="Comment" context="#pop#pop#pop#pop#pop!comment" char="#"/>
        <IncludeRules context="FindBlankLine"/>
        <StringDetect context="ExplicitKeyText" String="&indent;" dynamic="1" column="0"/>
      </context>

      <context name="ExplicitKeyText" attribute="Key" lineEndContext="#pop">
        <StringDetect context="#pop#pop#pop#pop#pop#pop!comment" String="#" column="0"/>
        <StringDetect context="#pop#pop#pop#pop#pop#pop!comment" String=" #"/>
        <StringDetect context="#pop#pop#pop#pop#pop#pop!comment" String="&tab;#"/>
        <StringDetect attribute="Key Points Operator" context="#pop#pop!ExplicitValuePrefix" String=": "/>
        <StringDetect attribute="Key Points Operator" context="#pop#pop!ExplicitValuePrefix" String=":&tab;"/>
        <LineContinue lookAhead="1" context="ValueOnKeyOp" char=":"/>
      </context>

      <context name="ValueOnKeyOp" attribute="Attribute">
        <StringDetect String=":" attribute="Key Points Operator" context="#pop#pop#pop!ExplicitValuePrefix"/>
      </context>
      <!--
      @} Key
      -->


      <!--
      @{ List and Hash
      -->

      <!-- [ ... ] -->
      <context name="List" attribute="List" fallthroughContext="ListValue" noIndentationBasedFolding="true">
        <DetectChar attribute="Operator" context="#pop" char="&listClose;" endRegion="List"/>
        <IncludeRules context="ElementCommon"/>
        <AnyChar attribute="Error" String=">|%&hashClose;"/>
      </context>

      <!-- { ... } -->
      <context name="Hash" attribute="Hash" fallthroughContext="HashValue" noIndentationBasedFolding="true">
        <DetectChar attribute="Operator" context="#pop" char="&hashClose;" endRegion="Hash"/>
        <IncludeRules context="ElementCommon"/>
        <AnyChar attribute="Error" String=">|%&listClose;"/>
      </context>

      <context name="ElementCommon" attribute="List">
        <DetectSpaces/>
        <DetectChar attribute="Operator" char=","/>
        <IncludeRules context="FindSingleComment"/>
        <IncludeRules context="FindSeq"/>
        <IncludeRules context="FindMarker"/>
        <StringDetect attribute="Operator" context="ListAttr" String=": "/>
        <StringDetect attribute="Operator" context="ListAttr" String=":&tab;"/>
        <LineContinue attribute="Operator" context="ListAttr" char=":"/>

        <RegExpr attribute="Key" context="ListKey" String="&jsonAttrWithEscape;"/>

        <IncludeRules context="FindStr"/>

        <StringDetect attribute="Operator" context="ListExplicitKey" String="? "/>
        <StringDetect attribute="Operator" context="ListExplicitKey" String="?&tab;"/>
        <LineContinue attribute="Operator" context="ListExplicitKey" char="?"/>

        <IncludeRules context="FindDashError"/>
      </context>

      <!-- [ - value ] / [ key: - value ] / { - value } / { key: - value }
             ~                  ~             ~                  ~
      -->
      <context name="FindDashError" attribute="Error" noIndentationBasedFolding="true">
        <StringDetect attribute="Error" String="- "/>
        <StringDetect attribute="Error" String="-&tab;"/>
        <LineContinue attribute="Error" char="-"/>
      </context>

      <!-- [ ? key ] / { ? key }
               ~~~         ~~~
      -->
      <context name="ListExplicitKey" attribute="Key" fallthroughContext="ListExplicitKeyName" noIndentationBasedFolding="true">
        <DetectSpaces/>
        <IncludeRules context="FindMarker"/>
        <IncludeRules context="FindDashError"/>
        <AnyChar lookAhead="1" context="#pop" String=",[]{}'&quot;"/>
        <AnyChar attribute="Error" String=">|"/>
      </context>

      <context name="ListExplicitKeyName" attribute="Key" noIndentationBasedFolding="true">
        <StringDetect attribute="Comment" context="#pop#pop!comment" String="#" column="0"/>
        <StringDetect attribute="Comment" context="#pop#pop!comment" String=" #"/>
        <StringDetect attribute="Comment" context="#pop#pop!comment" String="&tab;#"/>
        <AnyChar lookAhead="1" context="#pop#pop" String=",[]{}"/>
        <StringDetect attribute="Operator" context="#pop#pop!ListAttr" String=": "/>
        <StringDetect attribute="Operator" context="#pop#pop!ListAttr" String=":&tab;"/>
        <LineContinue attribute="Operator" context="#pop#pop!ListAttr" char=":"/>
        <StringDetect attribute="Error" context="#pop" String="? "/>
        <StringDetect attribute="Error" context="#pop" String="?&tab;"/>
        <LineContinue attribute="Error" context="#pop" char="?"/>
      </context>

      <!-- [ key: value ] / { key: value }
                ~                ~
      -->
      <context name="ListKey" attribute="Key" fallthroughContext="StringDqAsKey!EscapeDq" noIndentationBasedFolding="true">
        <StringDetect String=":" attribute="Key Points Operator" context="#pop!ListAttr"/>
        <DetectSpaces attribute="Key"/>
        <StringDetect attribute="Escaped Character" context="StringSqAsKey" String="''"/>
      </context>

      <!-- [ value ]
             ~~~~~
      -->
      <context name="ListValue" attribute="List" fallthroughContext="ListValueText" noIndentationBasedFolding="true">
        <IncludeRules context="ListExplicitKey"/>
        <RegExpr attribute="Integer" context="#pop" String="&allInt;(?=&endValueInline;)"/>
        <RegExpr attribute="Boolean" context="#pop" String="&bool;(?=&endValueInline;)"/>
        <RegExpr attribute="Float" context="#pop" String="&allFloat;(?=&endValueInline;)"/>
        <RegExpr attribute="Null" context="#pop" String="&null;(?=&endValueInline;)"/>
        <RegExpr attribute="Timestamp" context="#pop" String="&timestamp;(?=&endValueInline;)"/>
      </context>

      <context name="ListValueText" attribute="List" noIndentationBasedFolding="true">
        <StringDetect attribute="Comment" context="#pop#pop!comment" String="#" column="0"/>
        <StringDetect attribute="Comment" context="#pop#pop!comment" String=" #"/>
        <StringDetect attribute="Comment" context="#pop#pop!comment" String="&tab;#"/>
        <AnyChar lookAhead="1" context="#pop#pop" String=",[]{}"/>
        <StringDetect attribute="Error" context="#pop#pop!ListAttr" String=": "/>
        <StringDetect attribute="Error" context="#pop#pop!ListAttr" String=":&tab;"/>
        <LineContinue attribute="Error" context="#pop#pop!ListAttr" char=":"/>
        <StringDetect attribute="Error" context="#pop#pop!ListExplicitKey" String="? "/>
        <StringDetect attribute="Error" context="#pop#pop!ListExplicitKey" String="?&tab;"/>
        <LineContinue attribute="Error" context="#pop#pop!ListExplicitKey" char="?"/>
      </context>

      <!-- { value }
             ~~~~~
      -->
      <context name="HashValue" attribute="Hash" fallthroughContext="HashValueText" noIndentationBasedFolding="true">
        <IncludeRules context="ListExplicitKey"/>
      </context>
      <context name="HashValueText" attribute="Hash" noIndentationBasedFolding="true">
        <IncludeRules context="ListValueText"/>
      </context>

      <!-- [ key: value ] / { key: value }
                  ~~~~~            ~~~~~
      -->
      <context name="ListAttr" attribute="Attribute" fallthroughContext="ListAttrText" noIndentationBasedFolding="true">
        <IncludeRules context="ListValue"/>
      </context>

      <context name="ListAttrText" attribute="Attribute" noIndentationBasedFolding="true">
        <IncludeRules context="ListValueText"/>
      </context>
      <!--
      @} List and Hash
      -->


      <context attribute="Error" lineEndContext="#stay" name="EOD">
        <DetectChar attribute="Comment" context="#pop!comment" char="#"/>
        <DetectChar attribute="Error" context="#pop!List" char="&listOpen;" beginRegion="List"/>
        <DetectChar attribute="Error" context="#pop!Hash" char="&hashOpen;" beginRegion="Hash"/>
        <DetectChar attribute="Error" context="#pop!StringSq" char="'" beginRegion="String"/>
        <DetectChar attribute="Error" context="#pop!StringDq" char='"' beginRegion="String"/>
      </context>

      <context attribute="Directive" lineEndContext="#pop" name="Directive">
      </context>

    </contexts>

    <itemDatas>
      <itemData name="Normal Text" defStyleNum="dsAttribute"/>
      <itemData name="Attribute" defStyleNum="dsAttribute"/>
      <itemData name="List" defStyleNum="dsAttribute"/>
      <itemData name="Hash" defStyleNum="dsAttribute"/>
      <itemData name="Comment" defStyleNum="dsComment"/>
      <itemData name="End of Document" defStyleNum="dsComment"/>
      <itemData name="Document Header" defStyleNum="dsPreprocessor"/>
      <itemData name="Data Types" defStyleNum="dsOthers"/>
      <itemData name="Tag" defStyleNum="dsOthers"/>
      <itemData name="Alias" defStyleNum="dsOthers"/>
      <itemData name="Reference" defStyleNum="dsOthers"/>
      <itemData name="Key" defStyleNum="dsFunction" bold="1"/>
      <itemData name="Directive" defStyleNum="dsPreprocessor"/>
      <itemData name="Key Points Operator" defStyleNum="dsKeyword"/>
      <itemData name="Operator" defStyleNum="dsKeyword"/>
      <itemData name="String" defStyleNum="dsString"/>
      <itemData name="Escaped Character" defStyleNum="dsSpecialChar"/>
      <itemData name="Literal/Folded Operator" defStyleNum="dsChar" bold="1"/>
      <itemData name="Literal/Folded Block" defStyleNum="dsNormal"/>
      <itemData name="Null" defStyleNum="dsChar"/>
      <itemData name="Boolean" defStyleNum="dsChar"/>
      <itemData name="Integer" defStyleNum="dsDecVal"/>
      <itemData name="Float" defStyleNum="dsFloat"/>
      <itemData name="Timestamp" defStyleNum="dsBaseN"/>
      <itemData name="Error" defStyleNum="dsError"/>
      <itemData name="Alert" defStyleNum="dsAlert" backgroundColor="#EF9A9A"/>
    </itemDatas>
  </highlighting>

  <general>
    <folding indentationsensitive="1"/>
    <emptyLines>
      <emptyLine regexpr="(?:\s+|\s*#.*)"/>
    </emptyLines>
    <comments>
      <comment name="singleLine" start="#" position="afterwhitespace"/>
    </comments>
    <keywords casesensitive="1"/>
  </general>
</language>
<!-- kate: replace-tabs on; tab-width 2; indent-width 2; -->
