[gtksourceview: 2/13] css.lang: Allow comments inside ratio values



commit c3f53aa5263cdb4c43ec8a867da947a631adf5a5
Author: Jeffery To <jeffery to gmail com>
Date:   Sat Nov 30 21:08:25 2019 +0800

    css.lang: Allow comments inside ratio values
    
    Comments are allowed on either side of the slash symbol.

 data/language-specs/css.lang        | 23 +++++++++++++++++++----
 tests/syntax-highlighting/file.css  |  1 +
 tests/syntax-highlighting/file.less |  1 +
 tests/syntax-highlighting/file.scss |  1 +
 4 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/data/language-specs/css.lang b/data/language-specs/css.lang
index 31818280..209247e4 100644
--- a/data/language-specs/css.lang
+++ b/data/language-specs/css.lang
@@ -201,6 +201,10 @@
 
     <define-regex id="test-value-end">(?=\))</define-regex>
 
+    <define-regex id="optional-whitespace-or-comments" extended="true">
+      (?&gt; (?: \s+ | /\*.*?\*/ )* )
+    </define-regex>
+
     <context id="embedded-lang-hook"/>
 
     <context id="multiline-comment" style-ref="comment" class-disabled="no-spell-check" class="comment">
@@ -521,11 +525,22 @@
     </context>
 
     <context id="ratio" style-ref="expression">
-      <match extended="true">
+      <start extended="true">
         (?&lt;! \%{non-number-char} )
-        \%{positive-integer} \s* / \s* \%{positive-integer}
-        (?! \%{non-number-char} )
-      </match>
+        \%{positive-integer}
+        (?=
+          \%{optional-whitespace-or-comments}
+          /
+          \%{optional-whitespace-or-comments}
+          \%{positive-integer}
+          (?! \%{non-number-char} )
+        )
+      </start>
+      <end>\%{positive-integer}</end>
+      <include>
+        <context ref="embedded-lang-hook"/>
+        <context ref="comment"/>
+      </include>
     </context>
 
     <context id="number" style-ref="number">
diff --git a/tests/syntax-highlighting/file.css b/tests/syntax-highlighting/file.css
index 72743906..11fc9cb8 100644
--- a/tests/syntax-highlighting/file.css
+++ b/tests/syntax-highlighting/file.css
@@ -149,6 +149,7 @@ svg|[fill] { /* attribute */
 
 /* ratio */
 @media (min-aspect-ratio: 16/9) {}
+@media (min-aspect-ratio: 16 /* comment */ / /* comment */ 9) {}
 
 /* resolution */
 @media (min-resolution: +2.54dpcm) {}
diff --git a/tests/syntax-highlighting/file.less b/tests/syntax-highlighting/file.less
index f19b6037..f268eac3 100644
--- a/tests/syntax-highlighting/file.less
+++ b/tests/syntax-highlighting/file.less
@@ -571,6 +571,7 @@ svg|[fill] { /* attribute */
 
 /* ratio */
 @media (min-aspect-ratio: 16/9) {}
+@media (min-aspect-ratio: 16 /* comment */ / /* comment */ 9) {}
 
 /* resolution */
 @media (min-resolution: +2.54dpcm) {}
diff --git a/tests/syntax-highlighting/file.scss b/tests/syntax-highlighting/file.scss
index 888044c6..f31f861e 100644
--- a/tests/syntax-highlighting/file.scss
+++ b/tests/syntax-highlighting/file.scss
@@ -596,6 +596,7 @@ svg|[fill] { /* attribute */
 
 /* ratio */
 @media (min-aspect-ratio: 16/9) {}
+@media (min-aspect-ratio: 16 /* comment */ / /* comment */ 9) {}
 
 /* resolution */
 @media (min-resolution: +2.54dpcm) {}


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