[gtksourceview/gnome-3-24] python.lang: recognize escape sequences in raw strings
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gnome-3-24] python.lang: recognize escape sequences in raw strings
- Date: Thu, 16 Nov 2017 15:00:20 +0000 (UTC)
commit f8dcfa773944444b01de74eca431076692fc4bb2
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 3e51fb1..e80cdce 100644
--- a/data/language-specs/python.lang
+++ b/data/language-specs/python.lang
@@ -138,6 +138,7 @@
<end>"""</end>
<include>
<context ref="format"/>
+ <context ref="escaped-char" ignore-style="true"/>
</include>
</context>
@@ -146,6 +147,7 @@
<end>'''</end>
<include>
<context ref="format"/>
+ <context ref="escaped-char" ignore-style="true"/>
</include>
</context>
@@ -154,7 +156,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>
@@ -163,7 +166,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]