Skip to content

Commit eb58d63

Browse files
committed
Verified and fixed any typos in keywords
1 parent eff20a1 commit eb58d63

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

jsonschema_lexer/lexer.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pygments.lexer import include, RegexLexer
22
from pygments.token import Token
33

4+
45
def _get_regex_from_options(options: list[str]) -> str:
56
"""
67
Constructs a regular expression pattern allowing any string from the options list.
@@ -15,12 +16,14 @@ def _get_regex_from_options(options: list[str]) -> str:
1516
regex_str = "(" + "|".join(options) + ")"
1617
return regex_str
1718

19+
1820
class JSONSchemaLexer(RegexLexer):
1921
"""
2022
Lexer for JSON Schema syntax highlighting.
2123
"""
24+
2225
name = "JSON Schema Lexer"
23-
26+
2427
data_types = ["object", "integer", "string", "number", "array", "boolean", "null"]
2528
core_keywords = [
2629
r"\$schema",
@@ -46,7 +49,7 @@ class JSONSchemaLexer(RegexLexer):
4649
"additionalProperties",
4750
"dependentSchemas",
4851
"propertyNames",
49-
"prefixNames",
52+
"prefixItems",
5053
"contains",
5154
"items",
5255
]
@@ -81,7 +84,15 @@ class JSONSchemaLexer(RegexLexer):
8184
"maxContains",
8285
"uniqueItems",
8386
]
84-
other_keywords = ["format", "unevaluated", "content", "format_assertion"]
87+
other_keywords = [
88+
"format",
89+
"unevaluatedItems",
90+
"unevaluatedProperties",
91+
"contentEncoding",
92+
"contentMediaType",
93+
"contentSchema",
94+
"format_assertion",
95+
]
8596

8697
tokens = {
8798
"whitespace": [
@@ -133,15 +144,13 @@ class JSONSchemaLexer(RegexLexer):
133144
include("meta_data_keywords"),
134145
include("other_keywords"),
135146
],
136-
137147
# represents a simple terminal value
138148
"simplevalue": [
139149
include("data_types"),
140150
(r"(true|false)", Token.Number),
141151
(r"-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?", Token.Number.Integer),
142152
('"(\\|"|[^"])*"', Token.String.Double),
143153
],
144-
145154
# the right hand side of an object, after the attribute name
146155
"objectattribute": [
147156
include("value"),
@@ -151,31 +160,27 @@ class JSONSchemaLexer(RegexLexer):
151160
# a closing bracket terminates the entire object, so pop twice
152161
(r"}", Token.Punctuation, ("#pop", "#pop")),
153162
],
154-
155163
# a json object - { attr, attr, ... }
156164
"objectvalue": [
157165
include("whitespace"),
158166
include("keywords"),
159167
(r'"(\\\\|\\"|[^"])*"', Token.Name.Tag, "objectattribute"),
160168
(r"}", Token.Punctuation, "#pop"),
161169
],
162-
163170
# json array - [ value, value, ... }
164171
"arrayvalue": [
165172
include("whitespace"),
166173
include("value"),
167174
(r",", Token.Punctuation),
168175
(r"]", Token.Punctuation, "#pop"),
169176
],
170-
171177
# a json value - either a simple value or a complex value (object or array)
172178
"value": [
173179
include("whitespace"),
174180
include("simplevalue"),
175181
(r"{", Token.Punctuation, "objectvalue"),
176182
(r"\[", Token.Punctuation, "arrayvalue"),
177183
],
178-
179184
# the root of a json document whould be a value
180185
"root": [
181186
include("value"),

0 commit comments

Comments
 (0)