| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<!DOCTYPE language |
| 3 |
[ |
| 4 |
<!-- Replicated from "markdown.xml": --> |
| 5 |
<!ENTITY rulerregex "\s*(?:(?:\*\s*){3,}|(?:_\s*){3,}|(?:\-\s*){3,})\s*$"> |
| 6 |
<!ENTITY indentedcodeblock "(?:\s{4}|\t).*$"> |
| 7 |
<!ENTITY listbullet "[\*\+\-]"> |
| 8 |
<!ENTITY emptyline "^\s*$"> |
| 9 |
<!ENTITY checkbox "\[[ x]\](?=\s)"> |
| 10 |
]> |
| 11 |
<!-- |
| 12 |
Kate highlighting module for R Markdown |
| 13 |
(c) 2014 Dirk Sarpe ([email protected]) |
| 14 |
|
| 15 |
depends on: |
| 16 |
Kate highlighting module for Markdown |
| 17 |
Kate highlighting module for R script |
| 18 |
Kate highlighting module for LaTeX |
| 19 |
Kate highlighting module for YAML |
| 20 |
--> |
| 21 |
|
| 22 |
<language name="R Markdown" |
| 23 |
section="Markup" |
| 24 |
extensions="*.rmd;*.Rmd;*.RMD" |
| 25 |
mimetype="text/x-r-markdown" |
| 26 |
version="9" |
| 27 |
kateversion="5.79" |
| 28 |
casesensitive="true" |
| 29 |
author="Dirk Sarpe ([email protected])" |
| 30 |
license="GPL"> |
| 31 |
|
| 32 |
<highlighting> |
| 33 |
<contexts> |
| 34 |
|
| 35 |
<context name="Start Document" attribute="Markdown" lineEndContext="Normal Text" lineEmptyContext="Normal Text" fallthroughContext="Normal Text"> |
| 36 |
<RegExpr String="^---$" column="0" attribute="Markdown" context="YAMLhead" beginRegion="YAMLhead block"/> |
| 37 |
</context> |
| 38 |
|
| 39 |
<context name="Normal Text" attribute="Markdown" lineEndContext="#stay" lineEmptyContext="find-code-block"> |
| 40 |
<IncludeRules context="Common"/> |
| 41 |
<IncludeRules context="Overwrite Markdown Normal Text"/> |
| 42 |
<IncludeRules context="Normal Text##Markdown" includeAttrib="true"/> |
| 43 |
</context> |
| 44 |
<context name="find-code-block" attribute="Markdown" lineEndContext="#stay" lineEmptyContext="#stay" fallthroughContext="#pop"> |
| 45 |
<IncludeRules context="find-code-block##Markdown" includeAttrib="true"/> |
| 46 |
</context> |
| 47 |
|
| 48 |
<context name="Common" attribute="Markdown" lineEndContext="#stay"> |
| 49 |
<RegExpr String="```+\{r.*\}" firstNonSpace="true" attribute="Structure" |
| 50 |
context="R block" beginRegion="R block"/> |
| 51 |
<RegExpr String="`r\b" attribute="Structure" |
| 52 |
context="R inline"/> |
| 53 |
<Detect2Chars char="$" char1="$" attribute="MathMode" |
| 54 |
context="LaTeX equation block" beginRegion="LaTeX equation block"/> |
| 55 |
<DetectChar char="$" attribute="MathMode" |
| 56 |
context="LaTeX inline equation"/> |
| 57 |
<Detect2Chars char="\" char1="$" attribute="Backslash Escape" context="#stay"/> |
| 58 |
</context> |
| 59 |
|
| 60 |
<context name="R block" attribute="Markdown" lineEndContext="#stay"> |
| 61 |
<RegExpr String="```+(?=\s*$)" firstNonSpace="true" attribute="Structure" context="#pop" |
| 62 |
endRegion="R block"/> |
| 63 |
<IncludeRules context="##R Script" includeAttrib="true"/> |
| 64 |
</context> |
| 65 |
|
| 66 |
<context name="R inline" attribute="Markdown" lineEndContext="#stay"> |
| 67 |
<DetectChar char="`" attribute="Structure" context="#pop"/> |
| 68 |
<IncludeRules context="##R Script" includeAttrib="true"/> |
| 69 |
</context> |
| 70 |
|
| 71 |
<context name="LaTeX equation block" attribute="MathMode" |
| 72 |
lineEndContext="#stay"> |
| 73 |
<Detect2Chars char="$" char1="$" attribute="MathMode" |
| 74 |
context="#pop" endRegion="LaTeX equation block"/> |
| 75 |
<IncludeRules context="MathModeDisplay##LaTeX" includeAttrib="true"/> |
| 76 |
</context> |
| 77 |
|
| 78 |
<context name="LaTeX inline equation" attribute="MathMode" |
| 79 |
lineEndContext="#stay"> |
| 80 |
<DetectChar char="$" attribute="MathMode" context="#pop"/> |
| 81 |
<IncludeRules context="MathMode##LaTeX" includeAttrib="true"/> |
| 82 |
</context> |
| 83 |
|
| 84 |
<context name="YAMLhead" attribute="Document Headers" |
| 85 |
lineEndContext="#stay"> |
| 86 |
<RegExpr String="^---$" column="0" attribute="Markdown" context="#pop" |
| 87 |
endRegion="YAMLhead block"/> |
| 88 |
<IncludeRules context="##YAML" includeAttrib="true"/> |
| 89 |
</context> |
| 90 |
|
| 91 |
<!-- Markdown --> |
| 92 |
<!-- These contexts are replicated from "markdown.xml" to add the features of R Markdown. --> |
| 93 |
|
| 94 |
<context name="Overwrite Markdown Normal Text" attribute="Markdown" lineEndContext="#stay"> |
| 95 |
<!-- Blockquotes --> |
| 96 |
<DetectChar attribute="Blockquote" context="blockquote" char=">" firstNonSpace="true"/> |
| 97 |
<!-- Lists: avoid highlighting code blocks incorrectly, capturing indentation --> |
| 98 |
<RegExpr attribute="List" context="list" String="^(\s*)&listbullet;(\s+)" column="0"/> |
| 99 |
<RegExpr attribute="Number List" context="numlist" String="^(\s*)\d\.(\s+)" column="0"/> |
| 100 |
<RegExpr attribute="Number List" context="numlist2" String="^(\s*)\d\d+\.(\s+)" column="0"/> |
| 101 |
</context> |
| 102 |
|
| 103 |
<context name="list" attribute="Markdown" lineEndContext="#stay" fallthroughContext="content-list"> |
| 104 |
<!-- Find indented code blocks, blockquotes and horizontal rules --> |
| 105 |
<RegExpr attribute="List: Code" String="^%1%2\s&indentedcodeblock;" column="0" dynamic="true"/> |
| 106 |
<RegExpr attribute="Blockquote" context="blockquote-list" String="^%1%2\s+>" column="0" dynamic="true"/> |
| 107 |
<RegExpr attribute="List: Horizontal Rule" String="^%1%2\s+&rulerregex;" column="0" dynamic="true"/> |
| 108 |
<RegExpr String="&emptyline;" column="0"/> |
| 109 |
<!-- Text with the same indentation captured corresponds to the item list --> |
| 110 |
<RegExpr context="content-list" String="^%1%2\s" column="0" lookAhead="true" dynamic="true"/> |
| 111 |
<!-- Finish when the text has a lower indentation than the list --> |
| 112 |
<RegExpr context="#pop" String="^\s*\S" column="0" lookAhead="true"/> |
| 113 |
<!-- Highlight checkbox at the start of the item (task list) --> |
| 114 |
<RegExpr attribute="List: Checkbox" context="content-list" String="\s*&checkbox;"/> |
| 115 |
</context> |
| 116 |
<!-- 1. numlist (one digit) --> |
| 117 |
<context name="numlist" attribute="Markdown" lineEndContext="#stay" fallthroughContext="content-list"> |
| 118 |
<RegExpr attribute="List: Code" String="^%1%2\s{2}&indentedcodeblock;" column="0" dynamic="true"/> |
| 119 |
<RegExpr attribute="Blockquote" context="blockquote-list" String="^%1%2\s{2,}>" column="0" dynamic="true"/> |
| 120 |
<RegExpr attribute="List: Horizontal Rule" String="^%1%2\s{2,}&rulerregex;" column="0" dynamic="true"/> |
| 121 |
<RegExpr String="&emptyline;" column="0"/> |
| 122 |
<RegExpr context="content-list" String="^%1%2\s{2}" column="0" lookAhead="true" dynamic="true"/> |
| 123 |
<RegExpr context="#pop" String="^\s*\S" column="0" lookAhead="true"/> |
| 124 |
</context> |
| 125 |
<!-- 10. numlist (two or more digits) --> |
| 126 |
<context name="numlist2" attribute="Markdown" lineEndContext="#stay" fallthroughContext="content-list"> |
| 127 |
<RegExpr attribute="List: Code" String="^%1%2\s{3}&indentedcodeblock;" column="0" dynamic="true"/> |
| 128 |
<RegExpr attribute="Blockquote" context="blockquote-list" String="^%1%2\s{3,}>" column="0" dynamic="true"/> |
| 129 |
<RegExpr attribute="List: Horizontal Rule" String="^%1%2\s{3,}&rulerregex;" column="0" dynamic="true"/> |
| 130 |
<RegExpr String="&emptyline;" column="0"/> |
| 131 |
<RegExpr context="content-list" String="^%1%2\s{3}" column="0" lookAhead="true" dynamic="true"/> |
| 132 |
<RegExpr context="#pop" String="^\s*\S" column="0" lookAhead="true"/> |
| 133 |
</context> |
| 134 |
|
| 135 |
<context name="content-list" attribute="Markdown" lineEndContext="#stay" lineEmptyContext="#pop"> |
| 136 |
<IncludeRules context="Common"/> |
| 137 |
<IncludeRules context="content-list##Markdown" includeAttrib="true"/> |
| 138 |
</context> |
| 139 |
|
| 140 |
<context name="blockquote" attribute="Markdown" lineEndContext="#stay" lineEmptyContext="#pop"> |
| 141 |
<IncludeRules context="Common"/> |
| 142 |
<IncludeRules context="blockquote##Markdown" includeAttrib="true"/> |
| 143 |
</context> |
| 144 |
<context name="blockquote-list" attribute="Markdown" lineEndContext="#stay" lineEmptyContext="#pop"> |
| 145 |
<IncludeRules context="Common"/> |
| 146 |
<IncludeRules context="blockquote-list##Markdown" includeAttrib="true"/> |
| 147 |
</context> |
| 148 |
|
| 149 |
</contexts> |
| 150 |
|
| 151 |
<itemDatas> |
| 152 |
<itemData name="Markdown" defStyleNum="dsNormal"/> |
| 153 |
<itemData name="Structure" defStyleNum="dsRegionMarker"/> |
| 154 |
<itemData name="MathMode" defStyleNum="dsRegionMarker" color="#00A000"/> |
| 155 |
<itemData name="Document Headers" defStyleNum="dsOthers"/> |
| 156 |
|
| 157 |
<itemData name="Blockquote" defStyleNum="dsAttribute" spellChecking="false"/> |
| 158 |
<itemData name="List" defStyleNum="dsSpecialString" bold="1" spellChecking="false"/> |
| 159 |
<itemData name="Number List" defStyleNum="dsSpecialString" spellChecking="false"/> |
| 160 |
<itemData name="List: Horizontal Rule" defStyleNum="dsNormal" bold="true" spellChecking="false"/> |
| 161 |
<itemData name="List: Code" defStyleNum="dsInformation"/> |
| 162 |
<itemData name="List: Checkbox" defStyleNum="dsVariable" spellChecking="false"/> |
| 163 |
<itemData name="Backslash Escape" defStyleNum="dsSpecialChar" spellChecking="false"/> |
| 164 |
</itemDatas> |
| 165 |
|
| 166 |
</highlighting> |
| 167 |
|
| 168 |
<general> |
| 169 |
<keywords additionalDeliminator="`"/> |
| 170 |
<comments> |
| 171 |
<comment name="multiLine" start="<!--" end="-->"/> |
| 172 |
</comments> |
| 173 |
</general> |
| 174 |
|
| 175 |
</language> |