[gtksourceview] python.lang: recognize escape sequences in raw strings
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] python.lang: recognize escape sequences in raw strings
- Date: Thu, 16 Nov 2017 14:57:28 +0000 (UTC)
commit 3024375f700064295e594cf3f8c4ad7a209d1e4c
Author: Роман Донченко <dpb corrigendum ru>
Date: Thu Nov 16 01:53:54 2017 +0300
python.lang: recognize escape sequences in raw strings
Raw strings can still contain escape sequences. In particular, the quote
character can be escaped. However, the escape sequences are interpreted
literally (i.e., as a backslash followed by other characters).
Illustrate that by suppressing the style of the escaped-char context.
Line continuations are interpreted literally inside raw strings too (as
a backslash and a newline), so suppress the style for those, as well.
https://bugzilla.gnome.org/show_bug.cgi?id=784673
data/language-specs/python.lang | 8 ++++++--
tests/syntax-highlighting/file.py | 5 +++++
2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/data/language-specs/python.lang b/data/language-specs/python.lang
index 21a811c..ea20715 100644
--- a/data/language-specs/python.lang
+++ b/data/language-specs/python.lang
@@ -137,6 +137,7 @@
<end>"""</end>
<include>
<context ref="format"/>
+ <context ref="escaped-char" ignore-style="true"/>
</include>
</context>
@@ -145,6 +146,7 @@
<end>'''</end>
<include>
<context ref="format"/>
+ <context ref="escaped-char" ignore-style="true"/>
</include>
</context>
@@ -153,7 +155,8 @@
<end>"</end>
<include>
<context ref="format"/>
- <context ref="def:line-continue"/>
+ <context ref="escaped-char" ignore-style="true"/>
+ <context ref="def:line-continue" ignore-style="true"/>
</include>
</context>
@@ -162,7 +165,8 @@
<end>'</end>
<include>
<context ref="format"/>
- <context ref="def:line-continue"/>
+ <context ref="escaped-char" ignore-style="true"/>
+ <context ref="def:line-continue" ignore-style="true"/>
</include>
</context>
diff --git a/tests/syntax-highlighting/file.py b/tests/syntax-highlighting/file.py
index faaa113..819875d 100644
--- a/tests/syntax-highlighting/file.py
+++ b/tests/syntax-highlighting/file.py
@@ -6,4 +6,9 @@ class Hello(object):
def hello(self):
print >> sys.stderr, "Hi there!"
None, True, False
+ r'raw \' \
+ string'
+ r"""raw multiline \"""
+ string"""
+
Hello().hello()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]