Fix code blocks so reserved keywords inside strings don't get painted as reserved
This commit is contained in:
parent
52c1836c9c
commit
808b878658
1 changed files with 8 additions and 6 deletions
|
|
@ -287,12 +287,6 @@ class CodeHighlighter:
|
|||
# HTML comments
|
||||
patterns.append((r"<!--.*?-->", "comment"))
|
||||
|
||||
# Strings (double quotes)
|
||||
patterns.append((r'"[^"\\]*(\\.[^"\\]*)*"', "string"))
|
||||
|
||||
# Strings (single quotes)
|
||||
patterns.append((r"'[^'\\]*(\\.[^'\\]*)*'", "string"))
|
||||
|
||||
# Numbers
|
||||
patterns.append((r"\b\d+\.?\d*\b", "number"))
|
||||
|
||||
|
|
@ -300,6 +294,14 @@ class CodeHighlighter:
|
|||
for keyword in keywords:
|
||||
patterns.append((r"\b" + keyword + r"\b", "keyword"))
|
||||
|
||||
# Do strings last so they override any of the above (e.g reserved keywords in strings)
|
||||
|
||||
# Strings (double quotes)
|
||||
patterns.append((r'"[^"\\]*(\\.[^"\\]*)*"', "string"))
|
||||
|
||||
# Strings (single quotes)
|
||||
patterns.append((r"'[^'\\]*(\\.[^'\\]*)*'", "string"))
|
||||
|
||||
return patterns
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue