1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-11 01:37:41 +03:00

rc toml: fix wrong highlighting of triple quoted strings that have quotes at the end

In TOML's triple-quoted strings, it's allowed to place quotes just
next to the triple quotes.

	foo = '''bar''''
		    ^    part of the string contents
		     ^^^ closing sequence

We greedily interpret the first three single quotes as closing
sequence. As a result the remaining single quote wrongly opens a new
string. Fix this by only treating triple quotes as closing if they
are not followed by another quote.
I don't think there is another possible interpretation of quadruple
quotes in TOML, so this should not affect other valid inputs.

Fixes #4143
This commit is contained in:
Johannes Altmanninger 2021-09-15 17:00:02 +02:00
parent 6565f6edd7
commit afd1fa2217

View File

@ -35,10 +35,10 @@ provide-module toml %{
add-highlighter shared/toml regions
add-highlighter shared/toml/code default-region group
add-highlighter shared/toml/comment region '#' $ fill comment
add-highlighter shared/toml/string1 region '"""' (?<!\\)(\\\\)*""" fill string
add-highlighter shared/toml/string2 region "'''" "'''" fill string
add-highlighter shared/toml/string3 region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/toml/string4 region "'" "'" fill string
add-highlighter shared/toml/string1 region '"""' (?<!\\)(\\\\)*"""(?!") fill string
add-highlighter shared/toml/string2 region "'''" "'''(?!')" fill string
add-highlighter shared/toml/string3 region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/toml/string4 region "'" "'" fill string
add-highlighter shared/toml/code/ regex \
"^\h*\[\[?([A-Za-z0-9._-]*)\]\]?" 1:title