summaryrefslogtreecommitdiff
path: root/pygments/lexers/data.py
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-10-08 18:55:35 -0700
committerTim Hatch <tim@timhatch.com>2014-10-08 18:55:35 -0700
commit87781e3aa6748b035a822a3a8fdf2cedd53d478b (patch)
tree85da94f2627df7405c2a989f4e430ddda3bcf9db /pygments/lexers/data.py
parent6f82393fe38d73ffc2ef61b16722c603e41b6ec2 (diff)
downloadpygments-87781e3aa6748b035a822a3a8fdf2cedd53d478b.tar.gz
Add JSON-LD Lexer.
Adapted from PR 289.
Diffstat (limited to 'pygments/lexers/data.py')
-rw-r--r--pygments/lexers/data.py25
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,
+ ],
+ }