Guest User

My Kate/Kile highlighter for ConTeXt

a guest
Apr 20th, 2013
88
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE language SYSTEM "language.dtd">
  3. <language name="ConTeXt" version="1.02" section="Markup" kateversion="2.3" extensions="*.mkii;*.mkiv" mimetype="text/x-tex" casesensitive="1"
  4.          author="Michael Krauss (mickraus@googlemail.com)" license="LGPL" >
  5.             <!-- I modified it based on the LaTeX highlighting file to (1) allow spell-checking only in text sections and (2) show section* headings in bold. I prefer to use the extension, .context to prevent confusing the text editor. You may want to change that, above. -->
  6.   <highlighting>
  7.     <contexts>
  8.       <!-- Normal text -->
  9.       <context name="Normal Text" attribute="Normal Text" lineEndContext="#stay">
  10.         <RegExpr String="\\setup" attribute="Structure" context="FindSetup" />
  11.         <RegExpr String="\\start" attribute="Environment" context="FindStart" beginRegion="block"/>
  12.         <RegExpr String="\\stop" attribute="Environment" context="FindStop" endRegion="block"/>
  13.         <RegExpr String="\\type" attribute="Keyword" context="FindVerbatimCom"/>
  14.         <RegExpr String="\\(part|chapter|section|subsection|subsubsection|title|subject|subsubject|subsubsubject)" attribute="Structure" context="Sectioning"/>
  15.  
  16.         <DetectChar char="$" attribute="Math" context="MathModeTeX" beginRegion="mathMode" />
  17.         <RegExpr String="\\(matNormal Texthematics|math)" attribute="Keyword" context="FindMathConTeXt" beginRegion="mathMode"/>
  18.         <!-- Recognize quoted symbols -->
  19.         <RegExpr String="\\[^a-zA-Z]" attribute="Keyword" context="#stay" />
  20.         <DetectChar char="%" attribute="Comment" context="Comment"/>
  21.         <DetectChar char="\" attribute="Keyword" context="Command"/>
  22.       </context>
  23.  
  24.       <!-- LaTeX sectioning commands -->
  25.       <context name="Sectioning" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
  26.         <RegExpr String="\[[^\]]*\]" attribute="Normal Text" context="#stay"/>
  27.         <DetectChar char=" " attribute="Normal Text" context="#stay"/>
  28.         <DetectChar char="{" attribute="Normal Text" context="SectioningInside"/>
  29.         <DetectChar char="}" attribute="Normal Text" context="#pop"/>
  30.         <DetectChar char="%" attribute="Comment" context="Comment"/>
  31.       </context>
  32.       <context name="SectioningInside" attribute="Structure Text" lineEndContext="#stay">
  33.         <DetectChar char="{" attribute="Normal Text" context="SectioningInside"/>
  34.         <DetectChar char="}" attribute="Normal Text" context="#pop"/>
  35.         <StringDetect String="\(" attribute="Structure Math" context="SectioningMathMode" />
  36.         <DetectChar char="\" attribute="Structure Keyword" context="SectioningContrSeq"/>
  37.         <DetectChar char="$" attribute="Structure Math" context="SectioningMathMode" />
  38.         <DetectChar char="%" attribute="Comment" context="Comment"/>
  39.         <DetectChar char="&#xd7;" attribute="Bullet" context="#stay"/>
  40.       </context>
  41.       <context name="SectioningContrSeq" attribute="Keyword" lineEndContext="#pop">
  42.         <DetectChar char="&#xd7;" attribute="Bullet" context="#stay"/>
  43.         <RegExpr String="[a-zA-Z]+(\+?|\*{0,3})" attribute="Structure Keyword" context="#pop"/>
  44.         <RegExpr String="[^a-zA-Z]" attribute="Structure Keyword" context="#pop" />
  45.       </context>
  46.       <context name="SectioningMathMode" attribute="Structure Math" lineEndContext="#stay">
  47.         <StringDetect String="$$" attribute="Error" context="#stay" />
  48.         <DetectChar char="$" attribute="Structure Math" context="#pop" />
  49.         <Detect2Chars char="\" char1=")" attribute="Structure Math" context="#pop" />
  50.         <Detect2Chars char="\" char1="]" attribute="Error" context="#stay" />
  51.         <DetectChar char="\" attribute="Structure Keyword Mathmode" context="SectioningMathContrSeq"/>
  52.         <DetectChar char="%" attribute="Comment" context="Comment"/>
  53.         <DetectChar char="&#xd7;" attribute="Bullet" context="#stay"/>
  54.       </context>
  55.       <context name="SectioningMathContrSeq" attribute="Structure Keyword Mathmode" lineEndContext="#pop">
  56.         <DetectChar char="&#xd7;" attribute="Bullet" context="#stay"/>
  57.         <RegExpr String="[a-zA-Z]+\*?" attribute="Structure Keyword Mathmode" context="#pop"/>
  58.         <RegExpr String="[^a-zA-Z]" attribute="Structure Keyword Mathmode" context="#pop" />
  59.       </context>
  60.  
  61.  
  62.  
  63.       <!-- ConTeXt find setup commands -->
  64.       <context name="FindSetup" attribute="Structure" lineEndContext="#stay" fallthroughContext="#pop" fallthrough="true">
  65.         <DetectChar char="[" attribute="Normal Text" context="Parameter"/>
  66.         <RegExpr String="[a-zA-Z]+" attribute="Structure" context="#stay"/>
  67.       </context>
  68.  
  69.       <context name="ParameterList" attribute="Keyword" lineEndContext="#stay">
  70.         <Detect2Chars char="]" char1="[" attribute="Normal Text" context="#stay"/>
  71.       </context>
  72.  
  73.  
  74.       <!-- ConTeXt scan parameter -->
  75.       <context name="Parameter" attribute="Parameter" lineEndContext="#stay">
  76.         <DetectChar char="[" attribute="Normal Text" context="Parameter"/>
  77.         <DetectChar char="]" attribute="Normal Text" context="#pop"/>
  78.       </context>
  79.  
  80.       <!-- ConTeXt find start of environment -->
  81.       <context name="FindStart" attribute="Environment" lineEndContext="#pop" fallthroughContext="#pop#pop" fallthrough="true">
  82.         <RegExpr String="typing(?![a-zA-Z])" attribute="Environment" context="VerbatimEnv"/>
  83.         <RegExpr String="formula(?![a-zA-Z])" attribute="Environment" context="MathModeEnvConTeXt" beginRegion="mathMode"/>
  84.         <DetectChar char="[" attribute="Normal Text" context="Parameter"/>
  85.         <RegExpr String="[a-zA-Z]+" attribute="Environment" context="#stay"/>
  86.       </context>
  87.  
  88.       <!-- ConTeXt find stop of environment -->
  89.       <context name="FindStop" attribute="Environment" lineEndContext="#pop">
  90.         <RegExpr String="[^a-zA-Z]" attribute="Normal Text" context="#pop"/>
  91.       </context>
  92.  
  93.       <!-- ConTeXt verbatim environment -->
  94.       <context name="VerbatimEnv" attribute="Verbatim" lineEndContext="#stay">
  95.         <RegExpr String="\\stoptyping(?![a-zA-z])" attribute="Environment" context="#pop#pop" endRegion="block"/>
  96.       </context>
  97.  
  98.       <!-- ConTeXt ordinary command -->
  99.       <context name="Command" attribute="Keyword" lineEndContext="#pop" fallthroughContext="#pop" fallthrough="true">
  100.         <DetectChar char="%" context="Comment"/>
  101.         <DetectChar char="{" attribute="Normal Text" context="Argument"/>
  102.         <DetectChar char="[" attribute="Normal Text" context="Parameter"/>
  103.         <RegExpr String="[a-zA-Z]+" attribute="Keyword" context="#stay"/>
  104.       </context>
  105.  
  106.       <!-- ConTeXt command argument -->
  107.       <context name="Argument" attribute="Normal Text" lineEndContext="#stay">
  108.         <RegExpr String="\\setup" attribute="Structure" context="FindSetup" />
  109.         <RegExpr String="\\start" attribute="Environment" context="FindStart" beginRegion="block"/>
  110.         <RegExpr String="\\stop" attribute="Environment" context="FindStop" endRegion="block"/>
  111.         <RegExpr String="\\type" attribute="Keyword" context="FindVerbatimCom"/>
  112.         <DetectChar char="%" attribute="Comment" context="Comment"/>
  113.         <DetectChar char="\" attribute="Keyword" context="Command"/>
  114.         <DetectChar char="}" attribute="Normal Text" context="#pop"/>
  115.         <DetectChar char="{" attribute="Normal Text" context="Argument" />
  116.       </context>
  117.  
  118.       <!-- ConTeXt found verbatim command -->
  119.       <context name="FindVerbatimCom" attribute="Normal Text" lineEndContext="#stay">
  120.         <DetectChar char="{" attribute="Normal Text" context="VerbatimCom"/>
  121.         <RegExpr String="\S" attribute="Normal Text" context="#pop"/>
  122.       </context>
  123.  
  124.       <!-- ConTeXt verbatim command -->
  125.       <context name="VerbatimCom" attribute="Verbatim" lineEndContext="#stay">
  126.         <DetectChar char="}" attribute="Normal Text" context="#pop#pop"/>
  127.       </context>
  128.  
  129.       <!-- ConTeXt comment -->
  130.       <context name="Comment" attribute="Comment" lineEndContext="#pop"/>
  131.  
  132.       <!-- ConTeXt find math ConTeXt style -->
  133.       <context name="FindMathConTeXt" attribute="Normal Text" lineEndContext="#stay">
  134.         <DetectChar char="{" attribute="Normal Text" context="MathModeConTeXt"/>
  135.         <RegExpr String="\S" attribute="Normal Text" context="#pop"/>
  136.       </context>
  137.  
  138.       <!-- ConTeXt inline math TeX style -->
  139.       <context name="MathModeTeX" attribute="Math" lineEndContext="#stay">
  140.         <DetectChar char="$" attribute="Math" context="#pop" endRegion="mathMode"/>
  141.         <RegExpr String="\\[^a-zA-Z]" attribute="Keyword Mathmode" context="#stay" />
  142.         <DetectChar char="\" attribute="Keyword Mathmode" context="MathCommand"/>
  143.       </context>
  144.  
  145.       <!-- ConteXt inline math ConTeXt style -->
  146.       <context name="MathModeConTeXt" attribute="Math" lineEndContext="#stay">
  147.         <DetectChar char="}" attribute="Math" context="#pop#pop" endRegion="mathMode"/>
  148.       </context>
  149.  
  150.       <!-- ConTeXt math environment ConTeXt style -->
  151.       <context name="MathModeEnvConTeXt" attribute="Math" lineEndContext="#stay">
  152.         <RegExpr String="(\\stopformula$|\\stopformula\s)" attribute="Environment" context="#pop#pop" endRegion="mathMode"/>
  153.         <RegExpr String="\\[^a-zA-Z]" attribute="Keyword Mathmode" context="#stay" />
  154.         <DetectChar char="\" attribute="Keyword Mathmode" context="MathCommand"/>
  155.       </context>
  156.  
  157.       <!-- ConTeXt command in math mode -->
  158.       <context name="MathCommand" attribute="Keyword Mathmode" lineEndContext="#pop" fallthroughContext="#pop" fallthrough="true">
  159.         <DetectChar char="%" context="Comment"/>
  160.         <RegExpr String="[a-zA-Z]+" attribute="Keyword Mathmode" context="#stay"/>
  161.         <DetectChar char="{" attribute="Normal Text" context="MathArgument"/>
  162.         <DetectChar char="[" attribute="Normal Text" context="Parameter"/>
  163.       </context>
  164.  
  165.       <!-- ConTeXt math argument -->
  166.       <context name="MathArgument" attribute="Math" lineEndContext="#stay">
  167.         <DetectChar char="%" attribute="Comment" context="Comment"/>
  168.         <DetectChar char="\" attribute="Keyword" context="MathCommand"/>
  169.         <DetectChar char="}" attribute="Normal Text" context="#pop"/>
  170.         <DetectChar char="{" attribute="Normal Text" context="MathArgument" />
  171.       </context>
  172.  
  173.  
  174.     </contexts>
  175.  
  176.     <itemDatas>
  177.       <itemData name="Normal Text" defStyleNum="dsNormal"/>
  178.       <itemData name="Keyword" defStyleNum="dsNormal" color="#800000" selColor="#60FFFF" bold="0" italic="0" spellChecking="false"/>
  179.       <itemData name="Comment" defStyleNum="dsComment" spellChecking="false"/>
  180.       <itemData name="Parameter" defStyleNum="dsDataType" color="#F0A000" selColor="#8090FF" spellChecking="false"/>
  181.       <itemData name="Error" defStyleNum="dsAlert" spellChecking="false"/>
  182.       <itemData name="Math" defStyleNum="dsNormal" color="#00A000" selColor="#FF40FF"  bold="0" italic="0" spellChecking="false"/>
  183.       <itemData name="Structure" defStyleNum="dsNormal" color="#F00000" selColor="#80FFD0" bold="0" italic="0" spellChecking="false"/>
  184.       <itemData name="Keyword Mathmode" defStyleNum="dsNormal" color="#606000" selColor="#FFD0FF" bold="0" italic="0" spellChecking="false"/>
  185.       <itemData name="Environment" defStyleNum="dsNormal" color="#0000D0" selColor="#FFFF90" bold="0" italic="0" spellChecking="false"/>
  186.       <itemData name="Verbatim" defStyleNum="dsNormal" color="#a08000" selColor="#80D0FF" bold="0" italic="0"/>
  187.       <itemData name="Region Marker" defStyleNum="dsRegionMarker" />
  188.       <itemData name="Bullet" defStyleNum="dsNormal" color="#FF00C4" bold="1" underline="1" spellChecking="false"/>
  189.       <itemData name="Alert" defStyleNum="dsAlert"  spellChecking="false"/>
  190.       <itemData name="Structure Text" defStyleNum="dsNormal" color="#000000" selColor="#FFFFFF" bold="1" italic="0"/>
  191.       <itemData name="Structure Keyword" defStyleNum="dsNormal" color="#800000" selColor="#60FFFF" bold="1" italic="0" spellChecking="false"/>
  192.       <itemData name="Structure Math" defStyleNum="dsNormal" color="#00A000" selColor="#FF40FF"  bold="1" italic="0"/>
  193.       <itemData name="Structure Keyword Mathmode" defStyleNum="dsNormal" color="#606000" selColor="#FFD0FF" bold="1" italic="0" spellChecking="false"/>
  194.     </itemDatas>
  195.   </highlighting>
  196.  
  197.   <general>
  198.     <keywords weakDeliminator="\" wordWrapDeliminator=",{}[]"/>
  199.     <comments>
  200.       <comment name="singleLine" start="%" />
  201.     </comments>
  202.   </general>
  203. </language>
  204. <!--
  205.    // kate: space-indent on; indent-width 2; replace-tabs on;
  206. -->
RAW Paste Data