[gtksourceview] rst.lang: Handle interpreted markup



commit 1596a33684c4112c7901232e03720b306fa6a928
Author: Pierre Ossman <ossman cendio se>
Date:   Fri Oct 15 15:36:06 2021 +0200

    rst.lang: Handle interpreted markup
    
    Unfortunately the difference between these and references is if they end
    with a trailing underscore or not, and the shortest match is supposed to
    win. However I can't figure out how to implement that in this system.

 data/language-specs/rst.lang | 52 +++++++++++++++++++++++++-------------------
 1 file changed, 30 insertions(+), 22 deletions(-)
---
diff --git a/data/language-specs/rst.lang b/data/language-specs/rst.lang
index af7005b5..dac1b8d2 100644
--- a/data/language-specs/rst.lang
+++ b/data/language-specs/rst.lang
@@ -33,6 +33,7 @@
     <style id="bullet" name="Bullet" map-to="def:list-marker"/>
     <style id="directive" name="Directive" map-to="def:constant"/>
     <style id="comment" name="Comment" map-to="def:comment"/>
+    <style id="interpreted" name="Interpreted" map-to="def:identifier"/>
     <style id="link" name="Link" map-to="def:link-text"/>
     <style id="substitution" name="Substitution" map-to="def:type"/>
     <style id="code" name="Code" map-to="def:inline-code"/>
@@ -119,36 +120,40 @@
       <end>(?&lt;!\s)\*(\%{legal-end})</end>
     </context>
 
-    <context id="links">
+    <context id="literals">
       <include>
-        <context id="target" style-ref="link">
-          <start>(\%{legal-start})_`(?!(\s|$))</start>
-          <end>(?&lt;!\s)`(\%{legal-end})</end>
-        </context>
-        <context id="link" style-ref="link">
-          <start>(\%{legal-start})`(?!(\s|$|`))</start>
-          <end>(?&lt;!\s)`__?(\%{legal-end})</end>
-        </context>
-        <context id="simple-link" style-ref="link">
-          <match>(\%{legal-start})[^\W_]\w*_(\%{legal-end})</match>
+        <context id="inline-literals" class="no-spell-check" style-ref="code">
+          <start>(\%{legal-start})``(?!(\s|$))</start>
+          <end>(?&lt;!\s)``(\%{legal-end})</end>
         </context>
       </include>
     </context>
 
+    <context id="target" style-ref="link">
+      <start>(\%{legal-start})_`(?!(\s|$))</start>
+      <end>(?&lt;!\s)`(\%{legal-end})</end>
+    </context>
+
+    <context id="interpreted" style-ref="interpreted">
+      <start>(\%{legal-start}):[\w:]+:`(?!(\s|$))</start>
+      <end>(?&lt;!\s)`(\%{legal-end})</end>
+    </context>
+
+    <!-- FIXME: Can we separate these two somehow? -->
+    <context id="interpreted-or-link" style-ref="link">
+      <start>(\%{legal-start})`(?!(\s|$))</start>
+      <end>(?&lt;!\s)`(:[\w:]+:)?_?_?(\%{legal-end})</end>
+    </context>
+
+    <context id="simple-link" style-ref="link">
+      <match>(\%{legal-start})[^\W_]\w*_(\%{legal-end})</match>
+    </context>
+
     <context id="substitution" style-ref="substitution">
       <start>(\%{legal-start})\|(?!(\s|$))</start>
       <end>(?&lt;!\s)\|_?_?(\%{legal-end})</end>
     </context>
 
-    <context id="literals">
-      <include>
-        <context id="inline-literals" class="no-spell-check" style-ref="code">
-          <start>(\%{legal-start})``(?!(\s|$))</start>
-          <end>(?&lt;!\s)``(\%{legal-end})</end>
-        </context>
-      </include>
-    </context>
-
     <context id="url" style-ref="url">
       <match>((http)|(file))://\S*</match>
     </context>
@@ -166,9 +171,12 @@
         <context ref="field"/>
         <context ref="strong-emphasis"/>
         <context ref="emphasis"/>
-        <context ref="links"/>
-        <context ref="substitution"/>
         <context ref="literals"/>
+        <context ref="target"/>
+        <context ref="interpreted"/>
+        <context ref="interpreted-or-link"/>
+        <context ref="simple-link"/>
+        <context ref="substitution"/>
         <context ref="url"/>
       </include>
     </context>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]