Add Python f-string interpolation highlights

This commit is contained in:
Răzvan C. Rădulescu 2022-11-30 12:15:49 +02:00 committed by Maxime Coste
parent 80ae73c665
commit 86bd4efd25

View File

@ -36,12 +36,29 @@ 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
add-highlighter shared/python/comment region '#' '$' fill comment
# String interpolation
add-highlighter shared/python/f_triple_string region -match-capture [fF]("""|''') (?<!\\)(?:\\\\)*("""|''') group
add-highlighter shared/python/f_triple_string/ fill string
add-highlighter shared/python/f_triple_string/ regex \{.*?\} 0:value
add-highlighter shared/python/f_double_string region '[fF]"' (?<!\\)(\\\\)*" group
add-highlighter shared/python/f_double_string/ fill string
add-highlighter shared/python/f_double_string/ regex \{.*?\} 0:value
add-highlighter shared/python/f_single_string region "[fF]'" (?<!\\)(\\\\)*' group
add-highlighter shared/python/f_single_string/ fill string
add-highlighter shared/python/f_single_string/ regex \{.*?\} 0:value
# Regular string
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
# Integer formats
add-highlighter shared/python/code/ regex '(?i)\b0b[01]+l?\b' 0:value
add-highlighter shared/python/code/ regex '(?i)\b0x[\da-f]+l?\b' 0:value