From dca74bb84f2c9f2ca6a8643990d8f6def966c056 Mon Sep 17 00:00:00 2001 From: Golmote Date: Thu, 5 Apr 2018 08:21:59 +0200 Subject: [PATCH] Add support for Velocity. Fix #1372 --- components.js | 2 +- components.json | 5 + components/prism-velocity.js | 72 +++ components/prism-velocity.min.js | 1 + examples/prism-velocity.html | 47 ++ plugins/autoloader/prism-autoloader.js | 2 +- plugins/autoloader/prism-autoloader.min.js | 2 +- .../languages/velocity/directive_feature.test | 417 ++++++++++++++++++ .../languages/velocity/unparsed_feature.test | 29 ++ .../languages/velocity/variable_feature.test | 147 ++++++ .../velocity/velocity-comment_feature.test | 18 + 11 files changed, 739 insertions(+), 3 deletions(-) create mode 100644 components/prism-velocity.js create mode 100644 components/prism-velocity.min.js create mode 100644 examples/prism-velocity.html create mode 100644 tests/languages/velocity/directive_feature.test create mode 100644 tests/languages/velocity/unparsed_feature.test create mode 100644 tests/languages/velocity/variable_feature.test create mode 100644 tests/languages/velocity/velocity-comment_feature.test diff --git a/components.js b/components.js index 8858f0fe59..45af69a97b 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"},"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"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"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"},"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"},"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 c276ef6529..b05fb2321f 100644 --- a/components.json +++ b/components.json @@ -658,6 +658,11 @@ "require": "basic", "owner": "Bigsby" }, + "velocity": { + "title": "Velocity", + "require": "markup", + "owner": "Golmote" + }, "verilog": { "title": "Verilog", "owner": "a-rey" diff --git a/components/prism-velocity.js b/components/prism-velocity.js new file mode 100644 index 0000000000..d2bbe05349 --- /dev/null +++ b/components/prism-velocity.js @@ -0,0 +1,72 @@ +(function (Prism) { + Prism.languages.velocity = Prism.languages.extend('markup', {}); + + var velocity = { + 'variable': { + pattern: /(^|[^\\](?:\\\\)*)\$!?(?:[a-z][\w-]*(?:\([^)]*\))?(?:\.[a-z][\w-]*(?:\([^)]*\))?|\[[^\]]+])*|{[^}]+})/i, + lookbehind: true, + inside: {} // See below + }, + 'string': { + pattern: /"[^"]*"|'[^']*'/, + greedy: true + }, + 'number': /\b\d+\b/, + 'boolean': /\b(?:true|false)\b/, + 'operator': /[=!<>]=?|[+*/%-]|&&|\|\||\.\.|\b(?:eq|g[et]|l[et]|n(?:e|ot))\b/, + 'punctuation': /[(){}[\]:,.]/ + }; + + velocity.variable.inside = { + 'string': velocity['string'], + 'function': { + pattern: /([^\w-])[a-z][\w-]*(?=\()/, + lookbehind: true + }, + 'number': velocity['number'], + 'boolean': velocity['boolean'], + 'punctuation': velocity['punctuation'] + }; + + Prism.languages.insertBefore('velocity', 'comment', { + 'unparsed': { + pattern: /(^|[^\\])#\[\[[\s\S]*?]]#/, + lookbehind: true, + greedy: true, + inside: { + 'punctuation': /^#\[\[|]]#$/ + } + }, + 'velocity-comment': [ + { + pattern: /(^|[^\\])#\*[\s\S]*?\*#/, + lookbehind: true, + greedy: true, + alias: 'comment' + }, + { + pattern: /(^|[^\\])##.*/, + lookbehind: true, + greedy: true, + alias: 'comment' + } + ], + 'directive': { + pattern: /(^|[^\\](?:\\\\)*)#@?(?:[a-z][\w-]*|{[a-z][\w-]*})(?:\s*\((?:[^()]|\([^()]*\))*\))?/i, + lookbehind: true, + inside: { + keyword: { + pattern: /^#@?(?:[a-z][\w-]*|{[a-z][\w-]*})|\bin\b/, + inside: { + 'punctuation': /[{}]/ + } + }, + rest: velocity + } + }, + 'variable': velocity['variable'] + }); + + Prism.languages.velocity['tag'].inside['attr-value'].inside.rest = Prism.languages.velocity; + +}(Prism)); \ No newline at end of file diff --git a/components/prism-velocity.min.js b/components/prism-velocity.min.js new file mode 100644 index 0000000000..d0c1c07619 --- /dev/null +++ b/components/prism-velocity.min.js @@ -0,0 +1 @@ +!function(e){e.languages.velocity=e.languages.extend("markup",{});var n={variable:{pattern:/(^|[^\\](?:\\\\)*)\$!?(?:[a-z][\w-]*(?:\([^)]*\))?(?:\.[a-z][\w-]*(?:\([^)]*\))?|\[[^\]]+])*|{[^}]+})/i,lookbehind:!0,inside:{}},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},number:/\b\d+\b/,"boolean":/\b(?:true|false)\b/,operator:/[=!<>]=?|[+*\/%-]|&&|\|\||\.\.|\b(?:eq|g[et]|l[et]|n(?:e|ot))\b/,punctuation:/[(){}[\]:,.]/};n.variable.inside={string:n.string,"function":{pattern:/([^\w-])[a-z][\w-]*(?=\()/,lookbehind:!0},number:n.number,"boolean":n["boolean"],punctuation:n.punctuation},e.languages.insertBefore("velocity","comment",{unparsed:{pattern:/(^|[^\\])#\[\[[\s\S]*?]]#/,lookbehind:!0,greedy:!0,inside:{punctuation:/^#\[\[|]]#$/}},"velocity-comment":[{pattern:/(^|[^\\])#\*[\s\S]*?\*#/,lookbehind:!0,greedy:!0,alias:"comment"},{pattern:/(^|[^\\])##.*/,lookbehind:!0,greedy:!0,alias:"comment"}],directive:{pattern:/(^|[^\\](?:\\\\)*)#@?(?:[a-z][\w-]*|{[a-z][\w-]*})(?:\s*\((?:[^()]|\([^()]*\))*\))?/i,lookbehind:!0,inside:{keyword:{pattern:/^#@?(?:[a-z][\w-]*|{[a-z][\w-]*})|\bin\b/,inside:{punctuation:/[{}]/}},rest:n}},variable:n.variable}),e.languages.velocity.tag.inside["attr-value"].inside.rest=e.languages.velocity}(Prism); \ No newline at end of file diff --git a/examples/prism-velocity.html b/examples/prism-velocity.html new file mode 100644 index 0000000000..a97fa05e1b --- /dev/null +++ b/examples/prism-velocity.html @@ -0,0 +1,47 @@ +

