Skip to content

Commit

Permalink
Python: Fixed empty multiline strings (#2344)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Apr 29, 2020
1 parent 30b4e25 commit c932447
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions components/prism-python.js
Expand Up @@ -4,7 +4,7 @@ Prism.languages.python = {
lookbehind: true
},
'string-interpolation': {
pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
greedy: true,
inside: {
'interpolation': {
Expand All @@ -27,7 +27,7 @@ Prism.languages.python = {
}
},
'triple-quoted-string': {
pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,
pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]*?\1/i,
greedy: true,
alias: 'string'
},
Expand Down
2 changes: 1 addition & 1 deletion components/prism-python.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/languages/python/string-interpolation_feature.test
Expand Up @@ -144,4 +144,4 @@ f'{(lambda x: x*2)(3)}'

----------------------------------------------------

Checks for string interpolation.
Checks for string interpolation.
6 changes: 5 additions & 1 deletion tests/languages/python/triple-quoted-string_feature.test
@@ -1,7 +1,9 @@
""""""
"""foobar"""
"""fo"o
#bar
baz"""
''''''
'''foobar'''
'''fo'o
#bar
Expand All @@ -10,12 +12,14 @@ baz'''
----------------------------------------------------

[
["triple-quoted-string", "\"\"\"\"\"\""],
["triple-quoted-string", "\"\"\"foobar\"\"\""],
["triple-quoted-string", "\"\"\"fo\"o\r\n#bar\r\nbaz\"\"\""],
["triple-quoted-string", "''''''"],
["triple-quoted-string", "'''foobar'''"],
["triple-quoted-string", "'''fo'o\r\n#bar\r\nbaz'''"]
]

----------------------------------------------------

Checks for triple-quoted strings.
Checks for triple-quoted strings.

0 comments on commit c932447

Please sign in to comment.