diff options
author | Tim Hatch <tim@timhatch.com> | 2014-10-08 18:55:35 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-10-08 18:55:35 -0700 |
commit | 87781e3aa6748b035a822a3a8fdf2cedd53d478b (patch) | |
tree | 85da94f2627df7405c2a989f4e430ddda3bcf9db /pygments/lexers/data.py | |
parent | 6f82393fe38d73ffc2ef61b16722c603e41b6ec2 (diff) | |
download | pygments-87781e3aa6748b035a822a3a8fdf2cedd53d478b.tar.gz |
Add JSON-LD Lexer.
Adapted from PR 289.
Diffstat (limited to 'pygments/lexers/data.py')
-rw-r--r-- | pygments/lexers/data.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/pygments/lexers/data.py b/pygments/lexers/data.py index 6b7cc107..6ea331f6 100644 --- a/pygments/lexers/data.py +++ b/pygments/lexers/data.py @@ -12,11 +12,11 @@ import re from pygments.lexer import RegexLexer, ExtendedRegexLexer, LexerContext, \ - include, bygroups + include, bygroups, inherit from pygments.token import Text, Comment, Keyword, Name, String, Number, \ Punctuation, Literal -__all__ = ['YamlLexer', 'JsonLexer'] +__all__ = ['YamlLexer', 'JsonLexer', 'JsonLdLexer'] class YamlLexerContext(LexerContext): @@ -507,3 +507,24 @@ class JsonLexer(RegexLexer): include('value'), ], } + +class JsonLdLexer(JsonLexer): + """ + For `JSON-LD <http://json-ld.org/>`_ linked data. + + .. versionadded:: 2.0 + """ + + name = 'JSON-LD' + aliases = ['jsonld', 'json-ld'] + filenames = ['*.jsonld'] + mimetypes = ['application/ld+json'] + + tokens = { + 'objectvalue': [ + (r'"@(context|id|value|language|type|container|list|set|' + r'reverse|index|base|vocab|graph)"', Name.Decorator, + 'objectattribute'), + inherit, + ], + } |