summaryrefslogtreecommitdiff
path: root/pygments/lexers/data.py
diff options
context:
space:
mode:
authorFelix Fontein <felix@fontein.de>2018-05-19 16:12:37 +0200
committerFelix Fontein <felix@fontein.de>2018-05-19 16:12:37 +0200
commitee6237e744729b3d2d58112dba6fff4bad4b9bfa (patch)
tree752aca0b7e24e156944d54897c751d571160c4e8 /pygments/lexers/data.py
parent0db8e281af377923115b894703b2b8beb8f1e9d5 (diff)
downloadpygments-ee6237e744729b3d2d58112dba6fff4bad4b9bfa.tar.gz
Improving lexing of YAML mappings.
Diffstat (limited to 'pygments/lexers/data.py')
-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