summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2016-05-04 16:27:43 +0200
committerGeorg Brandl <georg@python.org>2016-05-04 16:27:43 +0200
commit46d327ffec931b5cc09d2b03f491e115ecc31007 (patch)
tree2f923c9398a417dc235a081e882732fecfed3e61
parent8ce6a5ca04a60d8fc4f388ea2a6a688ac32022b8 (diff)
parentfdbd4b8fda9db85caab00c7734a9decd3a72e8f0 (diff)
downloadpygments-git-46d327ffec931b5cc09d2b03f491e115ecc31007.tar.gz
Merged in embray/pygments-main (pull request #584)
Fix incorrect lexing of YAML tags
-rw-r--r--pygments/lexers/data.py6
-rw-r--r--tests/examplefiles/example.yaml9
2 files changed, 12 insertions, 3 deletions
diff --git a/pygments/lexers/data.py b/pygments/lexers/data.py
index c88375d5..84d02f49 100644
--- a/pygments/lexers/data.py
+++ b/pygments/lexers/data.py
@@ -247,10 +247,10 @@ class YamlLexer(ExtendedRegexLexer):
# tags, anchors, aliases
'descriptors': [
# a full-form tag
- (r'!<[\w;/?:@&=+$,.!~*\'()\[\]%-]+>', Keyword.Type),
+ (r'!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>', Keyword.Type),
# a tag in the form '!', '!suffix' or '!handle!suffix'
- (r'!(?:[\w-]+)?'
- r'(?:![\w;/?:@&=+$,.!~*\'()\[\]%-]+)?', Keyword.Type),
+ (r'!(?:[\w-]+!)?'
+ r'[\w#;/?:@&=+$,.!~*\'()\[\]%-]+', Keyword.Type),
# an anchor
(r'&[\w-]+', Name.Label),
# an alias
diff --git a/tests/examplefiles/example.yaml b/tests/examplefiles/example.yaml
index 9c0ed9d0..17544c02 100644
--- a/tests/examplefiles/example.yaml
+++ b/tests/examplefiles/example.yaml
@@ -1,3 +1,12 @@
+#
+# Regression tests
+#
+
+%TAG ! tag:example.com:foo/
+---
+test: !foo/bar {a: 'asdf'}
+test2: fred
+...
#
# Examples from the Preview section of the YAML specification