Skip to content

Commit

Permalink
Updates from review.
Browse files Browse the repository at this point in the history
  • Loading branch information
abentley authored and jeanas committed Sep 25, 2022
1 parent a563094 commit 8864640
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 37 deletions.
7 changes: 5 additions & 2 deletions pygments/lexers/jsonnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Operator,
Punctuation,
String,
Text,
Whitespace,
)

Expand Down Expand Up @@ -48,6 +49,7 @@ class JsonnetLexer(RegexLexer):
name = 'Jsonnet'
aliases = ['jsonnet']
filenames = ['*.jsonnet', '*.libsonnet']
url = "https://jsonnet.org"
tokens = {
# Not used by itself
'_comments': [
Expand All @@ -62,14 +64,15 @@ class JsonnetLexer(RegexLexer):
(r"'", String, 'singlestring'),
(r'"', String, 'doublestring'),
(r'(?s:\|\|\|.*\|\|\|)', String),
# Jsonnet has no integers, only an IEEE754 64-bit float
(r'[+-]?[0-9]+(.[0-9])?', Number.Float),
# Omit : despite spec because it appears to be used as a field
# separator
(r'[!$~+\-&|^=<>*/%]', Operator),
(r'[{]', Punctuation, 'object'),
(r'\[', Punctuation, 'array'),
(r'local\b', Keyword, ('local_name')),
(r'assert', Keyword, 'assert'),
(r'assert\b', Keyword, 'assert'),
(words([
'assert', 'else', 'error', 'false', 'for', 'if', 'import',
'importstr', 'in', 'null', 'tailstrict', 'then', 'self',
Expand Down Expand Up @@ -125,7 +128,7 @@ class JsonnetLexer(RegexLexer):
(r'local\b', Keyword, 'object_local_name'),
(r'assert\b', Keyword, 'object_assert'),
(r'\[', Operator, 'field_name_expr'),
(fr'(?={jsonnet_token})', Name.Variable, 'field_name'),
(fr'(?={jsonnet_token})', Text, 'field_name'),
(r'}', Punctuation, '#pop'),
(r'"', Name.Variable, 'double_field_name'),
(r"'", Name.Variable, 'single_field_name'),
Expand Down
70 changes: 35 additions & 35 deletions tests/examplefiles/jsonnet/example.jsonnet.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8864640

Please sign in to comment.