[gtksourceview] css.lang: Highlight escape sequences in strings



commit bc4a1af7291154919ad9734c743e32a7f1bd1407
Author: Jeffery To <jeffery to gmail com>
Date:   Fri May 18 00:43:50 2018 +0800

    css.lang: Highlight escape sequences in strings
    
    This highlights both single character escapes (\") and unicode character
    escapes (\0000e9).

 data/language-specs/css.lang       | 33 +++++++++++++++++++++++++++++++--
 tests/syntax-highlighting/file.css |  3 ++-
 2 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/data/language-specs/css.lang b/data/language-specs/css.lang
index 1e933453..364239e9 100644
--- a/data/language-specs/css.lang
+++ b/data/language-specs/css.lang
@@ -45,6 +45,8 @@
 
     <!-- data types -->
     <style id="name"                        name="Name"/>
+    <style id="escape"                      name="Escape Sequence"             map-to="def:special-char"/>
+    <style id="string"                      name="String"                      map-to="def:string"/>
     <style id="color"                       name="Color"                       map-to="def:base-n-integer"/>
     <style id="number"                      name="Number"                      map-to="def:number"/>
     <style id="integer"                     name="Integer"                     map-to="def:decimal"/>
@@ -212,10 +214,37 @@
       <match>\%{vendor-specific-identifier-regex}</match>
     </context>
 
+    <context id="escape" style-ref="escape">
+      <match>\%{escape-regex}</match>
+    </context>
+
+    <context id="string-content">
+      <include>
+        <context ref="escape"/>
+        <context ref="def:line-continue"/>
+      </include>
+    </context>
+
+    <context id="double-quoted-string" style-ref="string" end-at-line-end="true" class="string" 
class-disabled="no-spell-check">
+      <start>"</start>
+      <end>"</end>
+      <include>
+        <context ref="string-content"/>
+      </include>
+    </context>
+
+    <context id="single-quoted-string" style-ref="string" end-at-line-end="true" class="string" 
class-disabled="no-spell-check">
+      <start>'</start>
+      <end>'</end>
+      <include>
+        <context ref="string-content"/>
+      </include>
+    </context>
+
     <context id="string">
       <include>
-        <context ref="def:string"/>
-        <context ref="def:single-quoted-string"/>
+        <context ref="double-quoted-string"/>
+        <context ref="single-quoted-string"/>
       </include>
     </context>
 
diff --git a/tests/syntax-highlighting/file.css b/tests/syntax-highlighting/file.css
index 2cbdc6c5..a77c3ed6 100644
--- a/tests/syntax-highlighting/file.css
+++ b/tests/syntax-highlighting/file.css
@@ -89,7 +89,8 @@ div#\E9 dition .\0000E9dition .motion_\e9motion, /* Unicode character escape */
 .\e33  div, /* need extra space to denote separate tokens */
 #-notvendor-specific,
 .\31 23 {
-    background: \u\72\l("unicode.png");
+    background: \u\72\l("\E9 dition \"\0000E9dition\" \e9motion\
+                         .png");
 }
 
 @-webkit-keyframes myanim {


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