diff --git a/README.md b/README.md index 34a7d15eb..7c35585a7 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ translators for Pygments lexers and styles. | G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, Gleam, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groff, Groovy | | H | Handlebars, Hare, Haskell, Haxe, HCL, Hexdump, HLB, HLSL, HolyC, HTML, HTTP, Hy | | I | Idris, Igor, INI, Io, ISCdhcpd | -| J | J, Java, JavaScript, JSON, Julia, Jungle | +| J | J, Java, JavaScript, JSON, Jsonnet, Julia, Jungle | | K | Kotlin | | L | Lighttpd configuration file, LLVM, Lua | | M | Makefile, Mako, markdown, Mason, Materialize SQL dialect, Mathematica, Matlab, MCFunction, Meson, Metal, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL | diff --git a/lexers/embedded/jsonnet.xml b/lexers/embedded/jsonnet.xml new file mode 100644 index 000000000..1633a5e40 --- /dev/null +++ b/lexers/embedded/jsonnet.xml @@ -0,0 +1,138 @@ + + + + Jsonnet + jsonnet + *.jsonnet + *.libsonnet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lexers/testdata/jsonnet.actual b/lexers/testdata/jsonnet.actual new file mode 100644 index 000000000..c2681c4ca --- /dev/null +++ b/lexers/testdata/jsonnet.actual @@ -0,0 +1,36 @@ +local application = 'my-app'; +local module = 'uwsgi_module'; +local dir = '/var/www'; +local permission = 644; + +{ + 'uwsgi.ini': std.manifestIni({ + sections: { + uwsgi: { + module: module, + pythonpath: dir, + socket: dir + '/uwsgi.sock', + 'chmod-socket': permission, + callable: application, + logto: '/var/log/uwsgi/uwsgi.log', + }, + }, + }), + + 'init.sh': ||| + #!/usr/bin/env bash + mkdir -p %(dir)s + touch %(dir)s/initialized + chmod %(perm)d %(dir)s/initialized + ||| % {dir: dir, perm: permission}, + + 'cassandra.conf': std.manifestYamlDoc({ + cluster_name: application, + seed_provider: [ + { + class_name: 'SimpleSeedProvider', + parameters: [{ seeds: '127.0.0.1' }], + }, + ], + }), +} diff --git a/lexers/testdata/jsonnet.expected b/lexers/testdata/jsonnet.expected new file mode 100644 index 000000000..ca475ad5e --- /dev/null +++ b/lexers/testdata/jsonnet.expected @@ -0,0 +1,167 @@ +[ + {"type":"Keyword","value":"local"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"application"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Operator","value":"="}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralString","value":"'my-app'"}, + {"type":"Punctuation","value":";"}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Keyword","value":"local"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"module"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Operator","value":"="}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralString","value":"'uwsgi_module'"}, + {"type":"Punctuation","value":";"}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Keyword","value":"local"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"dir"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Operator","value":"="}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralString","value":"'/var/www'"}, + {"type":"Punctuation","value":";"}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Keyword","value":"local"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"permission"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Operator","value":"="}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralNumberFloat","value":"644"}, + {"type":"Punctuation","value":";"}, + {"type":"TextWhitespace","value":"\n\n"}, + {"type":"Punctuation","value":"{"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"'uwsgi.ini'"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameBuiltin","value":"std.manifestIni"}, + {"type":"Punctuation","value":"({"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"sections"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"uwsgi"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"module"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"module"}, + {"type":"Punctuation","value":","}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"pythonpath"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"dir"}, + {"type":"Punctuation","value":","}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"socket"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"dir"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Operator","value":"+"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralString","value":"'/uwsgi.sock'"}, + {"type":"Punctuation","value":","}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"'chmod-socket'"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"permission"}, + {"type":"Punctuation","value":","}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"callable"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"application"}, + {"type":"Punctuation","value":","}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"logto"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralString","value":"'/var/log/uwsgi/uwsgi.log'"}, + {"type":"Punctuation","value":","}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"Punctuation","value":"},"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"Punctuation","value":"},"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"Punctuation","value":"}),"}, + {"type":"TextWhitespace","value":"\n\n "}, + {"type":"NameVariable","value":"'init.sh'"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralString","value":"|||\n #!/usr/bin/env bash\n mkdir -p %(dir)s\n touch %(dir)s/initialized\n chmod %(perm)d %(dir)s/initialized\n |||"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Operator","value":"%"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"NameVariable","value":"dir"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"dir"}, + {"type":"Punctuation","value":","}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"perm"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"permission"}, + {"type":"Punctuation","value":"},"}, + {"type":"TextWhitespace","value":"\n\n "}, + {"type":"NameVariable","value":"'cassandra.conf'"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameBuiltin","value":"std.manifestYamlDoc"}, + {"type":"Punctuation","value":"({"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"cluster_name"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"application"}, + {"type":"Punctuation","value":","}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"seed_provider"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Punctuation","value":"["}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"Punctuation","value":"{"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"class_name"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralString","value":"'SimpleSeedProvider'"}, + {"type":"Punctuation","value":","}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"NameVariable","value":"parameters"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Punctuation","value":"[{"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"seeds"}, + {"type":"Punctuation","value":":"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralString","value":"'127.0.0.1'"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Punctuation","value":"}],"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"Punctuation","value":"},"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"Punctuation","value":"],"}, + {"type":"TextWhitespace","value":"\n "}, + {"type":"Punctuation","value":"}),"}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"TextWhitespace","value":"\n"} +]