From b4509bf55e057ad7dd92e4b78528bfd799c625b7 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 11 Apr 2018 08:58:28 +0200 Subject: [PATCH] Add support for Soy (Closure Template). Fix #1316 (#1387) --- components.js | 2 +- components.json | 5 + components/prism-soy.js | 96 +++++ components/prism-soy.min.js | 1 + examples/prism-soy.html | 36 ++ plugins/autoloader/prism-autoloader.js | 2 +- plugins/autoloader/prism-autoloader.min.js | 2 +- plugins/show-language/prism-show-language.js | 2 +- .../show-language/prism-show-language.min.js | 2 +- tests/languages/soy/boolean_feature.test | 27 ++ tests/languages/soy/command-arg.test | 84 +++++ tests/languages/soy/comment_feature.test | 25 ++ tests/languages/soy/function_feature.test | 86 +++++ tests/languages/soy/keyword_feature.test | 338 ++++++++++++++++++ tests/languages/soy/literal_feature.test | 73 ++++ tests/languages/soy/number_feature.test | 63 ++++ tests/languages/soy/operator_feature.test | 121 +++++++ tests/languages/soy/parameter_feature.test | 72 ++++ tests/languages/soy/property_feature.test | 54 +++ .../languages/soy/soy_in_markup_feature.test | 68 ++++ tests/languages/soy/string_feature.test | 47 +++ tests/languages/soy/variable_feature.test | 86 +++++ 22 files changed, 1287 insertions(+), 5 deletions(-) create mode 100644 components/prism-soy.js create mode 100644 components/prism-soy.min.js create mode 100644 examples/prism-soy.html create mode 100644 tests/languages/soy/boolean_feature.test create mode 100644 tests/languages/soy/command-arg.test create mode 100644 tests/languages/soy/comment_feature.test create mode 100644 tests/languages/soy/function_feature.test create mode 100644 tests/languages/soy/keyword_feature.test create mode 100644 tests/languages/soy/literal_feature.test create mode 100644 tests/languages/soy/number_feature.test create mode 100644 tests/languages/soy/operator_feature.test create mode 100644 tests/languages/soy/parameter_feature.test create mode 100644 tests/languages/soy/property_feature.test create mode 100644 tests/languages/soy/soy_in_markup_feature.test create mode 100644 tests/languages/soy/string_feature.test create mode 100644 tests/languages/soy/variable_feature.test diff --git a/components.js b/components.js index 91280dfe6a..96df9fa3d8 100644 --- a/components.js +++ b/components.js @@ -1,2 +1,2 @@ -var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML"},"option":"default"},"css":{"title":"CSS","option":"default"},"clike":{"title":"C-like","option":"default","overrideExampleHeader":true},"javascript":{"title":"JavaScript","require":"clike","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"actionscript":{"title":"ActionScript","require":"javascript","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"arduino":{"title":"Arduino","require":"cpp","owner":"eisbehr-"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"title":"AsciiDoc","owner":"Golmote"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"aspnet":{"title":"ASP.NET (C#)","require":"markup","owner":"nauzilus"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"bash":{"title":"Bash","owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","alias":"shell","owner":"Golmote"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":"dotnet","owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"coffeescript":{"title":"CoffeeScript","require":"javascript","owner":"R-osey"},"clojure":{"title":"Clojure","owner":"troglotit"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"css-extras":{"title":"CSS Extras","require":"css","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup","alias":"jinja2","owner":"romanvm"},"docker":{"title":"Docker","owner":"JustinBeckwith"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"clike","owner":"Golmote"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"graphql":{"title":"GraphQL","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","owner":"Golmote"},"haskell":{"title":"Haskell","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"http":{"title":"HTTP","owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"json":{"title":"JSON","owner":"CupOfTea696"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","require":"clike","owner":"Golmote"},"latex":{"title":"LaTeX","owner":"japborst"},"less":{"title":"Less","require":"css","owner":"Golmote"},"liquid":{"title":"Liquid","owner":"cinhtau"},"lisp":{"title":"Lisp","owner":"JuanCaicedo","alias":["emacs","elisp","emacs-lisp"]},"livescript":{"title":"LiveScript","owner":"Golmote"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"mel":{"title":"MEL","owner":"Golmote"},"mizar":{"title":"Mizar","owner":"Golmote"},"monkey":{"title":"Monkey","owner":"Golmote"},"n4js":{"title":"N4JS","require":"javascript","owner":"bsmith-n4"},"nasm":{"title":"NASM","owner":"rbmj"},"nginx":{"title":"nginx","owner":"westonganger","require":"clike"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"cpp","overrideExampleHeader":true,"owner":"Milania1"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","owner":"Golmote"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":["clike","markup-templating"],"owner":"milesj"},"php-extras":{"title":"PHP Extras","require":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":"javascript","owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","owner":"Golmote"},"python":{"title":"Python","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"renpy":{"title":"Ren'py","owner":"HyuchiaDiego"},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"ruby":{"title":"Ruby","require":"clike","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","owner":"Golmote"},"sql":{"title":"SQL","owner":"multipetros"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"textile":{"title":"Textile","require":"markup","owner":"Golmote"},"twig":{"title":"Twig","require":"markup","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","alias":"ts","owner":"vkbansal"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","owner":"Golmote","alias":"vb"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"xeora":{"title":"Xeora","require":"markup","owner":"freakmaxi"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"yaml":{"title":"YAML","owner":"hason"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":"Line Highlight","line-numbers":{"title":"Line Numbers","owner":"kuba-kubula"},"show-invisibles":"Show Invisibles","autolinker":"Autolinker","wpd":"WebPlatform Docs","custom-class":{"title":"Custom Class","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","noCSS":true},"show-language":{"title":"Show Language","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","owner":"Golmote","noCSS":true},"previewers":{"title":"Previewers","owner":"Golmote"},"autoloader":{"title":"Autoloader","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","owner":"Golmote","after":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","owner":"chriswells0"},"unescaped-markup":"Unescaped Markup","normalize-whitespace":{"title":"Normalize Whitespace","owner":"zeitgeist87","after":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","owner":"mAAdhaTTah","require":"toolbar","noCSS":true}}}; +var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML"},"option":"default"},"css":{"title":"CSS","option":"default"},"clike":{"title":"C-like","option":"default","overrideExampleHeader":true},"javascript":{"title":"JavaScript","require":"clike","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"actionscript":{"title":"ActionScript","require":"javascript","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"arduino":{"title":"Arduino","require":"cpp","owner":"eisbehr-"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"title":"AsciiDoc","owner":"Golmote"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"aspnet":{"title":"ASP.NET (C#)","require":"markup","owner":"nauzilus"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"bash":{"title":"Bash","owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","alias":"shell","owner":"Golmote"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":"dotnet","owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"coffeescript":{"title":"CoffeeScript","require":"javascript","owner":"R-osey"},"clojure":{"title":"Clojure","owner":"troglotit"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"css-extras":{"title":"CSS Extras","require":"css","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup","alias":"jinja2","owner":"romanvm"},"docker":{"title":"Docker","owner":"JustinBeckwith"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"clike","owner":"Golmote"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"graphql":{"title":"GraphQL","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","owner":"Golmote"},"haskell":{"title":"Haskell","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"http":{"title":"HTTP","owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"json":{"title":"JSON","owner":"CupOfTea696"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","require":"clike","owner":"Golmote"},"latex":{"title":"LaTeX","owner":"japborst"},"less":{"title":"Less","require":"css","owner":"Golmote"},"liquid":{"title":"Liquid","owner":"cinhtau"},"lisp":{"title":"Lisp","owner":"JuanCaicedo","alias":["emacs","elisp","emacs-lisp"]},"livescript":{"title":"LiveScript","owner":"Golmote"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"mel":{"title":"MEL","owner":"Golmote"},"mizar":{"title":"Mizar","owner":"Golmote"},"monkey":{"title":"Monkey","owner":"Golmote"},"n4js":{"title":"N4JS","require":"javascript","owner":"bsmith-n4"},"nasm":{"title":"NASM","owner":"rbmj"},"nginx":{"title":"nginx","owner":"westonganger","require":"clike"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"cpp","overrideExampleHeader":true,"owner":"Milania1"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","owner":"Golmote"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":["clike","markup-templating"],"owner":"milesj"},"php-extras":{"title":"PHP Extras","require":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":"javascript","owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","owner":"Golmote"},"python":{"title":"Python","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"renpy":{"title":"Ren'py","owner":"HyuchiaDiego"},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"ruby":{"title":"Ruby","require":"clike","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","owner":"Golmote"},"sql":{"title":"SQL","owner":"multipetros"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"textile":{"title":"Textile","require":"markup","owner":"Golmote"},"twig":{"title":"Twig","require":"markup","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","alias":"ts","owner":"vkbansal"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","owner":"Golmote","alias":"vb"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"xeora":{"title":"Xeora","require":"markup","owner":"freakmaxi"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"yaml":{"title":"YAML","owner":"hason"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":"Line Highlight","line-numbers":{"title":"Line Numbers","owner":"kuba-kubula"},"show-invisibles":"Show Invisibles","autolinker":"Autolinker","wpd":"WebPlatform Docs","custom-class":{"title":"Custom Class","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","noCSS":true},"show-language":{"title":"Show Language","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","owner":"Golmote","noCSS":true},"previewers":{"title":"Previewers","owner":"Golmote"},"autoloader":{"title":"Autoloader","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","owner":"Golmote","after":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","owner":"chriswells0"},"unescaped-markup":"Unescaped Markup","normalize-whitespace":{"title":"Normalize Whitespace","owner":"zeitgeist87","after":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","owner":"mAAdhaTTah","require":"toolbar","noCSS":true}}}; if (typeof module !== 'undefined' && module.exports) { module.exports = components; } \ No newline at end of file diff --git a/components.json b/components.json index 908937c0e8..4c5b068c3a 100644 --- a/components.json +++ b/components.json @@ -628,6 +628,11 @@ "title": "SQL", "owner": "multipetros" }, + "soy": { + "title": "Soy (Closure Template)", + "require": "markup-templating", + "owner": "Golmote" + }, "stylus": { "title": "Stylus", "owner": "vkbansal" diff --git a/components/prism-soy.js b/components/prism-soy.js new file mode 100644 index 0000000000..59080dc9c1 --- /dev/null +++ b/components/prism-soy.js @@ -0,0 +1,96 @@ +(function (Prism) { + var stringPattern = /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/; + var numberPattern = /\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|\b0x[\dA-F]+\b/; + + Prism.languages.soy = { + 'comment': [ + /\/\*[\s\S]*?\*\//, + { + pattern: /(\s)\/\/.*/, + lookbehind: true, + greedy: true + } + ], + 'command-arg': { + pattern: /({+\/?\s*(?:alias|call|delcall|delpackage|deltemplate|namespace|template)\s+)\.?[\w.]+/, + lookbehind: true, + alias: 'string', + inside: { + 'punctuation': /\./ + } + }, + 'parameter': { + pattern: /({+\/?\s*@?param\??\s+)\.?[\w.]+/, + lookbehind: true, + alias: 'variable' + }, + 'keyword': [ + { + pattern: /({+\/?[^\S\r\n]*)(?:\\[nrt]|alias|call|case|css|default|delcall|delpackage|deltemplate|else(?:if)?|fallbackmsg|for(?:each)?|if(?:empty)?|lb|let|literal|msg|namespace|nil|@?param\??|rb|sp|switch|template|xid)/, + lookbehind: true + }, + /\b(?:any|as|attributes|bool|css|float|in|int|js|html|list|map|null|number|string|uri)\b/ + ], + 'delimiter': { + pattern: /^{+\/?|\/?}+$/, + alias: 'punctuation' + }, + 'property': /\w+(?==)/, + 'variable': { + pattern: /\$[^\W\d]\w*(?:\??(?:\.\w+|\[[^\]]+]))*/, + inside: { + 'string': { + pattern: stringPattern, + greedy: true + }, + 'number': numberPattern, + 'punctuation': /[\[\].?]/ + } + }, + 'string': { + pattern: stringPattern, + greedy: true + }, + 'function': [ + /\w+(?=\()/, + { + pattern: /(\|[^\S\r\n]*)\w+/, + lookbehind: true + } + ], + 'boolean': /\b(?:true|false)\b/, + 'number': numberPattern, + 'operator': /\?:?|<=?|>=?|==?|!=|[+*/%-]|\b(?:and|not|or)\b/, + 'punctuation': /[{}()\[\]|.,:]/ + }; + + // Tokenize all inline Soy expressions + Prism.hooks.add('before-tokenize', function (env) { + var soyPattern = /{{.+?}}|{.+?}|\s\/\/.*|\/\*[\s\S]*?\*\//g; + var soyLitteralStart = '{literal}'; + var soyLitteralEnd = '{/literal}'; + var soyLitteralMode = false; + + Prism.languages['markup-templating'].buildPlaceholders(env, 'soy', soyPattern, function (match) { + // Soy tags inside {literal} block are ignored + if (match === soyLitteralEnd) { + soyLitteralMode = false; + } + + if (!soyLitteralMode) { + if (match === soyLitteralStart) { + soyLitteralMode = true; + } + + return true; + } + return false; + }); + }); + + // Re-insert the tokens after tokenizing + Prism.hooks.add('after-tokenize', function (env) { + Prism.languages['markup-templating'].tokenizePlaceholders(env, 'soy'); + }); + +}(Prism)); \ No newline at end of file diff --git a/components/prism-soy.min.js b/components/prism-soy.min.js new file mode 100644 index 0000000000..a2d16c1779 --- /dev/null +++ b/components/prism-soy.min.js @@ -0,0 +1 @@ +!function(e){var a=/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,t=/\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|\b0x[\dA-F]+\b/;e.languages.soy={comment:[/\/\*[\s\S]*?\*\//,{pattern:/(\s)\/\/.*/,lookbehind:!0,greedy:!0}],"command-arg":{pattern:/({+\/?\s*(?:alias|call|delcall|delpackage|deltemplate|namespace|template)\s+)\.?[\w.]+/,lookbehind:!0,alias:"string",inside:{punctuation:/\./}},parameter:{pattern:/({+\/?\s*@?param\??\s+)\.?[\w.]+/,lookbehind:!0,alias:"variable"},keyword:[{pattern:/({+\/?[^\S\r\n]*)(?:\\[nrt]|alias|call|case|css|default|delcall|delpackage|deltemplate|else(?:if)?|fallbackmsg|for(?:each)?|if(?:empty)?|lb|let|literal|msg|namespace|nil|@?param\??|rb|sp|switch|template|xid)/,lookbehind:!0},/\b(?:any|as|attributes|bool|css|float|in|int|js|html|list|map|null|number|string|uri)\b/],delimiter:{pattern:/^{+\/?|\/?}+$/,alias:"punctuation"},property:/\w+(?==)/,variable:{pattern:/\$[^\W\d]\w*(?:\??(?:\.\w+|\[[^\]]+]))*/,inside:{string:{pattern:a,greedy:!0},number:t,punctuation:/[\[\].?]/}},string:{pattern:a,greedy:!0},"function":[/\w+(?=\()/,{pattern:/(\|[^\S\r\n]*)\w+/,lookbehind:!0}],"boolean":/\b(?:true|false)\b/,number:t,operator:/\?:?|<=?|>=?|==?|!=|[+*\/%-]|\b(?:and|not|or)\b/,punctuation:/[{}()\[\]|.,:]/},e.hooks.add("before-tokenize",function(a){var t=/{{.+?}}|{.+?}|\s\/\/.*|\/\*[\s\S]*?\*\//g,n="{literal}",l="{/literal}",r=!1;e.languages["markup-templating"].buildPlaceholders(a,"soy",t,function(e){return e===l&&(r=!1),r?!1:(e===n&&(r=!0),!0)})}),e.hooks.add("after-tokenize",function(a){e.languages["markup-templating"].tokenizePlaceholders(a,"soy")})}(Prism); \ No newline at end of file diff --git a/examples/prism-soy.html b/examples/prism-soy.html new file mode 100644 index 0000000000..648b8e5f91 --- /dev/null +++ b/examples/prism-soy.html @@ -0,0 +1,36 @@ +

