summaryrefslogtreecommitdiff
path: root/rc/filetype/python.kak
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-11-23 08:45:59 +1100
committerMaxime Coste <mawww@kakoune.org>2020-11-23 08:45:59 +1100
commit14f7d2637c80258d80e5ae204e16dbb67a896ebc (patch)
tree503ce170d079f10fb639645428117302398eb9f2 /rc/filetype/python.kak
parent024e0a04f21cdecc9ada1e32c4b2c62d9ddd6076 (diff)
Fix test and re-add triple_string support in python highlighting
Triple strings are now distinct from docstrings, triple strings only preceeded by blanks on the line are considered docstrings. Avoid highlighting of the closing marker using a lookahead, this is not fully correct as it will break on a double quote triple docstring containing a single quote triple string but that seems improbable enough; if we encounter this in the wild we can split the two docstring formats into separate regions.
Diffstat (limited to 'rc/filetype/python.kak')
-rw-r--r--rc/filetype/python.kak4
1 files changed, 2 insertions, 2 deletions
diff --git a/rc/filetype/python.kak b/rc/filetype/python.kak
index d7b09aa7..7f44897d 100644
--- a/rc/filetype/python.kak
+++ b/rc/filetype/python.kak
@@ -36,6 +36,7 @@ provide-module python %ยง
add-highlighter shared/python regions
add-highlighter shared/python/code default-region group
add-highlighter shared/python/docstring region -match-capture ^\h*("""|''') (?<!\\)(?:\\\\)*("""|''') regions
+add-highlighter shared/python/triple_string region -match-capture ("""|''') (?<!\\)(?:\\\\)*("""|''') fill string
add-highlighter shared/python/double_string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/python/single_string region "'" (?<!\\)(\\\\)*' fill string
add-highlighter shared/python/documentation region '##' '$' fill documentation
@@ -54,8 +55,7 @@ add-highlighter shared/python/code/ regex '\b\d+\.' 0:value
add-highlighter shared/python/code/ regex '\b\d+\+\d+[jJ]\b' 0:value
add-highlighter shared/python/docstring/ default-region fill comment
-add-highlighter shared/python/docstring/ region '>>> \K' '\z' ref python
-add-highlighter shared/python/docstring/ region '\.\.\. \K' '\z' ref python
+add-highlighter shared/python/docstring/ region '(>>>|\.\.\.) \K' (?=''')|(?=""") ref python
evaluate-commands %sh{
# Grammar