[gtksourceview] css.lang: Add highlighting for @font-feature-values block



commit 045bd458ad601b16b3c03e0346704aae745eec3e
Author: Jeffery To <jeffery to gmail com>
Date:   Sat May 12 18:34:49 2018 +0800

    css.lang: Add highlighting for @font-feature-values block
    
    This adds contexts to highlight @font-feature-values blocks. This also
    adds a positive-integer context, used inside feature value blocks.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=796130

 data/language-specs/css.lang       |   61 ++++++++++++++++++++++++++++++++---
 tests/syntax-highlighting/file.css |   10 ++++++
 2 files changed, 65 insertions(+), 6 deletions(-)
---
diff --git a/data/language-specs/css.lang b/data/language-specs/css.lang
index b04cd34..37f5642 100644
--- a/data/language-specs/css.lang
+++ b/data/language-specs/css.lang
@@ -385,6 +385,10 @@
       <match>(?&lt;![\w\.])\%{number-regex}(?![\w\.])</match>
     </context>
 
+    <context id="positive-integer" style-ref="decimal">
+      <match>(?&lt;![\w\.])\%{positive-integer-regex}(?![\w\.])</match>
+    </context>
+
     <context id="unicode-range" style-ref="others-2">
       <match>u\+[a-f0-9?]{1,6}(-[a-f0-9]{1,6})?</match>
     </context>
@@ -1460,17 +1464,11 @@
 
     <context id="css3-at-rules" style-ref="at-rules">
       <prefix>@</prefix>
-      <keyword>annotation</keyword>
-      <keyword>character-variant</keyword>
       <keyword>font-face</keyword>
       <keyword>font-feature-values</keyword>
       <keyword>keyframes</keyword>
       <keyword>namespace</keyword>
-      <keyword>ornaments</keyword>
-      <keyword>styleset</keyword>
-      <keyword>stylistic</keyword>
       <keyword>supports</keyword>
-      <keyword>swash</keyword>
     </context>
 
     <context id="at-rules" style-ref="at-rules">
@@ -1521,6 +1519,56 @@
       </include>
     </context>
 
+    <context id="font-feature-types" style-ref="function">
+      <prefix>@</prefix>
+      <keyword>annotation</keyword>
+      <keyword>character-variant</keyword>
+      <keyword>ornaments</keyword>
+      <keyword>styleset</keyword>
+      <keyword>stylistic</keyword>
+      <keyword>swash</keyword>
+    </context>
+
+    <context id="at-font-feature-values-feature-value-name" style-ref="name">
+      <match>\%{identifier-regex}(?=\s*:)</match>
+    </context>
+
+    <context id="at-font-feature-values-feature-value-block">
+      <start>\{</start>
+      <end>\}</end>
+      <include>
+        <context sub-pattern="0" where="start" style-ref="others-3"/>
+        <context sub-pattern="0" where="end" style-ref="others-3"/>
+        <context ref="comment"/>
+        <context ref="at-font-feature-values-feature-value-name"/>
+        <context ref="positive-integer"/>
+        <context ref="colon"/>
+        <context ref="semicolon"/>
+      </include>
+    </context>
+
+    <context id="at-font-feature-values-block" end-parent="true">
+      <start>\{</start>
+      <end>\}</end>
+      <include>
+        <context sub-pattern="0" where="start" style-ref="others-3"/>
+        <context sub-pattern="0" where="end" style-ref="others-3"/>
+        <context ref="comment"/>
+        <context ref="font-feature-types"/>
+        <context ref="at-font-feature-values-feature-value-block"/>
+      </include>
+    </context>
+
+    <context id="at-font-feature-values-call">
+      <start>(?&lt;=@font-feature-values)</start>
+      <include>
+        <context ref="comment"/>
+        <context ref="string"/>
+        <context ref="name"/>
+        <context ref="at-font-feature-values-block"/>
+      </include>
+    </context>
+
     <context id="at-import-call">
       <start>(?&lt;=@import)</start>
       <include>
@@ -1620,6 +1668,7 @@
         <context ref="at-rules"/>
         <context ref="at-charset-call"/>
         <context ref="at-charset-call-error"/>
+        <context ref="at-font-feature-values-call"/>
         <context ref="at-import-call"/>
         <context ref="at-keyframes-call"/>
         <context ref="at-media-call"/>
diff --git a/tests/syntax-highlighting/file.css b/tests/syntax-highlighting/file.css
index 6bf633c..96a52a9 100644
--- a/tests/syntax-highlighting/file.css
+++ b/tests/syntax-highlighting/file.css
@@ -15,6 +15,12 @@
     unicode-range: U+0025-00FF, U+4??;
 }
 
+@font-feature-values Font One {
+    @styleset {
+        nice-style: 12;
+    }
+}
+
 #testID[lang|="zh"] {
     font: 12px italic "Overpass", sans-serif;
 }
@@ -31,6 +37,10 @@ p + div {
     width: 100%;
 }
 
+.nice-look {
+    font-variant-alternates: styleset(nice-style);
+}
+
 #headline:after {
     transform: scaleX(-1.75) rotate(+33.333e+3deg);
     transition: transform 2s ease-in-out, color 400ms;


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