[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kate] part/syntax/data: fix HL of indented reST code blocks
From: Matthew Woehlke <matthew.woehlke () kitware ! com>
Date: 2014-03-03 21:46:28
Message-ID: E1WKagu-0005vO-DP () scm ! kde ! org
[Download RAW message or body]
Git commit 87ef7904c1a9c688af7b9f7d6a8e3556830c3b5b by Matthew Woehlke.
Committed on 11/02/2014 at 18:42.
Pushed by mwoehlke into branch 'master'.
fix HL of indented reST code blocks
Add an additional context and dynamic rules in order to correctly detect
the end of a code block when the surrounding text is also indented. This
is especially important when parsing reST in Python docstrings, e.g.:
"""
Example::
This is the example.
Before, this would still be in the code block context...
"""
...and this would still be reST (code, even) as a result.
(Note that reST HL support in python.xml is a local change on my machine
at the moment.)
The technique used here isn't my favorite, but there doesn't seem to be
a better way at present.
M +21 -9 part/syntax/data/rest.xml
http://commits.kde.org/kate/87ef7904c1a9c688af7b9f7d6a8e3556830c3b5b
diff --git a/part/syntax/data/rest.xml b/part/syntax/data/rest.xml
index 09b3c05..b856e90 100644
--- a/part/syntax/data/rest.xml
+++ b/part/syntax/data/rest.xml
@@ -61,26 +61,38 @@
<RegExpr attribute="Keyword" String="\w+" context="#stay" />
<DetectChar attribute="HyperlinkRefOrInterpretedText" char="`" \
context="#pop!HyperlinkRefOrInterpretedText" /> </context>
+
<context name="CMakeCodeBlock" attribute="CMakeCode" lineEndContext="#stay">
- <RegExpr attribute="CMakeCode" String="^\s" context="CMakeCode" />
+ <RegExpr attribute="CMakeCode" String="^(\s+)(?=\S)" \
context="CMakeCodeRegion" /> </context>
<context name="CppCodeBlock" attribute="CppCode" lineEndContext="#stay">
- <RegExpr attribute="CppCode" String="^\s" context="CppCode" />
+ <RegExpr attribute="CppCode" String="^(\s+)(?=\S)" context="CppCodeRegion" \
/> </context>
<context name="CodeBlock" attribute="Code" lineEndContext="#stay">
- <RegExpr attribute="Code" String="^\s" context="Code" />
+ <RegExpr attribute="Code" String="^(\s+)(?=\S)" context="Code" />
</context>
- <context name="CMakeCode" attribute="CMakeCode" lineEndContext="#stay">
- <RegExpr attribute="Normal" String="^\S" lookAhead="true" context="#pop#pop" \
/> + <context name="CMakeCodeRegion" attribute="CMakeCode" \
lineEndContext="#stay" dynamic="true"> + <RegExpr attribute="CMakeCode" \
String="^%1" lookAhead="true" context="CMakeCode" dynamic="true"/> + <RegExpr \
attribute="Normal" String="^(.|$)" lookAhead="true" context="#pop#pop"/> + \
<IncludeRules context="CMakeCode"/> + </context>
+ <context name="CMakeCode" attribute="CMakeCode" lineEndContext="#pop">
<IncludeRules context="##CMake" includeAttrib="true"/>
</context>
- <context name="CppCode" attribute="CppCode" lineEndContext="#stay">
- <RegExpr attribute="Normal" String="^\S" lookAhead="true" context="#pop#pop" \
/> +
+ <context name="CppCodeRegion" attribute="CppCode" lineEndContext="#stay" \
dynamic="true"> + <RegExpr attribute="CppCode" String="^%1" lookAhead="true" \
context="CppCode" dynamic="true"/> + <RegExpr attribute="Normal" \
String="^(.|$)" lookAhead="true" context="#pop#pop"/> + <IncludeRules \
context="CppCode"/> + </context>
+ <context name="CppCode" attribute="CppCode" lineEndContext="#pop">
<IncludeRules context="##C++" includeAttrib="true"/>
</context>
- <context name="Code" attribute="Code" lineEndContext="#stay">
- <RegExpr attribute="Normal" String="^\S" lookAhead="true" context="#pop#pop" \
/> +
+ <context name="Code" attribute="Code" lineEndContext="#stay" dynamic="true">
+ <RegExpr attribute="Code" String="^%1" context="#stay" dynamic="true"/>
+ <RegExpr attribute="Normal" String="^(.|$)" lookAhead="true" \
context="#pop#pop"/> </context>
</contexts>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic