[gtksourceview: 7/13] css.lang: Handle escapes in unquoted strings/identifiers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview: 7/13] css.lang: Handle escapes in unquoted strings/identifiers
- Date: Wed, 11 Dec 2019 15:46:28 +0000 (UTC)
commit d2359ef703ca4db36da030edd0fcd39cb996d0bd
Author: Jeffery To <jeffery to gmail com>
Date: Tue Dec 3 05:08:54 2019 +0800
css.lang: Handle escapes in unquoted strings/identifiers
* Add name-value to any-value and attribute-selector-content (attribute
values can be identifiers or strings).
This allows escapes in unquoted strings (identifiers) to be consumed
as part of the name context.
* Add escape to url.
Since unquoted strings inside url() are URLs and not identifiers,
reference the escape context directly.
data/language-specs/css.lang | 3 +++
data/language-specs/less.lang | 2 ++
data/language-specs/scss.lang | 2 ++
tests/syntax-highlighting/file.css | 1 +
tests/syntax-highlighting/file.less | 1 +
tests/syntax-highlighting/file.scss | 1 +
6 files changed, 10 insertions(+)
---
diff --git a/data/language-specs/css.lang b/data/language-specs/css.lang
index df4b4869..ca33daa1 100644
--- a/data/language-specs/css.lang
+++ b/data/language-specs/css.lang
@@ -607,6 +607,7 @@
<context sub-pattern="0" where="end" style-ref="function"/>
<context ref="embedded-lang-hook"/>
<context ref="comment"/>
+ <context ref="escape" ignore-style="true"/>
<context ref="string-value"/>
</include>
</context>
@@ -1569,6 +1570,7 @@
<context ref="function-call"/>
<context ref="property-value-keyword"/>
<context ref="data-value"/>
+ <context ref="name-value"/>
<context ref="slash"/>
<context ref="comma"/> <!-- for lists -->
</include>
@@ -2310,6 +2312,7 @@
<context ref="attribute-selector-attribute-name"/>
<context ref="attribute-selector-operator"/>
<context ref="string-value"/>
+ <context ref="name-value"/>
</include>
</context>
diff --git a/data/language-specs/less.lang b/data/language-specs/less.lang
index 53f83e74..f465c058 100644
--- a/data/language-specs/less.lang
+++ b/data/language-specs/less.lang
@@ -292,6 +292,7 @@
<context ref="css:embedded-lang-hook"/>
<!-- only accept multi-line comments because // is part of urls -->
<context ref="css:comment" original="true"/>
+ <context ref="css:escape" ignore-style="true"/>
<context ref="css:string-value"/>
</include>
</context>
@@ -369,6 +370,7 @@
<context ref="css:number-value"/>
<context ref="css:unicode-range"/>
<context ref="arithmetic-operator"/>
+ <context ref="css:name-value" original="true"/>
<context ref="css:slash"/>
<context ref="css:comma"/>
</include>
diff --git a/data/language-specs/scss.lang b/data/language-specs/scss.lang
index 00a0f874..ba24fdc7 100644
--- a/data/language-specs/scss.lang
+++ b/data/language-specs/scss.lang
@@ -254,6 +254,7 @@
<context ref="css:embedded-lang-hook"/>
<!-- only accept multi-line comments because // is part of urls -->
<context ref="css:comment" original="true"/>
+ <context ref="css:escape" ignore-style="true"/>
<context ref="css:string-value"/>
</include>
</context>
@@ -330,6 +331,7 @@
<context ref="logical-operator"/>
<context ref="comparison-operator"/>
<context ref="arithmetic-operator"/>
+ <context ref="css:name-value" original="true"/>
<context ref="css:slash"/>
<context ref="css:comma"/>
</include>
diff --git a/tests/syntax-highlighting/file.css b/tests/syntax-highlighting/file.css
index 2d04188c..450a694c 100644
--- a/tests/syntax-highlighting/file.css
+++ b/tests/syntax-highlighting/file.css
@@ -195,6 +195,7 @@ svg|[fill] { /* attribute */
content: "\E9 dition \
\"\0000E9dition\" \
\e9motion";
+ font-family: \E9 dition, \"\0000E9dition\", \e9motion;
/* function name */
background: \u\72\l(image.png);
diff --git a/tests/syntax-highlighting/file.less b/tests/syntax-highlighting/file.less
index 1132b4cc..e0ddd211 100644
--- a/tests/syntax-highlighting/file.less
+++ b/tests/syntax-highlighting/file.less
@@ -617,6 +617,7 @@ svg|[fill] { /* attribute */
content: "\E9 dition \
\"\0000E9dition\" \
\e9motion";
+ font-family: \E9 dition, \"\0000E9dition\", \e9motion;
/* function name */
background: \u\72\l(image.png);
diff --git a/tests/syntax-highlighting/file.scss b/tests/syntax-highlighting/file.scss
index a2e611d4..f7444094 100644
--- a/tests/syntax-highlighting/file.scss
+++ b/tests/syntax-highlighting/file.scss
@@ -642,6 +642,7 @@ svg|[fill] { /* attribute */
content: "\E9 dition \
\"\0000E9dition\" \
\e9motion";
+ font-family: \E9 dition, \"\0000E9dition\", \e9motion;
/* function name */
background: \u\72\l(image.png);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]