summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnteru <bitbucket@ca.sh13.net>2018-12-13 18:54:13 +0000
committerAnteru <bitbucket@ca.sh13.net>2018-12-13 18:54:13 +0000
commitad4dcbb58826c360ee75747d6abface552695bff (patch)
treecf17901269fba71a3881beb4d936991d40db6b71
parentb03337e1f9c417af74159eaa70169bf8a093ad8b (diff)
parentee6237e744729b3d2d58112dba6fff4bad4b9bfa (diff)
downloadpygments-ad4dcbb58826c360ee75747d6abface552695bff.tar.gz
Merged in felixfontein/pygments-main (pull request #762)
Improving lexing of YAML mappings Approved-by: John Barker <john@johnrbarker.com>
-rw-r--r--pygments/lexers/data.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/pygments/lexers/data.py b/pygments/lexers/data.py
index 296366c2..abe87160 100644
--- a/pygments/lexers/data.py
+++ b/pygments/lexers/data.py
@@ -232,6 +232,9 @@ class YamlLexer(ExtendedRegexLexer):
(r'[ ]*(?=#|$)', something(Text), '#pop'),
# whitespaces separating tokens
(r'[ ]+', Text),
+ # key with colon
+ (r'([^,:?\[\]{}\n]+)(:)(?=[ ]|$)',
+ bygroups(Name.Tag, set_indent(Punctuation, implicit=True))),
# tags, anchors and aliases,
include('descriptors'),
# block collections and scalars
@@ -308,6 +311,9 @@ class YamlLexer(ExtendedRegexLexer):
# a flow mapping indicated by '{' and '}'
'flow-mapping': [
+ # key with colon
+ (r'([^,:?\[\]{}\n]+)(:)(?=[ ]|$)',
+ bygroups(Name.Tag, Punctuation)),
# include flow collection rules
include('flow-collection'),
# the closing indicator