Comments

+
## Single line comment
+#* Multi-line
+comment *#
+ +

Unparsed sections

+
## Section below is not parsed
+#[[
+	## This is not a comment
+]]#
+ +

Variables

+
$mud
+$customer.Name
+$flogger.getPromo( $mud )
+$!{mudSlinger_9}
+$foo[0]
+$foo[$i]
+$foo["bar"]
+$foo.bar[1].junk
+$foo.callMethod()[1]
+ +

Directives

+
#set($foo.bar[1] = 3)
+#if($a==1)true enough#{else}no way!#end
+#macro( d )
+<tr><td>$!bodyContent</td></tr>
+#end
+#@d()Hello!#end
+ +

Integration with HTML

+
<html>
+  <body>
+    Hello $customer.Name!
+    <table>
+    #foreach( $mud in $mudsOnSpecial )
+      #if ( $customer.hasPurchased($mud) )
+        <tr>
+          <td>
+            $flogger.getPromo( $mud )
+          </td>
+        </tr>
+      #end
+    #end
+    </table>
+  </body>
+</html>
\ No newline at end of file diff --git a/plugins/autoloader/prism-autoloader.js b/plugins/autoloader/prism-autoloader.js index a8765dad1d..9648a24512 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","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","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 9aa920f232..d74f147c36 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",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",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/tests/languages/velocity/directive_feature.test b/tests/languages/velocity/directive_feature.test new file mode 100644 index 0000000000..463722e2af --- /dev/null +++ b/tests/languages/velocity/directive_feature.test @@ -0,0 +1,417 @@ +#foreach($mud in $mudsOnSpecial) +#if($customer.hasPurchased($mud)) +#set($a = "Velocity") +#set($foo.bar[1] = 3) +#{set}($map["apple"] = "orange") +#if($foo == $bar)#end +#if (!$foo)#end +#if ($foo && $foo.bar)#end +#{if}($foo1 || $foo2)#end +#set( $monkey.Say = ["Not", $my, "fault"] ) +#set( $monkey.Map = {"banana" : "good", "roast beef" : "bad"}) +#set( $result = $query.criteria("address") ) +#set( $result = true ) +#set( $result = false ) +#if( $foo < 10 ) +#elseif( $foo == 10 ) +#else +#end +#if( $foo == $bar)it's true!#{else}it's not!#end +#include( "greetings.txt", $seasonalstock ) +#parse( "me.vm" ) +#{parse}( "me.vm" ) +#break +#{break} +#break($macro.topmost) +#stop('$foo was not in context') +#{stop} +#evaluate($dynamicsource) +#macro( d ) + +#end +#d() +#@d()Hello!#end +\#include( "a.txt" ) +\\#include ( "a.txt" ) +#set($foo=["$10 and ","a pie"])#foreach($a in $foo)$a#end +#set( $foo = $bar + 3 ) +#set( $foo = $bar - 4 ) +#set( $foo = $bar * 6 ) +#set( $foo = $bar / 2 ) +#set( $foo = $bar % 5 ) +#foreach( $foo in [1..5] ) + +---------------------------------------------------- + +[ + ["directive", [ + ["keyword", ["#foreach"]], + ["punctuation", "("], + ["variable", ["$mud"]], + ["keyword", ["in"]], + ["variable", ["$mudsOnSpecial"]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#if"]], + ["punctuation", "("], + ["variable", [ + "$customer", + ["punctuation", "."], + ["function", "hasPurchased"], + ["punctuation", "("], + "$mud", + ["punctuation", ")"] + ]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$a"]], + ["operator", "="], + ["string", "\"Velocity\""], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", [ + "$foo", + ["punctuation", "."], + "bar", + ["punctuation", "["], + ["number", "1"], + ["punctuation", "]"] + ]], + ["operator", "="], + ["number", "3"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#", ["punctuation", "{"], "set", ["punctuation", "}"]]], + ["punctuation", "("], + ["variable", [ + "$map", + ["punctuation", "["], + ["string", "\"apple\""], + ["punctuation", "]"] + ]], + ["operator", "="], + ["string", "\"orange\""], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#if"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "=="], + ["variable", ["$bar"]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#end"]] + ]], + ["directive", [ + ["keyword", ["#if"]], + ["punctuation", "("], + ["operator", "!"], + ["variable", ["$foo"]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#end"]] + ]], + ["directive", [ + ["keyword", ["#if"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "&&"], + ["variable", ["$foo", ["punctuation", "."], "bar"]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#end"]] + ]], + ["directive", [ + ["keyword", ["#", ["punctuation", "{"], "if", ["punctuation", "}"]]], + ["punctuation", "("], + ["variable", ["$foo1"]], + ["operator", "||"], + ["variable", ["$foo2"]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#end"]] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$monkey", ["punctuation", "."], "Say"]], + ["operator", "="], + ["punctuation", "["], + ["string", "\"Not\""], + ["punctuation", ","], + ["variable", ["$my"]], + ["punctuation", ","], + ["string", "\"fault\""], + ["punctuation", "]"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$monkey", ["punctuation", "."], "Map"]], + ["operator", "="], + ["punctuation", "{"], + ["string", "\"banana\""], + ["punctuation", ":"], + ["string", "\"good\""], + ["punctuation", ","], + ["string", "\"roast beef\""], + ["punctuation", ":"], + ["string", "\"bad\""], + ["punctuation", "}"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$result"]], + ["operator", "="], + ["variable", [ + "$query", + ["punctuation", "."], + ["function", "criteria"], + ["punctuation", "("], + ["string", "\"address\""], + ["punctuation", ")"] + ]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$result"]], + ["operator", "="], + ["boolean", "true"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$result"]], + ["operator", "="], + ["boolean", "false"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#if"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "<"], + ["number", "10"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#elseif"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "=="], + ["number", "10"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#else"]] + ]], + ["directive", [ + ["keyword", ["#end"]] + ]], + ["directive", [ + ["keyword", ["#if"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "=="], + ["variable", ["$bar"]], + ["punctuation", ")"] + ]], + "it's true!", + ["directive", [ + ["keyword", ["#", ["punctuation", "{"], "else", ["punctuation", "}"]]] + ]], + "it's not!", + ["directive", [ + ["keyword", ["#end"]] + ]], + ["directive", [ + ["keyword", ["#include"]], + ["punctuation", "("], + ["string", "\"greetings.txt\""], + ["punctuation", ","], + ["variable", ["$seasonalstock"]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#parse"]], + ["punctuation", "("], + ["string", "\"me.vm\""], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#", ["punctuation", "{"], "parse", ["punctuation", "}"]]], + ["punctuation", "("], + ["string", "\"me.vm\""], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#break"]] + ]], + ["directive", [ + ["keyword", ["#", ["punctuation", "{"], "break", ["punctuation", "}"]]] + ]], + ["directive", [ + ["keyword", ["#break"]], + ["punctuation", "("], + ["variable", ["$macro", ["punctuation", "."], "topmost"]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#stop"]], + ["punctuation", "("], + ["string", "'$foo was not in context'"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#", ["punctuation", "{"], "stop", ["punctuation", "}"]]] + ]], + ["directive", [ + ["keyword", ["#evaluate"]], + ["punctuation", "("], + ["variable", ["$dynamicsource"]], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#macro"]], + ["punctuation", "("], + " d ", + ["punctuation", ")"] + ]], + ["tag", [["tag", [["punctuation", "<"], "tr"]], ["punctuation", ">"]]], + ["tag", [["tag", [["punctuation", "<"], "td"]], ["punctuation", ">"]]], + ["tag", [["tag", [["punctuation", ""]]], + ["tag", [["tag", [["punctuation", ""]]], + ["directive", [ + ["keyword", ["#end"]] + ]], + ["directive", [ + ["keyword", ["#d"]], + ["punctuation", "("], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#@d"]], + ["punctuation", "("], + ["punctuation", ")"] + ]], + "Hello!", + ["directive", [ + ["keyword", ["#end"]] + ]], + "\r\n\\#include( \"a.txt\" )\r\n\\\\", + ["directive", [ + ["keyword", ["#include"]], + ["punctuation", "("], + ["string", "\"a.txt\""], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "="], + ["punctuation", "["], + ["string", "\"$10 and \""], + ["punctuation", ","], + ["string", "\"a pie\""], + ["punctuation", "]"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#foreach"]], + ["punctuation", "("], + ["variable", ["$a"]], + ["keyword", ["in"]], + ["variable", ["$foo"]], + ["punctuation", ")"] + ]], + ["variable", ["$a"]], + ["directive", [ + ["keyword", ["#end"]] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "="], + ["variable", ["$bar"]], + ["operator", "+"], + ["number", "3"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "="], + ["variable", ["$bar"]], + ["operator", "-"], + ["number", "4"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "="], + ["variable", ["$bar"]], + ["operator", "*"], + ["number", "6"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "="], + ["variable", ["$bar"]], + ["operator", "/"], + ["number", "2"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#set"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["operator", "="], + ["variable", ["$bar"]], + ["operator", "%"], + ["number", "5"], + ["punctuation", ")"] + ]], + ["directive", [ + ["keyword", ["#foreach"]], + ["punctuation", "("], + ["variable", ["$foo"]], + ["keyword", ["in"]], + ["punctuation", "["], + ["number", "1"], + ["operator", ".."], + ["number", "5"], + ["punctuation", "]"], + ["punctuation", ")"] + ]] +] + +---------------------------------------------------- + +Checks for directives. \ No newline at end of file diff --git a/tests/languages/velocity/unparsed_feature.test b/tests/languages/velocity/unparsed_feature.test new file mode 100644 index 0000000000..32dc1f58ce --- /dev/null +++ b/tests/languages/velocity/unparsed_feature.test @@ -0,0 +1,29 @@ +#[[]]# +#[[This is not parsed]]# +#[[#if("some quotes" 'some quotes') +## #* *# +$dollar +]]# + +---------------------------------------------------- + +[ + ["unparsed", [ + ["punctuation", "#[["], + ["punctuation", "]]#"] + ]], + ["unparsed", [ + ["punctuation", "#[["], + "This is not parsed", + ["punctuation", "]]#"] + ]], + ["unparsed", [ + ["punctuation", "#[["], + "#if(\"some quotes\" 'some quotes')\r\n## #* *#\r\n$dollar\r\n", + ["punctuation", "]]#"] + ]] +] + +---------------------------------------------------- + +Checks for unparsed sections. \ No newline at end of file diff --git a/tests/languages/velocity/variable_feature.test b/tests/languages/velocity/variable_feature.test new file mode 100644 index 0000000000..fcff8cc912 --- /dev/null +++ b/tests/languages/velocity/variable_feature.test @@ -0,0 +1,147 @@ +$mud +$customer.Name +$flogger.getPromo( $mud ) +$mud-slinger +$mud_slinger +$mudSlinger1 +$!mudSlinger_9 +$person.setAttributes( ["Strange", false, "Excited"] ) +$foo[0] +$foo[$i] +$foo["bar"] +$foo.bar[1].junk +$foo.callMethod()[1] +$foo["apple"][4] +${mudSlinger} +$!{mudSlinger_9} +${customer.Address} +${purchase.getTotal()} + + +$\!foo +$\!{foo} +$\\!foo +$\\\!foo +\$foo +\$!foo +\$!{foo} +\\$!{foo} + +---------------------------------------------------- + +[ + ["variable", ["$mud"]], + ["variable", ["$customer", ["punctuation", "."], "Name"]], + ["variable", [ + "$flogger", + ["punctuation", "."], + ["function", "getPromo"], + ["punctuation", "("], + " $mud ", + ["punctuation", ")"] + ]], + ["variable", ["$mud-slinger"]], + ["variable", ["$mud_slinger"]], + ["variable", ["$mudSlinger1"]], + ["variable", ["$!mudSlinger_9"]], + ["variable", [ + "$person", + ["punctuation", "."], + ["function", "setAttributes"], + ["punctuation", "("], + ["punctuation", "["], + ["string", "\"Strange\""], + ["punctuation", ","], + ["boolean", "false"], + ["punctuation", ","], + ["string", "\"Excited\""], + ["punctuation", "]"], + ["punctuation", ")"] + ]], + ["variable", ["$foo", ["punctuation", "["], ["number", "0"], ["punctuation", "]"]]], + ["variable", ["$foo", ["punctuation", "["], "$i", ["punctuation", "]"]]], + ["variable", ["$foo", ["punctuation", "["], ["string", "\"bar\""], ["punctuation", "]"]]], + ["variable", [ + "$foo", + ["punctuation", "."], + "bar", + ["punctuation", "["], + ["number", "1"], + ["punctuation", "]"], + ["punctuation", "."], + "junk" + ]], + ["variable", [ + "$foo", + ["punctuation", "."], + ["function", "callMethod"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "["], + ["number", "1"], + ["punctuation", "]"] + ]], + ["variable", [ + "$foo", + ["punctuation", "["], + ["string", "\"apple\""], + ["punctuation", "]"], + ["punctuation", "["], + ["number", "4"], + ["punctuation", "]"] + ]], + ["variable", ["$", ["punctuation", "{"], "mudSlinger", ["punctuation", "}"]]], + ["variable", ["$!", ["punctuation", "{"], "mudSlinger_9", ["punctuation", "}"]]], + ["variable", [ + "$", + ["punctuation", "{"], + "customer", + ["punctuation", "."], + "Address", + ["punctuation", "}"] + ]], + ["variable", [ + "$", + ["punctuation", "{"], + "purchase", + ["punctuation", "."], + ["function", "getTotal"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "}"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "input" + ]], + ["attr-name", ["value"]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + ["variable", ["$email"]], + ["punctuation", "\""] + ]], + ["punctuation", "/>"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "input" + ]], + ["attr-name", ["value"]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + ["variable", ["$!", ["punctuation", "{"], "email", ["punctuation", "}"]]], + ["punctuation", "\""] + ]], + ["punctuation", "/>"] + ]], + "\r\n$\\!foo\r\n$\\!{foo}\r\n$\\\\!foo\r\n$\\\\\\!foo\r\n\\$foo\r\n\\$!foo\r\n\\$!{foo}\r\n\\\\", + ["variable", ["$!", ["punctuation", "{"], "foo", ["punctuation", "}"]]] +] + +---------------------------------------------------- + +Checks for variables. \ No newline at end of file diff --git a/tests/languages/velocity/velocity-comment_feature.test b/tests/languages/velocity/velocity-comment_feature.test new file mode 100644 index 0000000000..0b66639e35 --- /dev/null +++ b/tests/languages/velocity/velocity-comment_feature.test @@ -0,0 +1,18 @@ +#**# +#*Multiline
+comment*# +## +## Single line comment
+ +---------------------------------------------------- + +[ + ["velocity-comment", "#**#"], + ["velocity-comment", "#*Multiline
\r\ncomment*#"], + ["velocity-comment", "##"], + ["velocity-comment", "## Single line comment
"] +] + +---------------------------------------------------- + +Checks for comments. \ No newline at end of file