diff options
author | Felix Fontein <felix@fontein.de> | 2018-05-19 16:12:37 +0200 |
---|---|---|
committer | Felix Fontein <felix@fontein.de> | 2018-05-19 16:12:37 +0200 |
commit | ee6237e744729b3d2d58112dba6fff4bad4b9bfa (patch) | |
tree | 752aca0b7e24e156944d54897c751d571160c4e8 | |
parent | 0db8e281af377923115b894703b2b8beb8f1e9d5 (diff) | |
download | pygments-ee6237e744729b3d2d58112dba6fff4bad4b9bfa.tar.gz |
Improving lexing of YAML mappings.
-rw-r--r-- | pygments/lexers/data.py | 6 |
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 |