Comments

+
/* Multi-line
+comment */
+// This is a comment with <p>some markup</p> in it
+ +

Variable

+
{$name}
+{$folders[0]['name']}
+{$aaa?.bbb.ccc?[0]}
+ +

Commands

+
{template .helloNames}
+  // Greet the person.
+  {call .helloName data="all" /}
+ // Greet the additional people. + {foreach $additionalName in $additionalNames} + {call .helloName} + {param name: $additionalName /} + {/call} + {if not isLast($additionalName)} + <br> // break after every line except the last + {/if} + {ifempty} + No additional people to greet. + {/foreach} +{/template}
+ +

Functions and print directives

+
{if length($items) > 5}
+{$foo|changeNewlineToBr}
+{$bar|truncate: 4, false}
+ +

Literal section

+
{literal}
+This is not a {$variable}
+{/literal}
\ No newline at end of file diff --git a/plugins/autoloader/prism-autoloader.js b/plugins/autoloader/prism-autoloader.js index 9648a24512..33190b0c79 100644 --- a/plugins/autoloader/prism-autoloader.js +++ b/plugins/autoloader/prism-autoloader.js @@ -4,7 +4,7 @@ } // The dependencies map is built automatically with gulp - var lang_dependencies = /*languages_placeholder[*/{"javascript":"clike","actionscript":"javascript","arduino":"cpp","aspnet":"markup","bison":"c","c":"clike","csharp":"clike","cpp":"c","coffeescript":"javascript","crystal":"ruby","css-extras":"css","d":"clike","dart":"clike","django":"markup","erb":["ruby","markup-templating"],"fsharp":"clike","flow":"javascript","glsl":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup-templating","haxe":"clike","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","markup-templating":"markup","n4js":"javascript","nginx":"clike","objectivec":"c","opencl":"cpp","parser":"markup","php":["clike","markup-templating"],"php-extras":"php","plsql":"sql","processing":"clike","protobuf":"clike","pug":"javascript","qore":"clike","jsx":["markup","javascript"],"tsx":["jsx","typescript"],"reason":"clike","ruby":"clike","sass":"css","scss":"css","scala":"java","smarty":"markup-templating","swift":"clike","textile":"markup","twig":"markup","typescript":"javascript","vbnet":"basic","velocity":"markup","wiki":"markup","xeora":"markup"}/*]*/; + var lang_dependencies = /*languages_placeholder[*/{"javascript":"clike","actionscript":"javascript","arduino":"cpp","aspnet":"markup","bison":"c","c":"clike","csharp":"clike","cpp":"c","coffeescript":"javascript","crystal":"ruby","css-extras":"css","d":"clike","dart":"clike","django":"markup","erb":["ruby","markup-templating"],"fsharp":"clike","flow":"javascript","glsl":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup-templating","haxe":"clike","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","markup-templating":"markup","n4js":"javascript","nginx":"clike","objectivec":"c","opencl":"cpp","parser":"markup","php":["clike","markup-templating"],"php-extras":"php","plsql":"sql","processing":"clike","protobuf":"clike","pug":"javascript","qore":"clike","jsx":["markup","javascript"],"tsx":["jsx","typescript"],"reason":"clike","ruby":"clike","sass":"css","scss":"css","scala":"java","smarty":"markup-templating","soy":"markup-templating","swift":"clike","textile":"markup","twig":"markup","typescript":"javascript","vbnet":"basic","velocity":"markup","wiki":"markup","xeora":"markup"}/*]*/; var lang_data = {}; diff --git a/plugins/autoloader/prism-autoloader.min.js b/plugins/autoloader/prism-autoloader.min.js index d74f147c36..f982f08af5 100644 --- a/plugins/autoloader/prism-autoloader.min.js +++ b/plugins/autoloader/prism-autoloader.min.js @@ -1 +1 @@ -!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var e={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:"markup",bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup",erb:["ruby","markup-templating"],fsharp:"clike",flow:"javascript",glsl:"clike",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",java:"clike",jolie:"clike",kotlin:"clike",less:"css",markdown:"markup","markup-templating":"markup",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"cpp",parser:"markup",php:["clike","markup-templating"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:"javascript",qore:"clike",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sass:"css",scss:"css",scala:"java",smarty:"markup-templating",swift:"clike",textile:"markup",twig:"markup",typescript:"javascript",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup"},a={},c="none",t=document.getElementsByTagName("script");t=t[t.length-1];var r="components/";if(t.hasAttribute("data-autoloader-path")){var s=t.getAttribute("data-autoloader-path").trim();s.length>0&&!/^[a-z]+:\/\//i.test(t.src)&&(r=s.replace(/\/?$/,"/"))}else/[\w-]+\.js$/.test(t.src)&&(r=t.src.replace(/[\w-]+\.js$/,"components/"));var n=Prism.plugins.autoloader={languages_path:r,use_minified:!0},t=function(e,a,c){var t=document.createElement("script");t.src=e,t.async=!0,t.onload=function(){document.body.removeChild(t),a&&a()},t.onerror=function(){document.body.removeChild(t),c&&c()},document.body.appendChild(t)},i=function(e){return n.languages_path+"prism-"+e+(n.use_minified?".min":"")+".js"},l=function(e,c){var t=a[e];t||(t=a[e]={});var r=c.getAttribute("data-dependencies");!r&&c.parentNode&&"pre"===c.parentNode.tagName.toLowerCase()&&(r=c.parentNode.getAttribute("data-dependencies")),r=r?r.split(/\s*,\s*/g):[],o(r,function(){p(e,function(){Prism.highlightElement(c)})})},o=function(e,a,c){"string"==typeof e&&(e=[e]);var t=0,r=e.length,s=function(){r>t?p(e[t],function(){t++,s()},function(){c&&c(e[t])}):t===r&&a&&a(e)};s()},p=function(c,r,s){var n=function(){var e=!1;c.indexOf("!")>=0&&(e=!0,c=c.replace("!",""));var n=a[c];if(n||(n=a[c]={}),r&&(n.success_callbacks||(n.success_callbacks=[]),n.success_callbacks.push(r)),s&&(n.error_callbacks||(n.error_callbacks=[]),n.error_callbacks.push(s)),!e&&Prism.languages[c])u(c);else if(!e&&n.error)m(c);else if(e||!n.loading){n.loading=!0;var l=i(c);t(l,function(){n.loading=!1,u(c)},function(){n.loading=!1,n.error=!0,m(c)})}},l=e[c];l&&l.length?o(l,n):n()},u=function(e){a[e]&&a[e].success_callbacks&&a[e].success_callbacks.length&&a[e].success_callbacks.forEach(function(a){a(e)})},m=function(e){a[e]&&a[e].error_callbacks&&a[e].error_callbacks.length&&a[e].error_callbacks.forEach(function(a){a(e)})};Prism.hooks.add("complete",function(e){e.element&&e.language&&!e.grammar&&e.language!==c&&l(e.language,e.element)})}}(); \ No newline at end of file +!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var e={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:"markup",bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup",erb:["ruby","markup-templating"],fsharp:"clike",flow:"javascript",glsl:"clike",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",java:"clike",jolie:"clike",kotlin:"clike",less:"css",markdown:"markup","markup-templating":"markup",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"cpp",parser:"markup",php:["clike","markup-templating"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:"javascript",qore:"clike",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sass:"css",scss:"css",scala:"java",smarty:"markup-templating",soy:"markup-templating",swift:"clike",textile:"markup",twig:"markup",typescript:"javascript",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup"},a={},c="none",t=document.getElementsByTagName("script");t=t[t.length-1];var r="components/";if(t.hasAttribute("data-autoloader-path")){var s=t.getAttribute("data-autoloader-path").trim();s.length>0&&!/^[a-z]+:\/\//i.test(t.src)&&(r=s.replace(/\/?$/,"/"))}else/[\w-]+\.js$/.test(t.src)&&(r=t.src.replace(/[\w-]+\.js$/,"components/"));var n=Prism.plugins.autoloader={languages_path:r,use_minified:!0},t=function(e,a,c){var t=document.createElement("script");t.src=e,t.async=!0,t.onload=function(){document.body.removeChild(t),a&&a()},t.onerror=function(){document.body.removeChild(t),c&&c()},document.body.appendChild(t)},i=function(e){return n.languages_path+"prism-"+e+(n.use_minified?".min":"")+".js"},l=function(e,c){var t=a[e];t||(t=a[e]={});var r=c.getAttribute("data-dependencies");!r&&c.parentNode&&"pre"===c.parentNode.tagName.toLowerCase()&&(r=c.parentNode.getAttribute("data-dependencies")),r=r?r.split(/\s*,\s*/g):[],o(r,function(){p(e,function(){Prism.highlightElement(c)})})},o=function(e,a,c){"string"==typeof e&&(e=[e]);var t=0,r=e.length,s=function(){r>t?p(e[t],function(){t++,s()},function(){c&&c(e[t])}):t===r&&a&&a(e)};s()},p=function(c,r,s){var n=function(){var e=!1;c.indexOf("!")>=0&&(e=!0,c=c.replace("!",""));var n=a[c];if(n||(n=a[c]={}),r&&(n.success_callbacks||(n.success_callbacks=[]),n.success_callbacks.push(r)),s&&(n.error_callbacks||(n.error_callbacks=[]),n.error_callbacks.push(s)),!e&&Prism.languages[c])u(c);else if(!e&&n.error)m(c);else if(e||!n.loading){n.loading=!0;var l=i(c);t(l,function(){n.loading=!1,u(c)},function(){n.loading=!1,n.error=!0,m(c)})}},l=e[c];l&&l.length?o(l,n):n()},u=function(e){a[e]&&a[e].success_callbacks&&a[e].success_callbacks.length&&a[e].success_callbacks.forEach(function(a){a(e)})},m=function(e){a[e]&&a[e].error_callbacks&&a[e].error_callbacks.length&&a[e].error_callbacks.forEach(function(a){a(e)})};Prism.hooks.add("complete",function(e){e.element&&e.language&&!e.grammar&&e.language!==c&&l(e.language,e.element)})}}(); \ No newline at end of file diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js index 2fc940ec8c..41647a8c72 100644 --- a/plugins/show-language/prism-show-language.js +++ b/plugins/show-language/prism-show-language.js @@ -11,7 +11,7 @@ if (!Prism.plugins.toolbar) { } // The languages map is built automatically with gulp -var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","arff":"ARFF","asciidoc":"AsciiDoc","asm6502":"6502 Assembly","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","autoit":"AutoIt","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","csp":"Content-Security-Policy","css-extras":"CSS Extras","django":"Django/Jinja2","erb":"ERB","fsharp":"F#","gedcom":"GEDCOM","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","hpkp":"HTTP Public-Key-Pins","hsts":"HTTP Strict-Transport-Security","ichigojam":"IchigoJam","inform7":"Inform 7","json":"JSON","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","markup-templating":"Markup templating","matlab":"MATLAB","mel":"MEL","n4js":"N4JS","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","opencl":"OpenCL","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","plsql":"PL/SQL","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","q":"Q (kdb+ database)","jsx":"React JSX","tsx":"React TSX","renpy":"Ren'py","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","visual-basic":"Visual Basic","wasm":"WebAssembly","wiki":"Wiki markup","xojo":"Xojo (REALbasic)","yaml":"YAML"}/*]*/; +var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","arff":"ARFF","asciidoc":"AsciiDoc","asm6502":"6502 Assembly","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","autoit":"AutoIt","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","csp":"Content-Security-Policy","css-extras":"CSS Extras","django":"Django/Jinja2","erb":"ERB","fsharp":"F#","gedcom":"GEDCOM","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","hpkp":"HTTP Public-Key-Pins","hsts":"HTTP Strict-Transport-Security","ichigojam":"IchigoJam","inform7":"Inform 7","json":"JSON","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","markup-templating":"Markup templating","matlab":"MATLAB","mel":"MEL","n4js":"N4JS","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","opencl":"OpenCL","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","plsql":"PL/SQL","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","q":"Q (kdb+ database)","jsx":"React JSX","tsx":"React TSX","renpy":"Ren'py","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","soy":"Soy (Closure Template)","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","visual-basic":"Visual Basic","wasm":"WebAssembly","wiki":"Wiki markup","xojo":"Xojo (REALbasic)","yaml":"YAML"}/*]*/; Prism.plugins.toolbar.registerButton('show-language', function(env) { var pre = env.element.parentNode; if (!pre || !/pre/i.test(pre.nodeName)) { diff --git a/plugins/show-language/prism-show-language.min.js b/plugins/show-language/prism-show-language.min.js index 2239ed2a2a..a6f3ce737a 100644 --- a/plugins/show-language/prism-show-language.min.js +++ b/plugins/show-language/prism-show-language.min.js @@ -1 +1 @@ -!function(){if("undefined"!=typeof self&&self.Prism&&self.document){if(!Prism.plugins.toolbar)return console.warn("Show Languages plugin loaded before Toolbar plugin."),void 0;var e={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",javascript:"JavaScript",abap:"ABAP",actionscript:"ActionScript",apacheconf:"Apache Configuration",apl:"APL",applescript:"AppleScript",arff:"ARFF",asciidoc:"AsciiDoc",asm6502:"6502 Assembly",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",autoit:"AutoIt",basic:"BASIC",csharp:"C#",cpp:"C++",coffeescript:"CoffeeScript",csp:"Content-Security-Policy","css-extras":"CSS Extras",django:"Django/Jinja2",erb:"ERB",fsharp:"F#",gedcom:"GEDCOM",glsl:"GLSL",graphql:"GraphQL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",inform7:"Inform 7",json:"JSON",latex:"LaTeX",livescript:"LiveScript",lolcode:"LOLCODE","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",n4js:"N4JS",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",php:"PHP","php-extras":"PHP Extras",plsql:"PL/SQL",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",q:"Q (kdb+ database)",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)",sql:"SQL",typescript:"TypeScript",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xojo:"Xojo (REALbasic)",yaml:"YAML"};Prism.plugins.toolbar.registerButton("show-language",function(t){var a=t.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s=a.getAttribute("data-language")||e[t.language]||t.language.substring(0,1).toUpperCase()+t.language.substring(1),i=document.createElement("span");return i.textContent=s,i}})}}(); \ No newline at end of file +!function(){if("undefined"!=typeof self&&self.Prism&&self.document){if(!Prism.plugins.toolbar)return console.warn("Show Languages plugin loaded before Toolbar plugin."),void 0;var e={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",javascript:"JavaScript",abap:"ABAP",actionscript:"ActionScript",apacheconf:"Apache Configuration",apl:"APL",applescript:"AppleScript",arff:"ARFF",asciidoc:"AsciiDoc",asm6502:"6502 Assembly",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",autoit:"AutoIt",basic:"BASIC",csharp:"C#",cpp:"C++",coffeescript:"CoffeeScript",csp:"Content-Security-Policy","css-extras":"CSS Extras",django:"Django/Jinja2",erb:"ERB",fsharp:"F#",gedcom:"GEDCOM",glsl:"GLSL",graphql:"GraphQL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",inform7:"Inform 7",json:"JSON",latex:"LaTeX",livescript:"LiveScript",lolcode:"LOLCODE","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",n4js:"N4JS",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",php:"PHP","php-extras":"PHP Extras",plsql:"PL/SQL",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",q:"Q (kdb+ database)",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)",sql:"SQL",soy:"Soy (Closure Template)",typescript:"TypeScript",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xojo:"Xojo (REALbasic)",yaml:"YAML"};Prism.plugins.toolbar.registerButton("show-language",function(t){var a=t.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s=a.getAttribute("data-language")||e[t.language]||t.language.substring(0,1).toUpperCase()+t.language.substring(1),i=document.createElement("span");return i.textContent=s,i}})}}(); \ No newline at end of file diff --git a/tests/languages/soy/boolean_feature.test b/tests/languages/soy/boolean_feature.test new file mode 100644 index 0000000000..9cc18f13d8 --- /dev/null +++ b/tests/languages/soy/boolean_feature.test @@ -0,0 +1,27 @@ +{param visible: true /} +{param visible:false/} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "visible"], + ["punctuation", ":"], + ["boolean", "true"], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "visible"], + ["punctuation", ":"], + ["boolean", "false"], + ["delimiter", "/}"] + ]] +] + +---------------------------------------------------- + +Checks for booleans. \ No newline at end of file diff --git a/tests/languages/soy/command-arg.test b/tests/languages/soy/command-arg.test new file mode 100644 index 0000000000..155dcd52be --- /dev/null +++ b/tests/languages/soy/command-arg.test @@ -0,0 +1,84 @@ +{alias long.namespace.root.projectx.foomodule.utils as fooUtils} +{call myfeature.myTemplate /} +{delcall aaa.bbb.myButton /} +{delpackage MyExperiment} +{deltemplate aaa.bbb.myButton} +{namespace ns} +{template .example} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "alias"], + ["command-arg", [ + "long", + ["punctuation", "."], "namespace", + ["punctuation", "."], "root", + ["punctuation", "."], "projectx", + ["punctuation", "."], "foomodule", + ["punctuation", "."], "utils" + ]], + ["keyword", "as"], + " fooUtils", + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "call"], + ["command-arg", [ + "myfeature", + ["punctuation", "."], "myTemplate" + ]], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "delcall"], + ["command-arg", [ + "aaa", + ["punctuation", "."], "bbb", + ["punctuation", "."], "myButton" + ]], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "delpackage"], + ["command-arg", [ + "MyExperiment" + ]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "deltemplate"], + ["command-arg", [ + "aaa", + ["punctuation", "."], "bbb", + ["punctuation", "."], "myButton" + ]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "namespace"], + ["command-arg", [ + "ns" + ]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "template"], + ["command-arg", [ + ["punctuation", "."], "example" + ]], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for command argument. \ No newline at end of file diff --git a/tests/languages/soy/comment_feature.test b/tests/languages/soy/comment_feature.test new file mode 100644 index 0000000000..8abf7b85cb --- /dev/null +++ b/tests/languages/soy/comment_feature.test @@ -0,0 +1,25 @@ +/**/ +/* Foo "bar" */ +/* Foo //bar +baz */ +// +// Foo /* bar */ +//
+/*
+
*/ + +---------------------------------------------------- + +[ + ["soy", [["comment", "/**/"]]], + ["soy", [["comment", "/* Foo \"bar\" */"]]], + ["soy", [["comment", "/* Foo //bar\r\nbaz */"]]], + ["soy", [["comment", "//"]]], + ["soy", [["comment", "// Foo /* bar */"]]], + ["soy", [["comment", "//
"]]], + ["soy", [["comment", "/*
\r\n
*/"]]] +] + +---------------------------------------------------- + +Checks for comments. \ No newline at end of file diff --git a/tests/languages/soy/function_feature.test b/tests/languages/soy/function_feature.test new file mode 100644 index 0000000000..3ba6df056f --- /dev/null +++ b/tests/languages/soy/function_feature.test @@ -0,0 +1,86 @@ +{if not isLast($additionalName)} +{if length($items) > 5} +{$x|noAutoescape} +{elseif round($pi) == 3} +{for $i in range($numLines)} +{$foo|changeNewLineToBr|bidiSpanWrap} +{$bar | truncate : 4 , false} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "if"], + ["operator", "not"], + ["function", "isLast"], + ["punctuation", "("], + ["variable", ["$additionalName"]], + ["punctuation", ")"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "if"], + ["function", "length"], + ["punctuation", "("], + ["variable", ["$items"]], + ["punctuation", ")"], + ["operator", ">"], + ["number", "5"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", ["$x"]], + ["punctuation", "|"], + ["function", "noAutoescape"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "elseif"], + ["function", "round"], + ["punctuation", "("], + ["variable", ["$pi"]], + ["punctuation", ")"], + ["operator", "=="], + ["number", "3"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "for"], + ["variable", ["$i"]], + ["keyword", "in"], + ["function", "range"], + ["punctuation", "("], + ["variable", ["$numLines"]], + ["punctuation", ")"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", ["$foo"]], + ["punctuation", "|"], + ["function", "changeNewLineToBr"], + ["punctuation", "|"], + ["function", "bidiSpanWrap"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", ["$bar"]], + ["punctuation", "|"], + ["function", "truncate"], + ["punctuation", ":"], + ["number", "4"], + ["punctuation", ","], + ["boolean", "false"], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for functions and print directives. \ No newline at end of file diff --git a/tests/languages/soy/keyword_feature.test b/tests/languages/soy/keyword_feature.test new file mode 100644 index 0000000000..a309b4f97c --- /dev/null +++ b/tests/languages/soy/keyword_feature.test @@ -0,0 +1,338 @@ +{\n} +{\r} +{\t} +{alias foo as bar} +{call} +{case} +{css} +{default} +{delcall} +{delpackage} +{deltemplate} +{else} +{elseif} +{fallbackmsg} +{for} +{foreach $i in $foo} +{if} +{ifempty} +{lb} +{let} +{literal}{/literal} +{msg} +{namespace} +{nil} +{param} +{@param} +{@param?} +{rb} +{sp} +{switch} +{template} +{xid} +{@param foo: any} +{@param foo: attributes} +{@param foo: bool} +{@param foo: css} +{@param foo: float} +{@param foo: int} +{@param foo: js} +{@param foo: html} +{@param foo: list} +{@param foo: map} +{@param foo: null} +{@param foo: number} +{@param foo: string} +{@param foo: uri} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "\\n"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "\\r"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "\\t"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "alias"], + ["command-arg", ["foo"]], + ["keyword", "as"], + " bar", + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "call"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "case"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "css"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "default"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "delcall"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "delpackage"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "deltemplate"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "else"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "elseif"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "fallbackmsg"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "for"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "foreach"], + ["variable", ["$i"]], + ["keyword", "in"], + ["variable", ["$foo"]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "if"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "ifempty"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "lb"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "literal"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{/"], + ["keyword", "literal"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "msg"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "namespace"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "nil"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param?"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "rb"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "sp"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "switch"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "template"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "xid"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "any"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "attributes"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "bool"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "css"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "float"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "int"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "js"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "html"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "list"], ["operator", "<"], ["keyword", "int"], ["operator", ">"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "map"], ["operator", "<"], ["keyword", "int"], ["punctuation", ","], ["keyword", "string"], ["operator", ">"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "null"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "number"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "string"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["keyword", "uri"], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for keywords. \ No newline at end of file diff --git a/tests/languages/soy/literal_feature.test b/tests/languages/soy/literal_feature.test new file mode 100644 index 0000000000..926ca05cc2 --- /dev/null +++ b/tests/languages/soy/literal_feature.test @@ -0,0 +1,73 @@ +{literal}{$noHighlight}{/literal} +{$highlight}{literal}
+{if $bar}{$bar}{/if}
+{/literal} +{literal}/* even comments */{/literal} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "literal"], + ["delimiter", "}"] + ]], + "{$noHighlight}", + ["soy", [ + ["delimiter", "{/"], + ["keyword", "literal"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", ["$highlight"]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "literal"], + ["delimiter", "}"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", ["class"]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + "{$foo}", + ["punctuation", "\""] + ]], + ["punctuation", ">"] + ]], + "\r\n{if $bar}{$bar}{/if}", + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + ["soy", [ + ["delimiter", "{/"], + ["keyword", "literal"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "literal"], + ["delimiter", "}"] + ]], + "/* even comments */", + ["soy", [ + ["delimiter", "{/"], + ["keyword", "literal"], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for {literal} command. \ No newline at end of file diff --git a/tests/languages/soy/number_feature.test b/tests/languages/soy/number_feature.test new file mode 100644 index 0000000000..3f852480fd --- /dev/null +++ b/tests/languages/soy/number_feature.test @@ -0,0 +1,63 @@ +{param foo: 42} +{param foo: 3.14159} +{param foo: 0.0} +{param foo: 7e+8} +{param foo: 2.5E-14} +{param foo: 0x42BADFACE} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["number", "42"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["number", "3.14159"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["number", "0.0"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["number", "7e+8"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["number", "2.5E-14"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "foo"], + ["punctuation", ":"], + ["number", "0x42BADFACE"], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for decimal and hexadecimal numbers. \ No newline at end of file diff --git a/tests/languages/soy/operator_feature.test b/tests/languages/soy/operator_feature.test new file mode 100644 index 0000000000..b37cd5066b --- /dev/null +++ b/tests/languages/soy/operator_feature.test @@ -0,0 +1,121 @@ +{let $foo: $a ? 0 : 1 /} +{let $foo: $a ?: 1 /} +{let $foo: 1 < 2 and 2 <= 3 /} +{let $foo: 1 > 2 or 2 >= 3 /} +{let $foo: 1 == 1 and 1 != 2 /} +{let $foo: ((1 + 2) / 3 * 4) % 5 - 6 /} +{let $foo: not $bar /} +{let $foo kind="text"} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$foo"]], + ["punctuation", ":"], + ["variable", ["$a"]], + ["operator", "?"], + ["number", "0"], + ["punctuation", ":"], + ["number", "1"], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$foo"]], + ["punctuation", ":"], + ["variable", ["$a"]], + ["operator", "?:"], + ["number", "1"], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$foo"]], + ["punctuation", ":"], + ["number", "1"], + ["operator", "<"], + ["number", "2"], + ["operator", "and"], + ["number", "2"], + ["operator", "<="], + ["number", "3"], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$foo"]], + ["punctuation", ":"], + ["number", "1"], + ["operator", ">"], + ["number", "2"], + ["operator", "or"], + ["number", "2"], + ["operator", ">="], + ["number", "3"], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$foo"]], + ["punctuation", ":"], + ["number", "1"], + ["operator", "=="], + ["number", "1"], + ["operator", "and"], + ["number", "1"], + ["operator", "!="], + ["number", "2"], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$foo"]], + ["punctuation", ":"], + ["punctuation", "("], + ["punctuation", "("], + ["number", "1"], + ["operator", "+"], + ["number", "2"], + ["punctuation", ")"], + ["operator", "/"], + ["number", "3"], + ["operator", "*"], + ["number", "4"], + ["punctuation", ")"], + ["operator", "%"], + ["number", "5"], + ["operator", "-"], + ["number", "6"], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$foo"]], + ["punctuation", ":"], + ["operator", "not"], + ["variable", ["$bar"]], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$foo"]], + ["property", "kind"], + ["operator", "="], + ["string", "\"text\""], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for operators. \ No newline at end of file diff --git a/tests/languages/soy/parameter_feature.test b/tests/languages/soy/parameter_feature.test new file mode 100644 index 0000000000..89263358f3 --- /dev/null +++ b/tests/languages/soy/parameter_feature.test @@ -0,0 +1,72 @@ +{param visible: true /} +{param content kind="html"} + {$message} +{/param} +{@param name: string} +{@param? height: int} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "visible"], + ["punctuation", ":"], + ["boolean", "true"], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "content"], + ["property", "kind"], + ["operator", "="], + ["string", "\"html\""], + ["delimiter", "}"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "b" + ]], + ["punctuation", ">"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", ["$message"]], + ["delimiter", "}"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + ["soy", [ + ["delimiter", "{/"], + ["keyword", "param"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param"], + ["parameter", "name"], + ["punctuation", ":"], + ["keyword", "string"], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "@param?"], + ["parameter", "height"], + ["punctuation", ":"], + ["keyword", "int"], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for parameters name. \ No newline at end of file diff --git a/tests/languages/soy/property_feature.test b/tests/languages/soy/property_feature.test new file mode 100644 index 0000000000..2c43149e0d --- /dev/null +++ b/tests/languages/soy/property_feature.test @@ -0,0 +1,54 @@ +{msg meaning="noun" desc="The word 'Archive' used as a noun, i.e. an information store."} +{param content kind="html"} +{let $message kind="text"} +{template .googleUri autoescape="strict" kind="uri"} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "msg"], + ["property", "meaning"], + ["operator", "="], + ["string", "\"noun\""], + ["property", "desc"], + ["operator", "="], + ["string", "\"The word 'Archive' used as a noun, i.e. an information store.\""], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "param"], + ["parameter", "content"], + ["property", "kind"], + ["operator", "="], + ["string", "\"html\""], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$message"]], + ["property", "kind"], + ["operator", "="], + ["string", "\"text\""], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "template"], + ["command-arg", [["punctuation", "."], "googleUri"]], + ["property", "autoescape"], + ["operator", "="], + ["string", "\"strict\""], + ["property", "kind"], + ["operator", "="], + ["string", "\"uri\""], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for command properties. \ No newline at end of file diff --git a/tests/languages/soy/soy_in_markup_feature.test b/tests/languages/soy/soy_in_markup_feature.test new file mode 100644 index 0000000000..bade0e21e3 --- /dev/null +++ b/tests/languages/soy/soy_in_markup_feature.test @@ -0,0 +1,68 @@ +
{$msg}
+
+ +___SOY1___{$foo} + +---------------------------------------------------- + +[ + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["punctuation", ">"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", ["$msg"]], + ["delimiter", "}"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", ["class"]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + ["soy", [ + ["delimiter", "{"], + ["variable", ["$msg"]], + ["delimiter", "}"] + ]], + ["punctuation", "\""] + ]], + ["punctuation", ">"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "h", + ["soy", [ + ["delimiter", "{"], + ["variable", ["$headingLevel"]], + ["delimiter", "}"] + ]] + ]], + ["punctuation", ">"] + ]], + "\r\n___SOY1___", + ["soy", [ + ["delimiter", "{"], + ["variable", ["$foo"]], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for Soy inside Markup. \ No newline at end of file diff --git a/tests/languages/soy/string_feature.test b/tests/languages/soy/string_feature.test new file mode 100644 index 0000000000..da1371a77e --- /dev/null +++ b/tests/languages/soy/string_feature.test @@ -0,0 +1,47 @@ +{msg desc=""} +{msg desc="Foo \"bar\" 'baz'"} +{$foo['bar\'baz\"\"\'']} +{{msg desc="Example: The set of prime numbers is {2, 3, 5, 7, 11, 13, ...}."}} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["keyword", "msg"], + ["property", "desc"], + ["operator", "="], + ["string", "\"\""], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "msg"], + ["property", "desc"], + ["operator", "="], + ["string", "\"Foo \\\"bar\\\" 'baz'\""], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", [ + "$foo", + ["punctuation", "["], + ["string", "'bar\\'baz\\\"\\\"\\''"], + ["punctuation", "]"] + ]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{{"], + ["keyword", "msg"], + ["property", "desc"], + ["operator", "="], + ["string", "\"Example: The set of prime numbers is {2, 3, 5, 7, 11, 13, ...}.\""], + ["delimiter", "}}"] + ]] +] + +---------------------------------------------------- + +Checks for strings. \ No newline at end of file diff --git a/tests/languages/soy/variable_feature.test b/tests/languages/soy/variable_feature.test new file mode 100644 index 0000000000..b6e180746d --- /dev/null +++ b/tests/languages/soy/variable_feature.test @@ -0,0 +1,86 @@ +{$name} +{$folders.0.name} +{$folders[0].name} +{$folders[0]['name']} +{$aaa?.bbb.ccc?[0]} +{let $category: $categoryList[0] /} +{let $isEnabled: $isAaa and not $isBbb and $ccc == $ddd + $eee /} + +---------------------------------------------------- + +[ + ["soy", [ + ["delimiter", "{"], + ["variable", ["$name"]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", [ + "$folders", + ["punctuation", "."], ["number", "0"], + ["punctuation", "."], "name" + ]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", [ + "$folders", + ["punctuation", "["], ["number", "0"], ["punctuation", "]"], + ["punctuation", "."], "name" + ]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", [ + "$folders", + ["punctuation", "["], ["number", "0"], ["punctuation", "]"], + ["punctuation", "["], ["string", "'name'"], ["punctuation", "]"] + ]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["variable", [ + "$aaa", ["punctuation", "?"], + ["punctuation", "."], "bbb", + ["punctuation", "."], "ccc", ["punctuation", "?"], + ["punctuation", "["], ["number", "0"], ["punctuation", "]"] + ]], + ["delimiter", "}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$category"]], + ["punctuation", ":"], + ["variable", [ + "$categoryList", + ["punctuation", "["], ["number", "0"], ["punctuation", "]"] + ]], + ["delimiter", "/}"] + ]], + ["soy", [ + ["delimiter", "{"], + ["keyword", "let"], + ["variable", ["$isEnabled"]], + ["punctuation", ":"], + ["variable", ["$isAaa"]], + ["operator", "and"], + ["operator", "not"], + ["variable", ["$isBbb"]], + ["operator", "and"], + ["variable", ["$ccc"]], + ["operator", "=="], + ["variable", ["$ddd"]], + ["operator", "+"], + ["variable", ["$eee"]], + ["delimiter", "/}"] + ]] +] + +---------------------------------------------------- + +Checks for variables. \ No newline at end of file