syntax: python: avoid miscoloring stuff between two empty strings

The quotes of an empty string ('' or "") should be colored just like
those of a non-empty string, because otherwise the text *between* two
empty strings on the same line gets colored.

Add an extra rule to discolor triple quotes again to not make them
look like valid by themselves.

Also, remove six superfluous backslashes.

This addresses https://savannah.gnu.org/patch/?9801.
Reported-by: Ryan Westlund <rlwestlund@gmail.com>
This commit is contained in:
Benno Schulenberg 2019-05-11 17:52:41 +02:00
parent 4fb9f298c9
commit 8f1cd50f1e

View File

@ -22,14 +22,15 @@ color brightcyan "\<(exec|print)([[:blank:]]|$)"
# Special values.
color brightmagenta "\<(False|None|True)\>"
# Single-quoted strings.
color brightgreen "'([^'\]|\\.)+'"
color brightgreen ""([^"\]|\\.)+""
# Mono-quoted strings.
color brightgreen "'([^'\]|\\.)*'|'''"
color brightgreen ""([^"\]|\\.)*"|""""
color normal "'''|""""
# Comments.
color brightred "(^|[[:blank:]])#.*"
# Triple-quoted strings.
color brightgreen start="'''([^'),]|$)" end="(^|[^(\])'''"
color brightgreen start="\"\"\"([^"),]|$)" end="(^|[^(\])\"\"\""
color brightgreen start=""""([^"),]|$)" end="(^|[^(\])""""
# Reminders.
color brightwhite,yellow "(FIXME|TODO|XXX)"