From acc0bc0944a14c2c225a8e7aa356a7e0ee4d3c52 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Sat, 18 Dec 2021 13:19:36 +0100 Subject: [PATCH] Smarty: Improved tokenization (#3268) --- components.js | 2 +- components.json | 1 + components/prism-smarty.js | 126 ++++--- components/prism-smarty.min.js | 2 +- tests/languages/smarty!+php/inclusion.test | 121 ++++++ tests/languages/smarty/attr-name_feature.test | 28 +- tests/languages/smarty/booelan_feature.test | 51 +++ tests/languages/smarty/comment_feature.test | 22 +- tests/languages/smarty/function_feature.test | 8 +- tests/languages/smarty/keyword_feature.test | 86 ++--- tests/languages/smarty/operator_feature.test | 34 +- tests/languages/smarty/php_feature.test | 81 ++++ .../languages/smarty/punctuation_feature.test | 33 ++ tests/languages/smarty/string_feature.test | 348 +++++++++++++++++- tests/languages/smarty/variable_feature.test | 82 ++++- 15 files changed, 885 insertions(+), 140 deletions(-) create mode 100644 tests/languages/smarty!+php/inclusion.test create mode 100644 tests/languages/smarty/booelan_feature.test create mode 100644 tests/languages/smarty/php_feature.test create mode 100644 tests/languages/smarty/punctuation_feature.test diff --git a/components.js b/components.js index d7476e6430..2984327d3a 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","ssml","atom","rss"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","ssml":"SSML","atom":"Atom","rss":"RSS"},"option":"default"},"css":{"title":"CSS","option":"default","modify":"markup"},"clike":{"title":"C-like","option":"default"},"javascript":{"title":"JavaScript","require":"clike","modify":"markup","optional":"regex","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"ABNF","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","modify":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"agda":{"title":"Agda","owner":"xy-ren"},"al":{"title":"AL","owner":"RunDevelopment"},"antlr4":{"title":"ANTLR4","alias":"g4","owner":"RunDevelopment"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apex":{"title":"Apex","require":["clike","sql"],"owner":"RunDevelopment"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","alias":"ino","owner":"dkern"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"asmatmel":{"title":"Atmel AVR Assembly","owner":"cerkit"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"avisynth":{"title":"AviSynth","alias":"avs","owner":"Zinfidel"},"avro-idl":{"title":"Avro IDL","alias":"avdl","owner":"RunDevelopment"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bbcode":{"title":"BBcode","alias":"shortcode","aliasTitles":{"shortcode":"Shortcode"},"owner":"RunDevelopment"},"bicep":{"title":"Bicep","owner":"johnnyreilly"},"birb":{"title":"Birb","require":"clike","owner":"Calamity210"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"BNF","alias":"rbnf","aliasTitles":{"rbnf":"RBNF"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"brightscript":{"title":"BrightScript","owner":"RunDevelopment"},"bro":{"title":"Bro","owner":"wayward710"},"bsl":{"title":"BSL (1C:Enterprise)","alias":"oscript","aliasTitles":{"oscript":"OneScript"},"owner":"Diversus23"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cfscript":{"title":"CFScript","require":"clike","alias":"cfc","owner":"mjclemente"},"chaiscript":{"title":"ChaiScript","require":["clike","cpp"],"owner":"RunDevelopment"},"cil":{"title":"CIL","owner":"sbrl"},"clojure":{"title":"Clojure","owner":"troglotit"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"cobol":{"title":"COBOL","owner":"RunDevelopment"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"concurnas":{"title":"Concurnas","alias":"conc","owner":"jasontatton"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"coq":{"title":"Coq","owner":"RunDevelopment"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"csv":{"title":"CSV","owner":"RunDevelopment"},"cypher":{"title":"Cypher","owner":"RunDevelopment"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"dataweave":{"title":"DataWeave","owner":"machaval"},"dax":{"title":"DAX","owner":"peterbud"},"dhall":{"title":"Dhall","owner":"RunDevelopment"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"dot":{"title":"DOT (Graphviz)","alias":"gv","optional":"markup","owner":"RunDevelopment"},"ebnf":{"title":"EBNF","owner":"RunDevelopment"},"editorconfig":{"title":"EditorConfig","owner":"osipxd"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment","alias":"eta","aliasTitles":{"eta":"Eta"}},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"etlua":{"title":"Embedded Lua templating","require":["lua","markup-templating"],"owner":"RunDevelopment"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"excel-formula":{"title":"Excel Formula","alias":["xlsx","xls"],"owner":"RunDevelopment"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"factor":{"title":"Factor","owner":"catb0t"},"false":{"title":"False","owner":"edukisto"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"ftl":{"title":"FreeMarker Template Language","require":"markup-templating","owner":"RunDevelopment"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"gap":{"title":"GAP (CAS)","owner":"RunDevelopment"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"c","owner":"Golmote"},"gn":{"title":"GN","alias":"gni","owner":"RunDevelopment"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"go-module":{"title":"Go module","alias":"go-mod","owner":"RunDevelopment"},"graphql":{"title":"GraphQL","optional":"markdown","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","optional":["css","css-extras","coffeescript","erb","javascript","less","markdown","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","alias":"hbs","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","optional":"regex","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"hlsl":{"title":"HLSL","require":"c","owner":"RunDevelopment"},"hoon":{"title":"Hoon","owner":"matildepark"},"http":{"title":"HTTP","optional":["css","javascript","json","markup","uri"],"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"},"icu-message-format":{"title":"ICU Message Format","owner":"RunDevelopment"},"idris":{"title":"Idris","alias":"idr","owner":"KeenS","require":"haskell"},"ignore":{"title":".ignore","owner":"osipxd","alias":["gitignore","hgignore","npmignore"],"aliasTitles":{"gitignore":".gitignore","hgignore":".hgignore","npmignore":".npmignore"}},"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"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"modify":"java","optional":"scala","owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","modify":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jexl":{"title":"Jexl","owner":"czosel"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike","typescript"],"modify":"javascript","optional":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","modify":"javascript","optional":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"json":{"title":"JSON","alias":"webmanifest","aliasTitles":{"webmanifest":"Web App Manifest"},"owner":"CupOfTea696"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"jsstacktrace":{"title":"JS stack trace","owner":"sbrl"},"js-templates":{"title":"JS Templates","require":"javascript","modify":"javascript","optional":["css","css-extras","graphql","markdown","markup","sql"],"owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keepalived":{"title":"Keepalived Configure","owner":"dev-itsheng"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","alias":["kt","kts"],"aliasTitles":{"kts":"Kotlin Script"},"require":"clike","owner":"Golmote"},"kumir":{"title":"KuMir (КуМир)","alias":"kum","owner":"edukisto"},"kusto":{"title":"Kusto","owner":"RunDevelopment"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"latte":{"title":"Latte","require":["clike","markup-templating","php"],"owner":"nette"},"less":{"title":"Less","require":"css","optional":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","require":"markup-templating","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"llvm":{"title":"LLVM IR","owner":"porglezomp"},"log":{"title":"Log file","optional":"javastacktrace","owner":"RunDevelopment"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"magma":{"title":"Magma (CAS)","owner":"RunDevelopment"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","optional":"yaml","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"maxscript":{"title":"MAXScript","owner":"RunDevelopment"},"mel":{"title":"MEL","owner":"Golmote"},"mermaid":{"title":"Mermaid","owner":"RunDevelopment"},"mizar":{"title":"Mizar","owner":"Golmote"},"mongodb":{"title":"MongoDB","owner":"airs0urce","require":"javascript"},"monkey":{"title":"Monkey","owner":"Golmote"},"moonscript":{"title":"MoonScript","alias":"moon","owner":"RunDevelopment"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","optional":"jsdoc","alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"naniscript":{"title":"Naninovel Script","owner":"Elringus","alias":"nani"},"nasm":{"title":"NASM","owner":"rbmj"},"neon":{"title":"NEON","owner":"nette"},"nevod":{"title":"Nevod","owner":"nezaboodka"},"nginx":{"title":"nginx","owner":"volado"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","alias":"objc","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"c","modify":["c","cpp"],"owner":"Milania1"},"openqasm":{"title":"OpenQasm","alias":"qasm","owner":"RunDevelopment"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"psl":{"title":"PATROL Scripting Language","owner":"bertysentry"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"peoplecode":{"title":"PeopleCode","alias":"pcode","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":"markup-templating","owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"modify":"php","owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","modify":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powerquery":{"title":"PowerQuery","alias":["pq","mscript"],"owner":"peterbud"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"promql":{"title":"PromQL","owner":"arendjr"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"optional":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","optional":["c","cpp","fortran"],"owner":"Golmote"},"purebasic":{"title":"PureBasic","require":"clike","alias":"pbfasm","owner":"HeX0R101"},"purescript":{"title":"PureScript","require":"haskell","alias":"purs","owner":"sriharshachilakapati"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"qsharp":{"title":"Q#","require":"clike","alias":"qs","owner":"fedonman"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qml":{"title":"QML","require":"javascript","owner":"RunDevelopment"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"racket":{"title":"Racket","require":"scheme","alias":"rkt","owner":"RunDevelopment"},"cshtml":{"title":"Razor C#","alias":"razor","require":["markup","csharp"],"optional":["css","css-extras","javascript","js-extras"],"owner":"RunDevelopment"},"jsx":{"title":"React JSX","require":["markup","javascript"],"optional":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","owner":"RunDevelopment"},"rego":{"title":"Rego","owner":"JordanSh"},"renpy":{"title":"Ren'py","alias":"rpy","owner":"HyuchiaDiego"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robotframework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","optional":["groovy","lua","sql"],"owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","optional":"css-extras","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","optional":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","alias":["sh-session","shellsession"],"owner":"RunDevelopment"},"smali":{"title":"Smali","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","owner":"Golmote"},"sml":{"title":"SML","alias":"smlnj","aliasTitles":{"smlnj":"SML/NJ"},"owner":"RunDevelopment"},"solidity":{"title":"Solidity (Ethereum)","alias":"sol","require":"clike","owner":"glachaud"},"solution-file":{"title":"Solution file","alias":"sln","owner":"RunDevelopment"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"sparql":{"title":"SPARQL","require":"turtle","owner":"Triply-Dev","alias":"rq"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","require":"clike","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"squirrel":{"title":"Squirrel","require":"clike","owner":"RunDevelopment"},"stan":{"title":"Stan","owner":"RunDevelopment"},"iecst":{"title":"Structured Text (IEC 61131-3)","owner":"serhioromano"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","owner":"chrischares"},"systemd":{"title":"Systemd configuration file","owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","vbnet"],"owner":"RunDevelopment"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"textile":{"title":"Textile","require":"markup","optional":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tremor":{"title":"Tremor","alias":["trickle","troy"],"owner":"darach","aliasTitles":{"trickle":"trickle","troy":"troy"}},"turtle":{"title":"Turtle","alias":"trig","aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup-templating","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","optional":"js-templates","alias":"ts","owner":"vkbansal"},"typoscript":{"title":"TypoScript","alias":"tsconfig","aliasTitles":{"tsconfig":"TSConfig"},"owner":"dkern"},"unrealscript":{"title":"UnrealScript","alias":["uscript","uc"],"owner":"RunDevelopment"},"uri":{"title":"URI","alias":"url","aliasTitles":{"url":"URL"},"owner":"RunDevelopment"},"v":{"title":"V","require":"clike","owner":"taggon"},"vala":{"title":"Vala","require":"clike","optional":"regex","owner":"TemplarVolk"},"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","alias":["vb","vba"],"aliasTitles":{"vba":"VBA"},"owner":"Golmote"},"warpscript":{"title":"WarpScript","owner":"RunDevelopment"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"web-idl":{"title":"Web IDL","alias":"webidl","owner":"RunDevelopment"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"wolfram":{"title":"Wolfram language","alias":["mathematica","nb","wl"],"aliasTitles":{"mathematica":"Mathematica","nb":"Mathematica Notebook"},"owner":"msollami"},"wren":{"title":"Wren","owner":"clsource"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xml-doc":{"title":"XML doc (.net)","require":"markup","modify":["csharp","fsharp","vbnet"],"owner":"RunDevelopment"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"yang":{"title":"YANG","owner":"RunDevelopment"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":{"title":"Line Highlight","description":"Highlights specific lines and/or line ranges."},"line-numbers":{"title":"Line Numbers","description":"Line number at the beginning of code lines.","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","description":"Show hidden characters such as tabs and line breaks.","optional":["autolinker","data-uri-highlight"]},"autolinker":{"title":"Autolinker","description":"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},"wpd":{"title":"WebPlatform Docs","description":"Makes tokens link to WebPlatform.org documentation. The links open in a new tab."},"custom-class":{"title":"Custom Class","description":"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","description":"Fetch external files and highlight them with Prism. Used on the Prism website itself.","noCSS":true},"show-language":{"title":"Show Language","description":"Display the highlighted language in code blocks (inline code does not show the label).","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","description":"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","description":"Adds special CSS classes for each keyword for fine-grained highlighting.","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","description":"Removes the initial line feed in code blocks.","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","description":"Adds a small inline preview for colors in style sheets.","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","description":"Previewers for angles, colors, gradients, easing and time.","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","description":"Automatically loads the needed languages to highlight the code blocks.","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","description":"Prevents custom markup from being dropped out during highlighting.","owner":"Golmote","optional":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","description":"Display a command line with a prompt and, optionally, the output/response from the commands.","owner":"chriswells0"},"unescaped-markup":{"title":"Unescaped Markup","description":"Write markup without having to escape anything."},"normalize-whitespace":{"title":"Normalize Whitespace","description":"Supports multiple operations to normalize whitespace in code blocks.","owner":"zeitgeist87","optional":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","description":"Highlights data-URI contents.","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","description":"Attach a toolbar for plugins to easily register buttons on the top of a code block.","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","description":"Add a button that copies the code block to the clipboard when clicked.","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","description":"A button in the toolbar of a code block adding a convenient way to download a code file.","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","description":"Highlights matching braces.","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","description":"Highlights the code inside diff blocks.","owner":"RunDevelopment","require":"diff"},"filter-highlight-all":{"title":"Filter highlightAll","description":"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.","owner":"RunDevelopment","noCSS":true},"treeview":{"title":"Treeview","description":"A language with special styles to highlight file system tree structures.","owner":"Golmote"}}}; +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","ssml","atom","rss"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","ssml":"SSML","atom":"Atom","rss":"RSS"},"option":"default"},"css":{"title":"CSS","option":"default","modify":"markup"},"clike":{"title":"C-like","option":"default"},"javascript":{"title":"JavaScript","require":"clike","modify":"markup","optional":"regex","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"ABNF","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","modify":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"agda":{"title":"Agda","owner":"xy-ren"},"al":{"title":"AL","owner":"RunDevelopment"},"antlr4":{"title":"ANTLR4","alias":"g4","owner":"RunDevelopment"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apex":{"title":"Apex","require":["clike","sql"],"owner":"RunDevelopment"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","alias":"ino","owner":"dkern"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"asmatmel":{"title":"Atmel AVR Assembly","owner":"cerkit"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"avisynth":{"title":"AviSynth","alias":"avs","owner":"Zinfidel"},"avro-idl":{"title":"Avro IDL","alias":"avdl","owner":"RunDevelopment"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bbcode":{"title":"BBcode","alias":"shortcode","aliasTitles":{"shortcode":"Shortcode"},"owner":"RunDevelopment"},"bicep":{"title":"Bicep","owner":"johnnyreilly"},"birb":{"title":"Birb","require":"clike","owner":"Calamity210"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"BNF","alias":"rbnf","aliasTitles":{"rbnf":"RBNF"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"brightscript":{"title":"BrightScript","owner":"RunDevelopment"},"bro":{"title":"Bro","owner":"wayward710"},"bsl":{"title":"BSL (1C:Enterprise)","alias":"oscript","aliasTitles":{"oscript":"OneScript"},"owner":"Diversus23"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cfscript":{"title":"CFScript","require":"clike","alias":"cfc","owner":"mjclemente"},"chaiscript":{"title":"ChaiScript","require":["clike","cpp"],"owner":"RunDevelopment"},"cil":{"title":"CIL","owner":"sbrl"},"clojure":{"title":"Clojure","owner":"troglotit"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"cobol":{"title":"COBOL","owner":"RunDevelopment"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"concurnas":{"title":"Concurnas","alias":"conc","owner":"jasontatton"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"coq":{"title":"Coq","owner":"RunDevelopment"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"csv":{"title":"CSV","owner":"RunDevelopment"},"cypher":{"title":"Cypher","owner":"RunDevelopment"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"dataweave":{"title":"DataWeave","owner":"machaval"},"dax":{"title":"DAX","owner":"peterbud"},"dhall":{"title":"Dhall","owner":"RunDevelopment"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"dot":{"title":"DOT (Graphviz)","alias":"gv","optional":"markup","owner":"RunDevelopment"},"ebnf":{"title":"EBNF","owner":"RunDevelopment"},"editorconfig":{"title":"EditorConfig","owner":"osipxd"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment","alias":"eta","aliasTitles":{"eta":"Eta"}},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"etlua":{"title":"Embedded Lua templating","require":["lua","markup-templating"],"owner":"RunDevelopment"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"excel-formula":{"title":"Excel Formula","alias":["xlsx","xls"],"owner":"RunDevelopment"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"factor":{"title":"Factor","owner":"catb0t"},"false":{"title":"False","owner":"edukisto"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"ftl":{"title":"FreeMarker Template Language","require":"markup-templating","owner":"RunDevelopment"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"gap":{"title":"GAP (CAS)","owner":"RunDevelopment"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"c","owner":"Golmote"},"gn":{"title":"GN","alias":"gni","owner":"RunDevelopment"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"go-module":{"title":"Go module","alias":"go-mod","owner":"RunDevelopment"},"graphql":{"title":"GraphQL","optional":"markdown","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","optional":["css","css-extras","coffeescript","erb","javascript","less","markdown","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","alias":"hbs","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","optional":"regex","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"hlsl":{"title":"HLSL","require":"c","owner":"RunDevelopment"},"hoon":{"title":"Hoon","owner":"matildepark"},"http":{"title":"HTTP","optional":["css","javascript","json","markup","uri"],"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"},"icu-message-format":{"title":"ICU Message Format","owner":"RunDevelopment"},"idris":{"title":"Idris","alias":"idr","owner":"KeenS","require":"haskell"},"ignore":{"title":".ignore","owner":"osipxd","alias":["gitignore","hgignore","npmignore"],"aliasTitles":{"gitignore":".gitignore","hgignore":".hgignore","npmignore":".npmignore"}},"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"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"modify":"java","optional":"scala","owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","modify":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jexl":{"title":"Jexl","owner":"czosel"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike","typescript"],"modify":"javascript","optional":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","modify":"javascript","optional":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"json":{"title":"JSON","alias":"webmanifest","aliasTitles":{"webmanifest":"Web App Manifest"},"owner":"CupOfTea696"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"jsstacktrace":{"title":"JS stack trace","owner":"sbrl"},"js-templates":{"title":"JS Templates","require":"javascript","modify":"javascript","optional":["css","css-extras","graphql","markdown","markup","sql"],"owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keepalived":{"title":"Keepalived Configure","owner":"dev-itsheng"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","alias":["kt","kts"],"aliasTitles":{"kts":"Kotlin Script"},"require":"clike","owner":"Golmote"},"kumir":{"title":"KuMir (КуМир)","alias":"kum","owner":"edukisto"},"kusto":{"title":"Kusto","owner":"RunDevelopment"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"latte":{"title":"Latte","require":["clike","markup-templating","php"],"owner":"nette"},"less":{"title":"Less","require":"css","optional":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","require":"markup-templating","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"llvm":{"title":"LLVM IR","owner":"porglezomp"},"log":{"title":"Log file","optional":"javastacktrace","owner":"RunDevelopment"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"magma":{"title":"Magma (CAS)","owner":"RunDevelopment"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","optional":"yaml","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"maxscript":{"title":"MAXScript","owner":"RunDevelopment"},"mel":{"title":"MEL","owner":"Golmote"},"mermaid":{"title":"Mermaid","owner":"RunDevelopment"},"mizar":{"title":"Mizar","owner":"Golmote"},"mongodb":{"title":"MongoDB","owner":"airs0urce","require":"javascript"},"monkey":{"title":"Monkey","owner":"Golmote"},"moonscript":{"title":"MoonScript","alias":"moon","owner":"RunDevelopment"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","optional":"jsdoc","alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"naniscript":{"title":"Naninovel Script","owner":"Elringus","alias":"nani"},"nasm":{"title":"NASM","owner":"rbmj"},"neon":{"title":"NEON","owner":"nette"},"nevod":{"title":"Nevod","owner":"nezaboodka"},"nginx":{"title":"nginx","owner":"volado"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","alias":"objc","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"c","modify":["c","cpp"],"owner":"Milania1"},"openqasm":{"title":"OpenQasm","alias":"qasm","owner":"RunDevelopment"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"psl":{"title":"PATROL Scripting Language","owner":"bertysentry"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"peoplecode":{"title":"PeopleCode","alias":"pcode","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":"markup-templating","owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"modify":"php","owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","modify":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powerquery":{"title":"PowerQuery","alias":["pq","mscript"],"owner":"peterbud"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"promql":{"title":"PromQL","owner":"arendjr"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"optional":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","optional":["c","cpp","fortran"],"owner":"Golmote"},"purebasic":{"title":"PureBasic","require":"clike","alias":"pbfasm","owner":"HeX0R101"},"purescript":{"title":"PureScript","require":"haskell","alias":"purs","owner":"sriharshachilakapati"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"qsharp":{"title":"Q#","require":"clike","alias":"qs","owner":"fedonman"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qml":{"title":"QML","require":"javascript","owner":"RunDevelopment"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"racket":{"title":"Racket","require":"scheme","alias":"rkt","owner":"RunDevelopment"},"cshtml":{"title":"Razor C#","alias":"razor","require":["markup","csharp"],"optional":["css","css-extras","javascript","js-extras"],"owner":"RunDevelopment"},"jsx":{"title":"React JSX","require":["markup","javascript"],"optional":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","owner":"RunDevelopment"},"rego":{"title":"Rego","owner":"JordanSh"},"renpy":{"title":"Ren'py","alias":"rpy","owner":"HyuchiaDiego"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robotframework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","optional":["groovy","lua","sql"],"owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","optional":"css-extras","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","optional":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","alias":["sh-session","shellsession"],"owner":"RunDevelopment"},"smali":{"title":"Smali","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","optional":"php","owner":"Golmote"},"sml":{"title":"SML","alias":"smlnj","aliasTitles":{"smlnj":"SML/NJ"},"owner":"RunDevelopment"},"solidity":{"title":"Solidity (Ethereum)","alias":"sol","require":"clike","owner":"glachaud"},"solution-file":{"title":"Solution file","alias":"sln","owner":"RunDevelopment"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"sparql":{"title":"SPARQL","require":"turtle","owner":"Triply-Dev","alias":"rq"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","require":"clike","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"squirrel":{"title":"Squirrel","require":"clike","owner":"RunDevelopment"},"stan":{"title":"Stan","owner":"RunDevelopment"},"iecst":{"title":"Structured Text (IEC 61131-3)","owner":"serhioromano"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","owner":"chrischares"},"systemd":{"title":"Systemd configuration file","owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","vbnet"],"owner":"RunDevelopment"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"textile":{"title":"Textile","require":"markup","optional":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tremor":{"title":"Tremor","alias":["trickle","troy"],"owner":"darach","aliasTitles":{"trickle":"trickle","troy":"troy"}},"turtle":{"title":"Turtle","alias":"trig","aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup-templating","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","optional":"js-templates","alias":"ts","owner":"vkbansal"},"typoscript":{"title":"TypoScript","alias":"tsconfig","aliasTitles":{"tsconfig":"TSConfig"},"owner":"dkern"},"unrealscript":{"title":"UnrealScript","alias":["uscript","uc"],"owner":"RunDevelopment"},"uri":{"title":"URI","alias":"url","aliasTitles":{"url":"URL"},"owner":"RunDevelopment"},"v":{"title":"V","require":"clike","owner":"taggon"},"vala":{"title":"Vala","require":"clike","optional":"regex","owner":"TemplarVolk"},"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","alias":["vb","vba"],"aliasTitles":{"vba":"VBA"},"owner":"Golmote"},"warpscript":{"title":"WarpScript","owner":"RunDevelopment"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"web-idl":{"title":"Web IDL","alias":"webidl","owner":"RunDevelopment"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"wolfram":{"title":"Wolfram language","alias":["mathematica","nb","wl"],"aliasTitles":{"mathematica":"Mathematica","nb":"Mathematica Notebook"},"owner":"msollami"},"wren":{"title":"Wren","owner":"clsource"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xml-doc":{"title":"XML doc (.net)","require":"markup","modify":["csharp","fsharp","vbnet"],"owner":"RunDevelopment"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"yang":{"title":"YANG","owner":"RunDevelopment"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":{"title":"Line Highlight","description":"Highlights specific lines and/or line ranges."},"line-numbers":{"title":"Line Numbers","description":"Line number at the beginning of code lines.","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","description":"Show hidden characters such as tabs and line breaks.","optional":["autolinker","data-uri-highlight"]},"autolinker":{"title":"Autolinker","description":"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},"wpd":{"title":"WebPlatform Docs","description":"Makes tokens link to WebPlatform.org documentation. The links open in a new tab."},"custom-class":{"title":"Custom Class","description":"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","description":"Fetch external files and highlight them with Prism. Used on the Prism website itself.","noCSS":true},"show-language":{"title":"Show Language","description":"Display the highlighted language in code blocks (inline code does not show the label).","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","description":"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","description":"Adds special CSS classes for each keyword for fine-grained highlighting.","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","description":"Removes the initial line feed in code blocks.","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","description":"Adds a small inline preview for colors in style sheets.","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","description":"Previewers for angles, colors, gradients, easing and time.","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","description":"Automatically loads the needed languages to highlight the code blocks.","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","description":"Prevents custom markup from being dropped out during highlighting.","owner":"Golmote","optional":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","description":"Display a command line with a prompt and, optionally, the output/response from the commands.","owner":"chriswells0"},"unescaped-markup":{"title":"Unescaped Markup","description":"Write markup without having to escape anything."},"normalize-whitespace":{"title":"Normalize Whitespace","description":"Supports multiple operations to normalize whitespace in code blocks.","owner":"zeitgeist87","optional":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","description":"Highlights data-URI contents.","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","description":"Attach a toolbar for plugins to easily register buttons on the top of a code block.","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","description":"Add a button that copies the code block to the clipboard when clicked.","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","description":"A button in the toolbar of a code block adding a convenient way to download a code file.","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","description":"Highlights matching braces.","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","description":"Highlights the code inside diff blocks.","owner":"RunDevelopment","require":"diff"},"filter-highlight-all":{"title":"Filter highlightAll","description":"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.","owner":"RunDevelopment","noCSS":true},"treeview":{"title":"Treeview","description":"A language with special styles to highlight file system tree structures.","owner":"Golmote"}}}; if (typeof module !== 'undefined' && module.exports) { module.exports = components; } \ No newline at end of file diff --git a/components.json b/components.json index 6a8e75281c..01aac511d0 100644 --- a/components.json +++ b/components.json @@ -1219,6 +1219,7 @@ "smarty": { "title": "Smarty", "require": "markup-templating", + "optional": "php", "owner": "Golmote" }, "sml": { diff --git a/components/prism-smarty.js b/components/prism-smarty.js index ec79668c3b..a49d103db4 100644 --- a/components/prism-smarty.js +++ b/components/prism-smarty.js @@ -1,23 +1,67 @@ -/* TODO - Add support for variables inside double quoted strings - Add support for {php} -*/ - (function (Prism) { Prism.languages.smarty = { - 'comment': /\{\*[\s\S]*?\*\}/, + 'comment': { + pattern: /^\{\*[\s\S]*?\*\}/, + greedy: true + }, + 'embedded-php': { + pattern: /^\{php\}[\s\S]*?\{\/php\}/, + greedy: true, + inside: { + 'smarty': { + pattern: /^\{php\}|\{\/php\}$/, + inside: null // see below + }, + 'php': { + pattern: /[\s\S]+/, + alias: 'language-php', + inside: Prism.languages.php + } + } + }, + 'string': [ + { + pattern: /"(?:\\.|[^"\\\r\n])*"/, + greedy: true, + inside: { + 'interpolation': { + pattern: /\{[^{}]*\}|`[^`]*`/, + inside: { + 'interpolation-punctuation': { + pattern: /^[{`]|[`}]$/, + alias: 'punctuation' + }, + 'expression': { + pattern: /[\s\S]+/, + inside: null // see below + } + } + }, + 'variable': /\$\w+/ + } + }, + { + pattern: /'(?:\\.|[^'\\\r\n])*'/, + greedy: true + }, + ], + 'keyword': { + pattern: /(^\{\/?)[a-z_]\w*\b(?!\()/i, + lookbehind: true, + greedy: true + }, 'delimiter': { - pattern: /^\{|\}$/, + pattern: /^\{\/?|\}$/, + greedy: true, alias: 'punctuation' }, - 'string': /(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/, 'number': /\b0x[\dA-Fa-f]+|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee][-+]?\d+)?/, 'variable': [ /\$(?!\d)\w+/, /#(?!\d)\w+#/, { - pattern: /(\.|->)(?!\d)\w+/, + pattern: /(\.|->|\w\s*=)(?!\d)\w+\b(?!\()/, lookbehind: true }, { @@ -25,52 +69,52 @@ lookbehind: true } ], - 'function': [ - { - pattern: /(\|\s*)@?(?!\d)\w+/, - lookbehind: true - }, - /^\/?(?!\d)\w+/, - /(?!\d)\w+(?=\()/ - ], - 'attr-name': { - // Value is made optional because it may have already been tokenized - pattern: /\w+\s*=\s*(?:(?!\d)\w+)?/, - inside: { - 'variable': { - pattern: /(=\s*)(?!\d)\w+/, - lookbehind: true - }, - 'operator': /=/ - } + 'function': { + pattern: /(\|\s*)@?[a-z_]\w*|\b[a-z_]\w*(?=\()/i, + lookbehind: true }, - 'punctuation': [ - /[\[\]().,:`]|->/ - ], + 'attr-name': /\b[a-z_]\w*(?=\s*=)/i, + 'boolean': /\b(?:false|no|off|on|true|yes)\b/, + 'punctuation': /[\[\](){}.,:`]|->/, 'operator': [ /[+\-*\/%]|==?=?|[!<>]=?|&&|\|\|?/, /\bis\s+(?:not\s+)?(?:div|even|odd)(?:\s+by)?\b/, /\b(?:and|eq|gt?e|gt|lt?e|lt|mod|neq?|not|or)\b/ - ], - 'keyword': /\b(?:false|no|off|on|true|yes)\b/ + ] }; + Prism.languages.smarty['embedded-php'].inside.smarty.inside = Prism.languages.smarty; + Prism.languages.smarty.string[0].inside.interpolation.inside.expression.inside = Prism.languages.smarty; + + var string = /"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'/; + var smartyPattern = RegExp( + // comments + /\{\*[\s\S]*?\*\}/.source + + '|' + + // php tags + /\{php\}[\s\S]*?\{\/php\}/.source + + '|' + + // smarty blocks + /\{(?:[^{}"']||\{(?:[^{}"']||\{(?:[^{}"']|)*\})*\})*\}/.source + .replace(//g, function () { return string.source; }), + 'g' + ); + // Tokenize all inline Smarty expressions Prism.hooks.add('before-tokenize', function (env) { - var smartyPattern = /\{\*[\s\S]*?\*\}|\{[\s\S]+?\}/g; - var smartyLitteralStart = '{literal}'; - var smartyLitteralEnd = '{/literal}'; - var smartyLitteralMode = false; + var smartyLiteralStart = '{literal}'; + var smartyLiteralEnd = '{/literal}'; + var smartyLiteralMode = false; Prism.languages['markup-templating'].buildPlaceholders(env, 'smarty', smartyPattern, function (match) { // Smarty tags inside {literal} block are ignored - if (match === smartyLitteralEnd) { - smartyLitteralMode = false; + if (match === smartyLiteralEnd) { + smartyLiteralMode = false; } - if (!smartyLitteralMode) { - if (match === smartyLitteralStart) { - smartyLitteralMode = true; + if (!smartyLiteralMode) { + if (match === smartyLiteralStart) { + smartyLiteralMode = true; } return true; diff --git a/components/prism-smarty.min.js b/components/prism-smarty.min.js index ef0b328a62..4651214a8a 100644 --- a/components/prism-smarty.min.js +++ b/components/prism-smarty.min.js @@ -1 +1 @@ -!function(n){n.languages.smarty={comment:/\{\*[\s\S]*?\*\}/,delimiter:{pattern:/^\{|\}$/,alias:"punctuation"},string:/(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,number:/\b0x[\dA-Fa-f]+|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee][-+]?\d+)?/,variable:[/\$(?!\d)\w+/,/#(?!\d)\w+#/,{pattern:/(\.|->)(?!\d)\w+/,lookbehind:!0},{pattern:/(\[)(?!\d)\w+(?=\])/,lookbehind:!0}],function:[{pattern:/(\|\s*)@?(?!\d)\w+/,lookbehind:!0},/^\/?(?!\d)\w+/,/(?!\d)\w+(?=\()/],"attr-name":{pattern:/\w+\s*=\s*(?:(?!\d)\w+)?/,inside:{variable:{pattern:/(=\s*)(?!\d)\w+/,lookbehind:!0},operator:/=/}},punctuation:[/[\[\]().,:`]|->/],operator:[/[+\-*\/%]|==?=?|[!<>]=?|&&|\|\|?/,/\bis\s+(?:not\s+)?(?:div|even|odd)(?:\s+by)?\b/,/\b(?:and|eq|gt?e|gt|lt?e|lt|mod|neq?|not|or)\b/],keyword:/\b(?:false|no|off|on|true|yes)\b/},n.hooks.add("before-tokenize",function(e){var t=!1;n.languages["markup-templating"].buildPlaceholders(e,"smarty",/\{\*[\s\S]*?\*\}|\{[\s\S]+?\}/g,function(e){return"{/literal}"===e&&(t=!1),!t&&("{literal}"===e&&(t=!0),!0)})}),n.hooks.add("after-tokenize",function(e){n.languages["markup-templating"].tokenizePlaceholders(e,"smarty")})}(Prism); \ No newline at end of file +!function(t){t.languages.smarty={comment:{pattern:/^\{\*[\s\S]*?\*\}/,greedy:!0},"embedded-php":{pattern:/^\{php\}[\s\S]*?\{\/php\}/,greedy:!0,inside:{smarty:{pattern:/^\{php\}|\{\/php\}$/,inside:null},php:{pattern:/[\s\S]+/,alias:"language-php",inside:t.languages.php}}},string:[{pattern:/"(?:\\.|[^"\\\r\n])*"/,greedy:!0,inside:{interpolation:{pattern:/\{[^{}]*\}|`[^`]*`/,inside:{"interpolation-punctuation":{pattern:/^[{`]|[`}]$/,alias:"punctuation"},expression:{pattern:/[\s\S]+/,inside:null}}},variable:/\$\w+/}},{pattern:/'(?:\\.|[^'\\\r\n])*'/,greedy:!0}],keyword:{pattern:/(^\{\/?)[a-z_]\w*\b(?!\()/i,lookbehind:!0,greedy:!0},delimiter:{pattern:/^\{\/?|\}$/,greedy:!0,alias:"punctuation"},number:/\b0x[\dA-Fa-f]+|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee][-+]?\d+)?/,variable:[/\$(?!\d)\w+/,/#(?!\d)\w+#/,{pattern:/(\.|->|\w\s*=)(?!\d)\w+\b(?!\()/,lookbehind:!0},{pattern:/(\[)(?!\d)\w+(?=\])/,lookbehind:!0}],function:{pattern:/(\|\s*)@?[a-z_]\w*|\b[a-z_]\w*(?=\()/i,lookbehind:!0},"attr-name":/\b[a-z_]\w*(?=\s*=)/i,boolean:/\b(?:false|no|off|on|true|yes)\b/,punctuation:/[\[\](){}.,:`]|->/,operator:[/[+\-*\/%]|==?=?|[!<>]=?|&&|\|\|?/,/\bis\s+(?:not\s+)?(?:div|even|odd)(?:\s+by)?\b/,/\b(?:and|eq|gt?e|gt|lt?e|lt|mod|neq?|not|or)\b/]},t.languages.smarty["embedded-php"].inside.smarty.inside=t.languages.smarty,t.languages.smarty.string[0].inside.interpolation.inside.expression.inside=t.languages.smarty;var e=/"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*'/,a=RegExp("\\{\\*[^]*?\\*\\}|\\{php\\}[^]*?\\{/php\\}|"+"\\{(?:[^{}\"']||\\{(?:[^{}\"']||\\{(?:[^{}\"']|)*\\})*\\})*\\}".replace(//g,function(){return e.source}),"g");t.hooks.add("before-tokenize",function(e){var n=!1;t.languages["markup-templating"].buildPlaceholders(e,"smarty",a,function(e){return"{/literal}"===e&&(n=!1),!n&&("{literal}"===e&&(n=!0),!0)})}),t.hooks.add("after-tokenize",function(e){t.languages["markup-templating"].tokenizePlaceholders(e,"smarty")})}(Prism); \ No newline at end of file diff --git a/tests/languages/smarty!+php/inclusion.test b/tests/languages/smarty!+php/inclusion.test new file mode 100644 index 0000000000..8f1b5e8d3c --- /dev/null +++ b/tests/languages/smarty!+php/inclusion.test @@ -0,0 +1,121 @@ +{php} + // including a php script directly from the template. + include('/path/to/display_weather.php'); +{/php} + +{* this template includes a {php} block that assign's the variable $varX *} +{php} + global $foo, $bar; + if($foo == $bar){ + echo 'This will be sent to browser'; + } + // assign a variable to Smarty + $this->assign('varX','Toffee'); +{/php} +{* output the variable *} +{$varX} is my fav ice cream :-) + +---------------------------------------------------- + +[ + ["smarty", [ + ["embedded-php", [ + ["smarty", [ + ["delimiter", "{"], + ["keyword", "php"], + ["delimiter", "}"] + ]], + ["php", [ + ["comment", "// including a php script directly from the template."], + + ["keyword", "include"], + ["punctuation", "("], + ["string", "'/path/to/display_weather.php'"], + ["punctuation", ")"], + ["punctuation", ";"] + ]], + ["smarty", [ + ["delimiter", "{/"], + ["keyword", "php"], + ["delimiter", "}"] + ]] + ]] + ]], + + ["smarty", [ + ["comment", "{* this template includes a {php} block that assign's the variable $varX *}"] + ]], + + ["smarty", [ + ["embedded-php", [ + ["smarty", [ + ["delimiter", "{"], + ["keyword", "php"], + ["delimiter", "}"] + ]], + ["php", [ + ["keyword", "global"], + ["variable", "$foo"], + ["punctuation", ","], + ["variable", "$bar"], + ["punctuation", ";"], + + ["keyword", "if"], + ["punctuation", "("], + ["variable", "$foo"], + ["operator", "=="], + ["variable", "$bar"], + ["punctuation", ")"], + ["punctuation", "{"], + + ["keyword", "echo"], + ["string", "'This will be sent to browser'"], + ["punctuation", ";"], + + ["punctuation", "}"], + + ["comment", "// assign a variable to Smarty"], + + ["variable", "$this"], + ["operator", "->"], + ["function", ["assign"]], + ["punctuation", "("], + ["string", "'varX'"], + ["punctuation", ","], + ["string", "'Toffee'"], + ["punctuation", ")"], + ["punctuation", ";"] + ]], + ["smarty", [ + ["delimiter", "{/"], + ["keyword", "php"], + ["delimiter", "}"] + ]] + ]] + ]], + + ["smarty", [ + ["comment", "{* output the variable *}"] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "strong" + ]], + ["punctuation", ">"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["variable", "$varX"], + ["delimiter", "}"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + " is my fav ice cream :-)" +] diff --git a/tests/languages/smarty/attr-name_feature.test b/tests/languages/smarty/attr-name_feature.test index 11697a5b4d..354dce89d7 100644 --- a/tests/languages/smarty/attr-name_feature.test +++ b/tests/languages/smarty/attr-name_feature.test @@ -6,26 +6,20 @@ [ ["smarty", [ ["delimiter", "{"], - ["function", "assign"], - ["attr-name", [ - "var", - ["operator", "="], - ["variable", "foo"] - ]], - ["attr-name", [ - "value", - ["operator", "="] - ]], - ["string", "\"bar\""], + ["keyword", "assign"], + ["attr-name", "var"], + ["operator", "="], + ["variable", "foo"], + ["attr-name", "value"], + ["operator", "="], + ["string", ["\"bar\""]], ["delimiter", "}"] ]], ["smarty", [ ["delimiter", "{"], - ["function", "foo"], - ["attr-name", [ - "bar ", - ["operator", "="] - ]], + ["keyword", "foo"], + ["attr-name", "bar"], + ["operator", "="], ["number", "40"], ["delimiter", "}"] ]] @@ -33,4 +27,4 @@ ---------------------------------------------------- -Checks for attributes. \ No newline at end of file +Checks for attributes. diff --git a/tests/languages/smarty/booelan_feature.test b/tests/languages/smarty/booelan_feature.test new file mode 100644 index 0000000000..12b777689d --- /dev/null +++ b/tests/languages/smarty/booelan_feature.test @@ -0,0 +1,51 @@ +{if false} +{if off} +{if on} +{if no} +{if true} +{if yes} + +---------------------------------------------------- + +[ + ["smarty", [ + ["delimiter", "{"], + ["keyword", "if"], + ["boolean", "false"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["keyword", "if"], + ["boolean", "off"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["keyword", "if"], + ["boolean", "on"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["keyword", "if"], + ["boolean", "no"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["keyword", "if"], + ["boolean", "true"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["keyword", "if"], + ["boolean", "yes"], + ["delimiter", "}"] + ]] +] + +---------------------------------------------------- + +Checks for keywords. diff --git a/tests/languages/smarty/comment_feature.test b/tests/languages/smarty/comment_feature.test index 616ed1fc9d..9106d4efc9 100644 --- a/tests/languages/smarty/comment_feature.test +++ b/tests/languages/smarty/comment_feature.test @@ -2,13 +2,29 @@ {* foo bar *} +{* you cannot nest comments *} +{* {* foo *} *} + ---------------------------------------------------- [ - ["smarty", [["comment", "{**}"]]], - ["smarty", [["comment", "{* foo\r\nbar *}"]]] + ["smarty", [ + ["comment", "{**}"] + ]], + ["smarty", [ + ["comment", "{* foo\r\nbar *}"] + ]], + + ["smarty", [ + ["comment", "{* you cannot nest comments *}"] + ]], + + ["smarty", [ + ["comment", "{* {* foo *}"] + ]], + " *}" ] ---------------------------------------------------- -Checks for comments. \ No newline at end of file +Checks for comments. diff --git a/tests/languages/smarty/function_feature.test b/tests/languages/smarty/function_feature.test index e138bb9493..51e0df99de 100644 --- a/tests/languages/smarty/function_feature.test +++ b/tests/languages/smarty/function_feature.test @@ -8,7 +8,7 @@ [ ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["function", "count"], ["punctuation", "("], ["variable", "$foo"], @@ -30,12 +30,12 @@ ["delimiter", "}"] ]], ["smarty", [ - ["delimiter", "{"], - ["function", "/if"], + ["delimiter", "{/"], + ["keyword", "if"], ["delimiter", "}"] ]] ] ---------------------------------------------------- -Checks for tags, filters and functions. \ No newline at end of file +Checks for tags, filters and functions. diff --git a/tests/languages/smarty/keyword_feature.test b/tests/languages/smarty/keyword_feature.test index 0f714f2fa4..8d5de3ebb4 100644 --- a/tests/languages/smarty/keyword_feature.test +++ b/tests/languages/smarty/keyword_feature.test @@ -1,51 +1,35 @@ -{if false} -{if off} -{if on} -{if no} -{if true} -{if yes} - ----------------------------------------------------- - -[ - ["smarty", [ - ["delimiter", "{"], - ["function", "if"], - ["keyword", "false"], - ["delimiter", "}"] - ]], - ["smarty", [ - ["delimiter", "{"], - ["function", "if"], - ["keyword", "off"], - ["delimiter", "}"] - ]], - ["smarty", [ - ["delimiter", "{"], - ["function", "if"], - ["keyword", "on"], - ["delimiter", "}"] - ]], - ["smarty", [ - ["delimiter", "{"], - ["function", "if"], - ["keyword", "no"], - ["delimiter", "}"] - ]], - ["smarty", [ - ["delimiter", "{"], - ["function", "if"], - ["keyword", "true"], - ["delimiter", "}"] - ]], - ["smarty", [ - ["delimiter", "{"], - ["function", "if"], - ["keyword", "yes"], - ["delimiter", "}"] - ]] -] - ----------------------------------------------------- - -Checks for keywords. \ No newline at end of file +{if count($foo)} +{/if} + +{* PHP function *} +{time()} + +---------------------------------------------------- + +[ + ["smarty", [ + ["delimiter", "{"], + ["keyword", "if"], + ["function", "count"], + ["punctuation", "("], + ["variable", "$foo"], + ["punctuation", ")"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{/"], + ["keyword", "if"], + ["delimiter", "}"] + ]], + + ["smarty", [ + ["comment", "{* PHP function *}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["function", "time"], + ["punctuation", "("], + ["punctuation", ")"], + ["delimiter", "}"] + ]] +] diff --git a/tests/languages/smarty/operator_feature.test b/tests/languages/smarty/operator_feature.test index c296fa3f1a..725a01446f 100644 --- a/tests/languages/smarty/operator_feature.test +++ b/tests/languages/smarty/operator_feature.test @@ -17,7 +17,7 @@ [ ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["variable", "$a"], ["operator", "+"], ["variable", "$b"], @@ -29,7 +29,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["variable", "$e"], ["operator", "*"], ["variable", "$f"], @@ -43,7 +43,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["variable", "$j"], ["operator", "<"], ["variable", "$k"], @@ -63,7 +63,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["operator", "!"], ["variable", "$r"], ["operator", "!="], @@ -76,7 +76,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["variable", "$v"], ["operator", "is not even by"], ["number", "3"], @@ -87,7 +87,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["variable", "$w"], ["operator", "is div by"], ["number", "2"], @@ -99,7 +99,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["variable", "$x"], ["operator", "is not odd"], ["operator", "or"], @@ -110,7 +110,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["variable", "$y"], ["operator", "ne"], ["variable", "$z"], @@ -122,7 +122,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["variable", "$c"], ["operator", "gt"], ["variable", "$d"], @@ -134,7 +134,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["variable", "$g"], ["operator", "gte"], ["variable", "$h"], @@ -154,7 +154,7 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "if"], + ["keyword", "if"], ["operator", "not"], ["variable", "$o"], ["operator", "and"], @@ -165,12 +165,10 @@ ]], ["smarty", [ ["delimiter", "{"], - ["function", "foo"], - ["attr-name", [ - "bar", - ["operator", "="], - ["variable", "baz"] - ]], + ["keyword", "foo"], + ["attr-name", "bar"], + ["operator", "="], + ["variable", "baz"], ["delimiter", "}"] ]], ["smarty", [ @@ -184,4 +182,4 @@ ---------------------------------------------------- -Checks for all operators. \ No newline at end of file +Checks for all operators. diff --git a/tests/languages/smarty/php_feature.test b/tests/languages/smarty/php_feature.test new file mode 100644 index 0000000000..e529763bdb --- /dev/null +++ b/tests/languages/smarty/php_feature.test @@ -0,0 +1,81 @@ +{php} + // including a php script directly from the template. + include('/path/to/display_weather.php'); +{/php} + +{* this template includes a {php} block that assign's the variable $varX *} +{php} + global $foo, $bar; + if($foo == $bar){ + echo 'This will be sent to browser'; + } + // assign a variable to Smarty + $this->assign('varX','Toffee'); +{/php} +{* output the variable *} +{$varX} is my fav ice cream :-) + +---------------------------------------------------- + +[ + ["smarty", [ + ["embedded-php", [ + ["smarty", [ + ["delimiter", "{"], + ["keyword", "php"], + ["delimiter", "}"] + ]], + ["php", "\r\n // including a php script directly from the template.\r\n include('/path/to/display_weather.php');\r\n"], + ["smarty", [ + ["delimiter", "{/"], + ["keyword", "php"], + ["delimiter", "}"] + ]] + ]] + ]], + + ["smarty", [ + ["comment", "{* this template includes a {php} block that assign's the variable $varX *}"] + ]], + + ["smarty", [ + ["embedded-php", [ + ["smarty", [ + ["delimiter", "{"], + ["keyword", "php"], + ["delimiter", "}"] + ]], + ["php", "\r\n global $foo, $bar;\r\n if($foo == $bar){\r\n echo 'This will be sent to browser';\r\n }\r\n // assign a variable to Smarty\r\n $this->assign('varX','Toffee');\r\n"], + ["smarty", [ + ["delimiter", "{/"], + ["keyword", "php"], + ["delimiter", "}"] + ]] + ]] + ]], + + ["smarty", [ + ["comment", "{* output the variable *}"] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "strong" + ]], + ["punctuation", ">"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["variable", "$varX"], + ["delimiter", "}"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + " is my fav ice cream :-)" +] diff --git a/tests/languages/smarty/punctuation_feature.test b/tests/languages/smarty/punctuation_feature.test new file mode 100644 index 0000000000..ca485e887f --- /dev/null +++ b/tests/languages/smarty/punctuation_feature.test @@ -0,0 +1,33 @@ +{foo + +( ) [ ] { } +. : , +` +-> + +} + +---------------------------------------------------- + +[ + ["smarty", [ + ["delimiter", "{"], ["keyword", "foo"], + + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "["], + ["punctuation", "]"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["punctuation", "."], + ["punctuation", ":"], + ["punctuation", ","], + + ["punctuation", "`"], + + ["punctuation", "->"], + + ["delimiter", "}"] + ]] +] diff --git a/tests/languages/smarty/string_feature.test b/tests/languages/smarty/string_feature.test index 31f6e79576..d39e92aad2 100644 --- a/tests/languages/smarty/string_feature.test +++ b/tests/languages/smarty/string_feature.test @@ -2,18 +2,45 @@ {"fo\"obar"} {''} {'fo\'obar'} +{$foo="this is message {counter}"} + +{func var="test $foo test"} // sees $foo +{func var="test $foo_bar test"} // sees $foo_bar +{func var="test `$foo[0]` test"} // sees $foo[0] +{func var="test `$foo[bar]` test"} // sees $foo[bar] +{func var="test $foo.bar test"} // sees $foo (not $foo.bar) +{func var="test `$foo.bar` test"} // sees $foo.bar +{func var="test `$foo.bar` test"|escape} // modifiers outside quotes! +{func var="test {$foo|escape} test"} // modifiers inside quotes! +{func var="test {time()} test"} // PHP function result +{func var="test {counter} test"} // plugin result + +{* will replace $tpl_name with value *} +{include file="subdir/$tpl_name.tpl"} + +{* does NOT replace $tpl_name *} +{include file='subdir/$tpl_name.tpl'} // vars require double quotes! + +{* must have backticks as it contains a dot "." *} +{cycle values="one,two,`$smarty.config.myval`"} + +{* must have backticks as it contains a dot "." *} +{include file="`$module.contact`.tpl"} + +{* can use variable with dot syntax *} +{include file="`$module.$view`.tpl"} ---------------------------------------------------- [ ["smarty", [ ["delimiter", "{"], - ["string", "\"\""], + ["string", ["\"\""]], ["delimiter", "}"] ]], ["smarty", [ ["delimiter", "{"], - ["string", "\"fo\\\"obar\""], + ["string", ["\"fo\\\"obar\""]], ["delimiter", "}"] ]], ["smarty", [ @@ -25,9 +52,324 @@ ["delimiter", "{"], ["string", "'fo\\'obar'"], ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["variable", "$foo"], + ["operator", "="], + ["string", [ + "\"this is message ", + ["interpolation", [ + ["interpolation-punctuation", "{"], + ["expression", ["counter"]], + ["interpolation-punctuation", "}"] + ]], + "\"" + ]], + ["delimiter", "}"] + ]], + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["variable", "$foo"], + " test\"" + ]], + ["delimiter", "}"] + ]], + " // sees $foo\r\n", + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["variable", "$foo_bar"], + " test\"" + ]], + ["delimiter", "}"] + ]], + " // sees $foo_bar\r\n", + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["interpolation", [ + ["interpolation-punctuation", "`"], + ["expression", [ + ["variable", "$foo"], + ["punctuation", "["], + ["number", "0"], + ["punctuation", "]"] + ]], + ["interpolation-punctuation", "`"] + ]], + " test\"" + ]], + ["delimiter", "}"] + ]], + " // sees $foo[0]\r\n", + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["interpolation", [ + ["interpolation-punctuation", "`"], + ["expression", [ + ["variable", "$foo"], + ["punctuation", "["], + ["variable", "bar"], + ["punctuation", "]"] + ]], + ["interpolation-punctuation", "`"] + ]], + " test\"" + ]], + ["delimiter", "}"] + ]], + " // sees $foo[bar]\r\n", + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["variable", "$foo"], + ".bar test\"" + ]], + ["delimiter", "}"] + ]], + " // sees $foo (not $foo.bar)\r\n", + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["interpolation", [ + ["interpolation-punctuation", "`"], + ["expression", [ + ["variable", "$foo"], + ["punctuation", "."], + ["variable", "bar"] + ]], + ["interpolation-punctuation", "`"] + ]], + " test\"" + ]], + ["delimiter", "}"] + ]], + " // sees $foo.bar\r\n", + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["interpolation", [ + ["interpolation-punctuation", "`"], + ["expression", [ + ["variable", "$foo"], + ["punctuation", "."], + ["variable", "bar"] + ]], + ["interpolation-punctuation", "`"] + ]], + " test\"" + ]], + ["operator", "|"], + ["function", "escape"], + ["delimiter", "}"] + ]], + " // modifiers outside quotes!\r\n", + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["interpolation", [ + ["interpolation-punctuation", "{"], + ["expression", [ + ["variable", "$foo"], + ["operator", "|"], + ["function", "escape"] + ]], + ["interpolation-punctuation", "}"] + ]], + " test\"" + ]], + ["delimiter", "}"] + ]], + " // modifiers inside quotes!\r\n", + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["interpolation", [ + ["interpolation-punctuation", "{"], + ["expression", [ + ["function", "time"], + ["punctuation", "("], + ["punctuation", ")"] + ]], + ["interpolation-punctuation", "}"] + ]], + " test\"" + ]], + ["delimiter", "}"] + ]], + " // PHP function result\r\n", + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "func"], + ["attr-name", "var"], + ["operator", "="], + ["string", [ + "\"test ", + ["interpolation", [ + ["interpolation-punctuation", "{"], + ["expression", ["counter"]], + ["interpolation-punctuation", "}"] + ]], + " test\"" + ]], + ["delimiter", "}"] + ]], + " // plugin result\r\n\r\n", + + ["smarty", [ + ["comment", "{* will replace $tpl_name with value *}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["keyword", "include"], + ["attr-name", "file"], + ["operator", "="], + ["string", [ + "\"subdir/", + ["variable", "$tpl_name"], + ".tpl\"" + ]], + ["delimiter", "}"] + ]], + + ["smarty", [ + ["comment", "{* does NOT replace $tpl_name *}"] + ]], + + ["smarty", [ + ["delimiter", "{"], + ["keyword", "include"], + ["attr-name", "file"], + ["operator", "="], + ["string", "'subdir/$tpl_name.tpl'"], + ["delimiter", "}"] + ]], + " // vars require double quotes!\r\n\r\n", + + ["smarty", [ + ["comment", "{* must have backticks as it contains a dot \".\" *}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["keyword", "cycle"], + ["attr-name", "values"], + ["operator", "="], + ["string", [ + "\"one,two,", + ["interpolation", [ + ["interpolation-punctuation", "`"], + ["expression", [ + ["variable", "$smarty"], + ["punctuation", "."], + ["variable", "config"], + ["punctuation", "."], + ["variable", "myval"] + ]], + ["interpolation-punctuation", "`"] + ]], + "\"" + ]], + ["delimiter", "}"] + ]], + + ["smarty", [ + ["comment", "{* must have backticks as it contains a dot \".\" *}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["keyword", "include"], + ["attr-name", "file"], + ["operator", "="], + ["string", [ + "\"", + ["interpolation", [ + ["interpolation-punctuation", "`"], + ["expression", [ + ["variable", "$module"], + ["punctuation", "."], + ["variable", "contact"] + ]], + ["interpolation-punctuation", "`"] + ]], + ".tpl\"" + ]], + ["delimiter", "}"] + ]], + + ["smarty", [ + ["comment", "{* can use variable with dot syntax *}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["keyword", "include"], + ["attr-name", "file"], + ["operator", "="], + ["string", [ + "\"", + ["interpolation", [ + ["interpolation-punctuation", "`"], + ["expression", [ + ["variable", "$module"], + ["punctuation", "."], + ["variable", "$view"] + ]], + ["interpolation-punctuation", "`"] + ]], + ".tpl\"" + ]], + ["delimiter", "}"] ]] ] ---------------------------------------------------- -Checks for strings. \ No newline at end of file +Checks for strings. diff --git a/tests/languages/smarty/variable_feature.test b/tests/languages/smarty/variable_feature.test index c2db9b4683..c30eeaec5f 100644 --- a/tests/languages/smarty/variable_feature.test +++ b/tests/languages/smarty/variable_feature.test @@ -4,6 +4,12 @@ {$foo.bar.baz} {$foo->bar->baz} {$foo[row]} +{$foo[$x+$x]} +{$foo.a.$b.c} +{$foo.a.{$b+4}.c} +{$foo.a.{$b.c}} +{$foo={counter}+3} +{$foo->bar($baz,2,$bar)} ---------------------------------------------------- @@ -48,9 +54,83 @@ ["variable", "row"], ["punctuation", "]"], ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["variable", "$foo"], + ["punctuation", "["], + ["variable", "$x"], + ["operator", "+"], + ["variable", "$x"], + ["punctuation", "]"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["variable", "$foo"], + ["punctuation", "."], + ["variable", "a"], + ["punctuation", "."], + ["variable", "$b"], + ["punctuation", "."], + ["variable", "c"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["variable", "$foo"], + ["punctuation", "."], + ["variable", "a"], + ["punctuation", "."], + ["punctuation", "{"], + ["variable", "$b"], + ["operator", "+"], + ["number", "4"], + ["punctuation", "}"], + ["punctuation", "."], + ["variable", "c"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["variable", "$foo"], + ["punctuation", "."], + ["variable", "a"], + ["punctuation", "."], + ["punctuation", "{"], + ["variable", "$b"], + ["punctuation", "."], + ["variable", "c"], + ["punctuation", "}"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["variable", "$foo"], + ["operator", "="], + ["punctuation", "{"], + "counter", + ["punctuation", "}"], + ["operator", "+"], + ["number", "3"], + ["delimiter", "}"] + ]], + ["smarty", [ + ["delimiter", "{"], + ["variable", "$foo"], + ["punctuation", "->"], + ["function", "bar"], + ["punctuation", "("], + ["variable", "$baz"], + ["punctuation", ","], + ["number", "2"], + ["punctuation", ","], + ["variable", "$bar"], + ["punctuation", ")"], + ["delimiter", "}"] ]] ] ---------------------------------------------------- -Checks for variables. \ No newline at end of file +Checks for variables.