Skip to content

Commit c932447

Browse files
authoredApr 29, 2020
Python: Fixed empty multiline strings (#2344)
1 parent 30b4e25 commit c932447

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed
 

‎components/prism-python.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Prism.languages.python = {
44
lookbehind: true
55
},
66
'string-interpolation': {
7-
pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
7+
pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
88
greedy: true,
99
inside: {
1010
'interpolation': {
@@ -27,7 +27,7 @@ Prism.languages.python = {
2727
}
2828
},
2929
'triple-quoted-string': {
30-
pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,
30+
pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]*?\1/i,
3131
greedy: true,
3232
alias: 'string'
3333
},

‎components/prism-python.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/languages/python/string-interpolation_feature.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ f'{(lambda x: x*2)(3)}'
144144

145145
----------------------------------------------------
146146

147-
Checks for string interpolation.
147+
Checks for string interpolation.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
""""""
12
"""foobar"""
23
"""fo"o
34
#bar
45
baz"""
6+
''''''
57
'''foobar'''
68
'''fo'o
79
#bar
@@ -10,12 +12,14 @@ baz'''
1012
----------------------------------------------------
1113

1214
[
15+
["triple-quoted-string", "\"\"\"\"\"\""],
1316
["triple-quoted-string", "\"\"\"foobar\"\"\""],
1417
["triple-quoted-string", "\"\"\"fo\"o\r\n#bar\r\nbaz\"\"\""],
18+
["triple-quoted-string", "''''''"],
1519
["triple-quoted-string", "'''foobar'''"],
1620
["triple-quoted-string", "'''fo'o\r\n#bar\r\nbaz'''"]
1721
]
1822

1923
----------------------------------------------------
2024

21-
Checks for triple-quoted strings.
25+
Checks for triple-quoted strings.

0 commit comments

Comments
 (0)
Please sign in to comment.