<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE language SYSTEM "language.dtd" [
  <!ENTITY citation "(\s|^)\?\?[^\s]{1}[^?]+\?\?(?=\s|\.|,|;|:|\-|$)">
  <!ENTITY deleted "(\s|^)\-[^\s]{1}[^\-]+\-(?=\s|\.|,|;|:|\?|$)">
  <!ENTITY emphasis "(\s|^)_[^\s]{1}[^_]+_(?=\s|\.|,|;|:|\-|\?|$)">
  <!ENTITY inserted "(\s|^)\+[^\s]{1}[^\+]+\+(?=\s|\.|,|;|:|\-|\?|$)">
  <!ENTITY monospaced "(\s|^)\{\{[^\s]{1}[^}]+\}\}(?=\s|\.|,|;|:|\-|$)">
  <!ENTITY strong "(\s|^)\*[^\s]{1}[^\*]+\*(?=\s|\.|,|;|:|\-|\?|$)">
  <!ENTITY subscript "(\s|^)~[^\s]{1}[^~]+~(?=\s|\.|,|;|:|\-|\?|$)">
  <!ENTITY superscript "(\s|^)\^[^\s]{1}[^\^]+\^(?=\s|\.|,|;|:|\-|\?|$)">
  <!ENTITY url "(http:|https:|ftp:|mailto:)[^]| ]*(?=$|[]|\s])">
]>
<language name="Jira" section="Markup" version="0.2" kateversion="3.10" extensions="*.jira" mimetype="" license="FDL" >
  <highlighting>

    <!--
    Documentation about the Jira syntax: https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all
    -->

    <contexts>

      <!-- Main Context -->
      <context name="Main" attribute="Normal" lineEndContext="#stay" >
        <IncludeRules context="FindBlockQuote" />
        <IncludeRules context="FindColor" />
        <IncludeRules context="FindHeader" />
        <IncludeRules context="FindQuote" />
        <IncludeRules context="FindTextBreaks" />
        <IncludeRules context="FindTextEffects" />
      </context>


      <!-- Contexts -->

      <!-- Headings -->
      <context name="Header" attribute="Header" lineEndContext="#pop" />

      <!-- Text Effects -->
      <context name="BlockQuote" lineEndContext="#pop" />
      <context name="Bold" lineEndContext="#stay">
        <DetectChar char="*" attribute="Special Character" context="BoldContent" />
      </context>
      <context name="BoldContent" attribute="Bold" lineEndContext="#stay">
        <DetectChar char="*" attribute="Special Character" context="#pop#pop" />
      </context>
      <context name="Citation" lineEndContext="#stay">
        <Detect2Chars char="?" char1="?" attribute="Special Character" context="CitationContent" />
      </context>
      <context name="CitationContent" attribute="Italic" lineEndContext="#stay">
        <Detect2Chars char="?" char1="?" attribute="Special Character" context="#pop#pop" />
      </context>

      <context name="Color">
        <StringDetect String="{color:" context="ColorTagColor" attribute="Special Character" />
      </context>
      <context name="ColorTagColor">
        <!-- Black and White have been skipped on purpose. -->
        <StringDetect String="silver}"  context="ColorSilverTagColor" lookAhead="true" />
        <StringDetect String="gray}"  context="ColorGrayTagColor" lookAhead="true" />
        <StringDetect String="red}"  context="ColorRedTagColor" lookAhead="true" />
        <StringDetect String="maroon}"  context="ColorMaroonTagColor" lookAhead="true" />
        <StringDetect String="yellow}"  context="ColorYellowTagColor" lookAhead="true" />
        <StringDetect String="olive}"  context="ColorOliveTagColor" lookAhead="true" />
        <StringDetect String="lime}"  context="ColorLimeTagColor" lookAhead="true" />
        <StringDetect String="green}"  context="ColorGreenTagColor" lookAhead="true" />
        <StringDetect String="aqua}"  context="ColorAquaTagColor" lookAhead="true" />
        <StringDetect String="teal}"  context="ColorTealTagColor" lookAhead="true" />
        <StringDetect String="blue}"  context="ColorBlueTagColor" lookAhead="true" />
        <StringDetect String="navy}"  context="ColorNavyTagColor" lookAhead="true" />
        <StringDetect String="fuchsia}"  context="ColorFuchsiaTagColor" lookAhead="true" />
        <StringDetect String="purple}"  context="ColorPurpleTagColor" lookAhead="true" />
        <DetectChar char="}"  attribute="Special Character" context="UnhighlightedColorContent" />
      </context>
      <context name="UnhighlightedColorContent">
        <StringDetect String="{color}" attribute="Special Character" context="#pop#pop#pop" />
      </context>
      <context name="HighlightedColorContent">
        <StringDetect String="{color}" attribute="Special Character" context="#pop#pop#pop#pop" />
      </context>
      <context name="ColorSilverTagColor">
        <StringDetect String="silver" attribute="Silver" />
        <DetectChar char="}" attribute="Special Character" context="SilverContent" />
      </context>
      <context name="SilverContent" attribute="Silver">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorGrayTagColor">
        <StringDetect String="gray" attribute="Gray" />
        <DetectChar char="}" attribute="Special Character" context="GrayContent" />
      </context>
      <context name="GrayContent" attribute="Gray">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorRedTagColor">
        <StringDetect String="red" attribute="Red" />
        <DetectChar char="}" attribute="Special Character" context="RedContent" />
      </context>
      <context name="RedContent" attribute="Red">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorMaroonTagColor">
        <StringDetect String="maroon" attribute="Maroon" />
        <DetectChar char="}" attribute="Special Character" context="MaroonContent" />
      </context>
      <context name="MaroonContent" attribute="Maroon">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorYellowTagColor">
        <StringDetect String="yellow" attribute="Yellow" />
        <DetectChar char="}" attribute="Special Character" context="YellowContent" />
      </context>
      <context name="YellowContent" attribute="Yellow">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorOliveTagColor">
        <StringDetect String="olive" attribute="Olive" />
        <DetectChar char="}" attribute="Special Character" context="OliveContent" />
      </context>
      <context name="OliveContent" attribute="Olive">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorLimeTagColor">
        <StringDetect String="lime" attribute="Lime" />
        <DetectChar char="}" attribute="Special Character" context="LimeContent" />
      </context>
      <context name="LimeContent" attribute="Limed">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorGreenTagColor">
        <StringDetect String="green" attribute="Green" />
        <DetectChar char="}" attribute="Special Character" context="GreenContent" />
      </context>
      <context name="GreenContent" attribute="Green">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorAquaTagColor">
        <StringDetect String="aqua" attribute="Aqua" />
        <DetectChar char="}" attribute="Special Character" context="AquaContent" />
      </context>
      <context name="AquaContent" attribute="Aqua">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorTealTagColor">
        <StringDetect String="teal" attribute="Teal" />
        <DetectChar char="}" attribute="Special Character" context="TealContent" />
      </context>
      <context name="TealContent" attribute="Teal">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorBlueTagColor">
        <StringDetect String="blue" attribute="Blue" />
        <DetectChar char="}" attribute="Special Character" context="BlueContent" />
      </context>
      <context name="BlueContent" attribute="Blue">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorNavyTagColor">
        <StringDetect String="navy" attribute="Navy" />
        <DetectChar char="}" attribute="Special Character" context="NavyContent" />
      </context>
      <context name="NavyContent" attribute="Navy">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorFuchsiaTagColor">
        <StringDetect String="fuchsia" attribute="Fuchsia" />
        <DetectChar char="}" attribute="Special Character" context="FuchsiaContent" />
      </context>
      <context name="FuchsiaContent" attribute="Fuchsia">
        <IncludeRules context="HighlightedColorContent" />
      </context>
      <context name="ColorPurpleTagColor">
        <StringDetect String="purple" attribute="Purple" />
        <DetectChar char="}" attribute="Special Character" context="PurpleContent" />
      </context>
      <context name="PurpleContent" attribute="Purple">
        <IncludeRules context="HighlightedColorContent" />
      </context>

      <context name="Deleted" lineEndContext="#stay">
        <DetectChar char="-" attribute="Special Character" context="DeletedContent" />
      </context>
      <context name="DeletedContent" attribute="Stroked Out" lineEndContext="#stay">
        <DetectChar char="-" attribute="Special Character" context="#pop#pop" />
      </context>
      <context name="Inserted" lineEndContext="#stay">
        <DetectChar char="+" attribute="Special Character" context="InsertedContent" />
      </context>
      <context name="InsertedContent" attribute="Underlined" lineEndContext="#stay">
        <DetectChar char="+" attribute="Special Character" context="#pop#pop" />
      </context>
      <context name="Italic" lineEndContext="#stay">
        <DetectChar char="_" attribute="Special Character" context="ItalicContent" />
      </context>
      <context name="ItalicContent" attribute="Italic" lineEndContext="#stay">
        <DetectChar char="_" attribute="Special Character" context="#pop#pop" />
      </context>
      <context name="Monospaced" attribute="Normal" lineEndContext="#stay">
        <Detect2Chars char="}" char1="}" attribute="Special Character" context="#pop" />
        <Detect2Chars char="{" char1="{" attribute="Special Character" />
      </context>
      <context name="Quote">
        <StringDetect String="{quote}" context="#pop" attribute="Special Character" />
      </context>
      <context name="Subscript" lineEndContext="#stay">
        <DetectChar char="~" attribute="Special Character" context="SubscriptContent" />
      </context>
      <context name="SubscriptContent" attribute="Normal" lineEndContext="#stay">
        <DetectChar char="~" attribute="Special Character" context="#pop#pop" />
      </context>
      <context name="Superscript" lineEndContext="#stay">
        <DetectChar char="^" attribute="Special Character" context="SuperscriptContent" />
      </context>
      <context name="SuperscriptContent" attribute="Normal" lineEndContext="#stay">
        <DetectChar char="^" attribute="Special Character" context="#pop#pop" />
      </context>


      <!-- Rules to Include -->

      <!-- BlockQuotes -->
      <context name="FindBlockQuote" attribute="Normal" lineEndContext="#stay" >
        <RegExpr String="bq\. " context="BlockQuote" attribute="Special Character" column="0" />
      </context>

      <!-- Colors -->
      <context name="FindColor" attribute="Normal" lineEndContext="#stay" >
        <RegExpr String="\{color:[^}]+\}" context="Color" lookAhead="true" />
      </context>

      <!-- Headings -->
      <context name="FindHeader" attribute="Normal" lineEndContext="#stay" >
        <RegExpr String="h[1-6]\. " context="Header" attribute="Special Character" column="0" />
      </context>

      <!-- Quotes -->
      <context name="FindQuote" attribute="Normal" lineEndContext="#stay" >
        <StringDetect String="{quote}" context="Quote" attribute="Special Character" />
      </context>

      <!-- Text Breaks -->
      <context name="FindTextBreaks" attribute="Normal" lineEndContext="#stay" >
        <Detect2Chars char="\" char1="\" attribute="Special Character" />
        <StringDetect String="----" attribute="Special Character" />
        <StringDetect String="---" attribute="Special Character" />
        <Detect2Chars char="-" char1="-" attribute="Special Character" />
      </context>

      <!-- Text Effects -->
      <context name="FindTextEffects" attribute="Normal" lineEndContext="#stay" >
        <RegExpr String="&citation;" context="Citation" lookAhead="true" />
        <RegExpr String="&deleted;" context="Deleted" lookAhead="true" />
        <RegExpr String="&emphasis;" context="Italic" lookAhead="true" />
        <RegExpr String="&inserted;" context="Inserted" lookAhead="true" />
        <RegExpr String="&strong;" context="Bold" lookAhead="true" />
        <RegExpr String="&subscript;" context="Subscript" lookAhead="true" />
        <RegExpr String="&superscript;" context="Superscript" lookAhead="true" />
        <RegExpr String="&monospaced;" context="Monospaced" lookAhead="true" />
      </context>

    </contexts>
    <itemDatas>
      <itemData name="Normal" defStyleNum="dsNormal" /><!-- Must be first. -->

      <itemData name="Bold" defStyleNum="dsNormal" bold="true" />
      <itemData name="Header" defStyleNum="dsKeyword" />
      <itemData name="Italic" defStyleNum="dsNormal" italic="true" />
      <itemData name="Keyword" defStyleNum="dsKeyword" />
      <itemData name="Special Character" defStyleNum="dsDecVal" bold="true" />
      <itemData name="Stroked Out" defStyleNum="dsNormal" strikeOut="true" />
      <itemData name="Underlined" defStyleNum="dsNormal" underline="true" />

      <!-- Colors -->
      <itemData name="Silver" defStyleNum="dsNormal" color="silver" />
      <itemData name="Gray" defStyleNum="dsNormal" color="gray" />
      <itemData name="Red" defStyleNum="dsNormal" color="red" />
      <itemData name="Maroon" defStyleNum="dsNormal" color="maroon" />
      <itemData name="Yellow" defStyleNum="dsNormal" color="yellow" />
      <itemData name="Olive" defStyleNum="dsNormal" color="olive" />
      <itemData name="Lime" defStyleNum="dsNormal" color="lime" />
      <itemData name="Green" defStyleNum="dsNormal" color="green" />
      <itemData name="Aqua" defStyleNum="dsNormal" color="aqua" />
      <itemData name="Teal" defStyleNum="dsNormal" color="teal" />
      <itemData name="Blue" defStyleNum="dsNormal" color="blue" />
      <itemData name="Navy" defStyleNum="dsNormal" color="navy" />
      <itemData name="Fuchsia" defStyleNum="dsNormal" color="fuchsia" />
      <itemData name="Purple" defStyleNum="dsNormal" color="purple" />
    </itemDatas>
  </highlighting>
  <general>
    <keywords casesensitive="0" />
    <indentation mode="normal" />
  </general>
</language>
