From 061650b1fc9f495115f0e85b04b464640e819b41 Mon Sep 17 00:00:00 2001 From: taggon Date: Sat, 2 Jan 2021 02:15:46 +0900 Subject: [PATCH 1/7] Add support for V langauge --- components.js | 2 +- components.json | 5 + components/prism-v.js | 54 ++++++++++ components/prism-v.min.js | 1 + examples/prism-v.html | 91 +++++++++++++++++ plugins/autoloader/prism-autoloader.js | 1 + plugins/autoloader/prism-autoloader.min.js | 2 +- tests/v/boolean_feature.test | 13 +++ tests/v/builtin_feature.test | 6 ++ tests/v/class-name_feature.test | 39 ++++++++ tests/v/function_feature.test | 110 +++++++++++++++++++++ tests/v/keyword_feature.test | 83 ++++++++++++++++ tests/v/number_feature.test | 25 +++++ tests/v/operator_feature.test | 67 +++++++++++++ tests/v/string_feature.test | 35 +++++++ 15 files changed, 532 insertions(+), 2 deletions(-) create mode 100644 components/prism-v.js create mode 100644 components/prism-v.min.js create mode 100644 examples/prism-v.html create mode 100644 tests/v/boolean_feature.test create mode 100644 tests/v/builtin_feature.test create mode 100644 tests/v/class-name_feature.test create mode 100644 tests/v/function_feature.test create mode 100644 tests/v/keyword_feature.test create mode 100644 tests/v/number_feature.test create mode 100644 tests/v/operator_feature.test create mode 100644 tests/v/string_feature.test diff --git a/components.js b/components.js index a0d23dbd7c..61a4304917 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","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"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"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"},"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"},"cil":{"title":"CIL","owner":"sbrl"},"clojure":{"title":"Clojure","owner":"troglotit"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"concurnas":{"title":"Concurnas","alias":"conc","owner":"jasontatton"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"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"},"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"},"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"},"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"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"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","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"hlsl":{"title":"HLSL","require":"c","owner":"RunDevelopment"},"http":{"title":"HTTP","optional":["css","javascript","json","markup"],"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"},"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"},"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"],"owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","alias":["kt","kts"],"aliasTitles":{"kts":"Kotlin Script"},"require":"clike","owner":"Golmote"},"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","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"llvm":{"title":"LLVM IR","owner":"porglezomp"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"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"},"mel":{"title":"MEL","owner":"Golmote"},"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"},"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","alias":"objc","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"c","modify":["c","cpp"],"owner":"Milania1"},"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"},"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"},"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"},"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"},"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","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"},"stan":{"title":"Stan","owner":"RunDevelopment"},"iecst":{"title":"Structured Text (IEC 61131-3)","owner":"serhioromano"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"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"},"turtle":{"title":"Turtle","alias":"trig","aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup","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"},"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"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"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 matched in the code. For example, the keyword if will have the class keyword-if as well. You can have fine grained control over the appearance of each keyword by providing your own CSS rules.","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","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"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"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"},"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"},"cil":{"title":"CIL","owner":"sbrl"},"clojure":{"title":"Clojure","owner":"troglotit"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"concurnas":{"title":"Concurnas","alias":"conc","owner":"jasontatton"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"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"},"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"},"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"},"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"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"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","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"hlsl":{"title":"HLSL","require":"c","owner":"RunDevelopment"},"http":{"title":"HTTP","optional":["css","javascript","json","markup"],"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"},"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"},"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"],"owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","alias":["kt","kts"],"aliasTitles":{"kts":"Kotlin Script"},"require":"clike","owner":"Golmote"},"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","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"llvm":{"title":"LLVM IR","owner":"porglezomp"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"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"},"mel":{"title":"MEL","owner":"Golmote"},"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"},"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","alias":"objc","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"c","modify":["c","cpp"],"owner":"Milania1"},"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"},"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"},"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"},"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"},"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","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"},"stan":{"title":"Stan","owner":"RunDevelopment"},"iecst":{"title":"Structured Text (IEC 61131-3)","owner":"serhioromano"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"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"},"turtle":{"title":"Turtle","alias":"trig","aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup","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"},"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"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"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 matched in the code. For example, the keyword if will have the class keyword-if as well. You can have fine grained control over the appearance of each keyword by providing your own CSS rules.","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 e2e9845a97..c2fcfd77d5 100644 --- a/components.json +++ b/components.json @@ -1199,6 +1199,11 @@ "alias": ["uscript", "uc"], "owner": "RunDevelopment" }, + "v": { + "title": "V", + "require": "clike", + "owner": "taggon" + }, "vala": { "title": "Vala", "require": "clike", diff --git a/components/prism-v.js b/components/prism-v.js new file mode 100644 index 0000000000..469b30b677 --- /dev/null +++ b/components/prism-v.js @@ -0,0 +1,54 @@ +Prism.languages.v = Prism.languages.extend('clike', { + 'string': [ + { + pattern: /`(?:\\[\s\S]|[^\\`])*`/, + alias: 'backtick-quoted-string', + greedy: true, + }, + { + pattern: /r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + alias: 'single-quoted-string', + greedy: true, + inside: { + 'interpolation': { + pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/, + lookbehind: true, + inside: { + 'interpolation-variable': { + pattern: /^\$\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*$/, + alias: 'variable' + }, + 'interpolation-punctuation': { + pattern: /^\${|}$/, + alias: 'punctuation' + }, + rest: Prism.languages.v + } + } + } + } + ], + 'class-name': { + pattern: /\b(enum|interface|struct|type)\s+[\w.\\]+/, + lookbehind: true + }, + 'keyword': /\b(?:as|asm|assert|atomic|break|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)\b/, + 'number': /\b(?:0x[a-f\d]+(_[a-f\d]+)*|0b[01]+(_[01]+)*|0o[0-7]+(_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i, + 'operator': /~|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./, + 'builtin': /\b(?:any(_int|_float)?|bool|byte(ptr)?|charptr|i(8|16|nt|64|128)|rune|size_t|u?string|u(16|32|64|128))\b/ +}); + +Prism.languages.insertBefore('v', 'function', { + 'generic-function': { + // e.g. foo( ... + pattern: /\w+\s*<[^<>]*>(?=\()/, + greedy: true, + inside: { + 'function': /^\w+/, + 'generic': { + pattern: /<[\s\S]+/, // everything after the first < + alias: 'class-name' + } + } + } +}); \ No newline at end of file diff --git a/components/prism-v.min.js b/components/prism-v.min.js new file mode 100644 index 0000000000..6f0c33465c --- /dev/null +++ b/components/prism-v.min.js @@ -0,0 +1 @@ +Prism.languages.v=Prism.languages.extend("clike",{string:[{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,alias:"single-quoted-string",greedy:!0,inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/,lookbehind:!0,inside:{"interpolation-variable":{pattern:/^\$\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*$/,alias:"variable"},"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.v}}}}],"class-name":{pattern:/\b(enum|interface|struct|type)\s+[\w.\\]+/,lookbehind:!0},keyword:/\b(?:as|asm|assert|atomic|break|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)\b/,number:/\b(?:0x[a-f\d]+(_[a-f\d]+)*|0b[01]+(_[01]+)*|0o[0-7]+(_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i,operator:/~|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:any(_int|_float)?|bool|byte(ptr)?|charptr|i(8|16|nt|64|128)|rune|size_t|u?string|u(16|32|64|128))\b/}),Prism.languages.insertBefore("v","function",{"generic-function":{pattern:/\w+\s*<[^<>]*>(?=\()/,greedy:!0,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name"}}}}); \ No newline at end of file diff --git a/examples/prism-v.html b/examples/prism-v.html new file mode 100644 index 0000000000..1ddb018263 --- /dev/null +++ b/examples/prism-v.html @@ -0,0 +1,91 @@ +

Comments

+
// This is a comment
+/* This is a comment
+on multiple lines */
+ +

Numbers

+
123
+0x7B
+0b01111011
+0o173
+170141183460469231731687303715884105727
+1_000_000
+0b0_11
+3_122.55
+0xF_F
+0o17_3
+72.40
+072.40
+2.71828
+
+ +

Runes and strings

+
'\t'
+'\000'
+'\x07'
+'\u12e4'
+'\U00101234'
+`abc`
+`multi-line
+string`
+"Hello, world!"
+"multi-line
+string"
+ +

String interpolation

+
'Hello, $name!'
+"age = $user.age"
+'can register = ${user.age > 13}'
+'x = ${x:4.2f}'
+'[${x:10}]'
+'[${int(x):-10}]'
+
+ +

Struct

+
struct Foo {
+	a int   // private immutable (default)
+mut:
+	b int   // private mutable
+	c int   // (you can list multiple fields with the same access modifier)
+pub:
+	d int   // public immutable (readonly)
+pub mut:
+	e int   // public, but mutable only in parent module
+__global:
+	f int   // public and mutable both inside and outside parent module
+}           // (not recommended to use, that's why the 'global' keyword
+			// starts with __)
+
+ +

Functions

+
func(a, b int, z float64) bool { return a*b < int(z) }
+ +

Full example

+

+module mymodule
+
+import external_module
+
+fn sqr(n int) int {
+	return n * n
+}
+
+fn run(value int, op fn (int) int) int {
+	return op(value)
+}
+
+fn main() {
+	println(run(5, sqr)) // "25"
+	// Anonymous functions can be declared inside other functions:
+	double_fn := fn (n int) int {
+		return n + n
+	}
+	println(run(5, double_fn)) // "10"
+	// Functions can be passed around without assigning them to variables:
+	res := run(5, fn (n int) int {
+		return n + n
+	})
+
+	external_module.say_hi()
+}
+
diff --git a/plugins/autoloader/prism-autoloader.js b/plugins/autoloader/prism-autoloader.js index 48b90c390f..c90ee6b3ba 100644 --- a/plugins/autoloader/prism-autoloader.js +++ b/plugins/autoloader/prism-autoloader.js @@ -141,6 +141,7 @@ "textile": "markup", "twig": "markup", "typescript": "javascript", + "v": "clike", "vala": "clike", "vbnet": "basic", "velocity": "markup", diff --git a/plugins/autoloader/prism-autoloader.min.js b/plugins/autoloader/prism-autoloader.min.js index dd5b4113ce..1012adf6c5 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 l={javascript:"clike",actionscript:"javascript",apex:["clike","sql"],arduino:"cpp",aspnet:["markup","csharp"],birb:"clike",bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup-templating",ejs:["javascript","markup-templating"],etlua:["lua","markup-templating"],erb:["ruby","markup-templating"],fsharp:"clike","firestore-security-rules":"clike",flow:"javascript",ftl:"markup-templating",gml:"clike",glsl:"c",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",hlsl:"c",java:"clike",javadoc:["markup","java","javadoclike"],jolie:"clike",jsdoc:["javascript","javadoclike","typescript"],"js-extras":"javascript",json5:"json",jsonp:"json","js-templates":"javascript",kotlin:"clike",latte:["clike","markup-templating","php"],less:"css",lilypond:"scheme",markdown:"markup","markup-templating":"markup",mongodb:"javascript",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"c",parser:"markup",php:"markup-templating",phpdoc:["php","javadoclike"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:["markup","javascript"],purebasic:"clike",purescript:"haskell",qml:"javascript",qore:"clike",racket:"scheme",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sass:"css",scss:"css",scala:"java","shell-session":"bash",smarty:"markup-templating",solidity:"clike",soy:"markup-templating",sparql:"turtle",sqf:"clike",swift:"clike","t4-cs":["t4-templating","csharp"],"t4-vb":["t4-templating","vbnet"],tap:"yaml",tt2:["clike","markup-templating"],textile:"markup",twig:"markup",typescript:"javascript",vala:"clike",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup","xml-doc":"markup",xquery:"markup"},n={html:"markup",xml:"markup",svg:"markup",mathml:"markup",ssml:"markup",atom:"markup",rss:"markup",js:"javascript",g4:"antlr4",adoc:"asciidoc",shell:"bash",shortcode:"bbcode",rbnf:"bnf",oscript:"bsl",cs:"csharp",dotnet:"csharp",coffee:"coffeescript",conc:"concurnas",jinja2:"django","dns-zone":"dns-zone-file",dockerfile:"docker",eta:"ejs",xlsx:"excel-formula",xls:"excel-formula",gamemakerlanguage:"gml",hs:"haskell",gitignore:"ignore",hgignore:"ignore",npmignore:"ignore",webmanifest:"json",kt:"kotlin",kts:"kotlin",tex:"latex",context:"latex",ly:"lilypond",emacs:"lisp",elisp:"lisp","emacs-lisp":"lisp",md:"markdown",moon:"moonscript",n4jsd:"n4js",nani:"naniscript",objc:"objectivec",objectpascal:"pascal",px:"pcaxis",pcode:"peoplecode",pq:"powerquery",mscript:"powerquery",pbfasm:"purebasic",purs:"purescript",py:"python",rkt:"racket",rpy:"renpy",robot:"robotframework",rb:"ruby","sh-session":"shell-session",shellsession:"shell-session",smlnj:"sml",sol:"solidity",sln:"solution-file",rq:"sparql",t4:"t4-cs",trig:"turtle",ts:"typescript",tsconfig:"typoscript",uscript:"unrealscript",uc:"unrealscript",vb:"visual-basic",vba:"visual-basic",xeoracube:"xeora",yml:"yaml"},p={},e="components/",a=Prism.util.currentScript();if(a){var r=/\bplugins\/autoloader\/prism-autoloader\.(?:min\.)?js(?:\?[^\r\n/]*)?$/i,s=/(^|\/)[\w-]+\.(?:min\.)?js(?:\?[^\r\n/]*)?$/i,t=a.getAttribute("data-autoloader-path");if(null!=t)e=t.trim().replace(/\/?$/,"/");else{var i=a.src;r.test(i)?e=i.replace(r,"components/"):s.test(i)&&(e=i.replace(s,"$1components/"))}}var o=Prism.plugins.autoloader={languages_path:e,use_minified:!0,loadLanguages:m};Prism.hooks.add("complete",function(e){var a=e.element,r=e.language;if(a&&r&&"none"!==r){var s=function(e){var a=(e.getAttribute("data-dependencies")||"").trim();if(!a){var r=e.parentElement;r&&"pre"===r.tagName.toLowerCase()&&(a=(r.getAttribute("data-dependencies")||"").trim())}return a?a.split(/\s*,\s*/g):[]}(a);/^diff-./i.test(r)?(s.push("diff"),s.push(r.substr("diff-".length))):s.push(r),s.every(u)||m(s,function(){Prism.highlightElement(a)})}})}function u(e){if(0<=e.indexOf("!"))return!1;if((e=n[e]||e)in Prism.languages)return!0;var a=p[e];return a&&!a.error&&!1===a.loading}function m(e,a,r){"string"==typeof e&&(e=[e]);var s=e.length,t=0,i=!1;function c(){i||++t===s&&a&&a(e)}0!==s?e.forEach(function(e){!function(a,r,s){var t=0<=a.indexOf("!");function e(){var e=p[a];e||(e=p[a]={callbacks:[]}),e.callbacks.push({success:r,error:s}),!t&&u(a)?k(a,"success"):!t&&e.error?k(a,"error"):!t&&e.loading||(e.loading=!0,e.error=!1,function(e,a,r){var s=document.createElement("script");s.src=e,s.async=!0,s.onload=function(){document.body.removeChild(s),a&&a()},s.onerror=function(){document.body.removeChild(s),r&&r()},document.body.appendChild(s)}(function(e){return o.languages_path+"prism-"+e+(o.use_minified?".min":"")+".js"}(a),function(){e.loading=!1,k(a,"success")},function(){e.loading=!1,e.error=!0,k(a,"error")}))}a=a.replace("!",""),a=n[a]||a;var i=l[a];i&&i.length?m(i,e,s):e()}(e,c,function(){i||(i=!0,r&&r(e))})}):a&&setTimeout(a,0)}function k(e,a){if(p[e]){for(var r=p[e].callbacks,s=0,t=r.length;s { } + +---------------------------------------------------- + +[ + ["keyword", "struct"], + ["class-name", " Abc"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "type"], + ["class-name", " Alphabet"], + ["operator", "="], + " Abc ", + ["operator", "|"], + " Xyz\r\n", + + ["keyword", "enum"], + ["class-name", " Token"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "interface"], + ["class-name", " Speaker"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "struct"], + ["class-name", " Repo"], + ["operator", "<"], + "T", + ["operator", ">"], + ["punctuation", "{"], + ["punctuation", "}"] +] \ No newline at end of file diff --git a/tests/v/function_feature.test b/tests/v/function_feature.test new file mode 100644 index 0000000000..a96c6cbc84 --- /dev/null +++ b/tests/v/function_feature.test @@ -0,0 +1,110 @@ +fn init() { } +fn add(x int, y int) int { } +fn sum(a ...int) int { } +fn (mut t MyTime) century() int { } +fn (d Dog) speak() string { } +fn (r Repo) find_user_by_id(id int) ?User { } +fn new_repo(db DB) Repo { } +fn (r Repo) find_by_id(id int) ?T { } + +---------------------------------------------------- + +[ + ["keyword", "fn"], + ["function", "init"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["function", "add"], + ["punctuation", "("], + "x ", + ["builtin", "int"], + ["punctuation", ","], + " y ", + ["builtin", "int"], + ["punctuation", ")"], + ["builtin", "int"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["function", "sum"], + ["punctuation", "("], + "a ", + ["operator", "..."], + ["builtin", "int"], + ["punctuation", ")"], + ["builtin", "int"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["punctuation", "("], + ["keyword", "mut"], + " t MyTime", + ["punctuation", ")"], + ["function", "century"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "int"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["punctuation", "("], + "d Dog", + ["punctuation", ")"], + ["function", "speak"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "string"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["punctuation", "("], + "r Repo", + ["punctuation", ")"], + ["function", "find_user_by_id"], + ["punctuation", "("], + "id ", + ["builtin", "int"], + ["punctuation", ")"], + " ?User ", + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["generic-function", [ + ["function", "new_repo"], + ["generic", ""] + ]], + ["punctuation", "("], + "db DB", + ["punctuation", ")"], + " Repo", + ["operator", "<"], + "T", + ["operator", ">"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["punctuation", "("], + "r Repo", + ["operator", "<"], + "T", + ["operator", ">"], + ["punctuation", ")"], + ["function", "find_by_id"], + ["punctuation", "("], + "id ", + ["builtin", "int"], + ["punctuation", ")"], + " ?T ", + ["punctuation", "{"], + ["punctuation", "}"] +] \ No newline at end of file diff --git a/tests/v/keyword_feature.test b/tests/v/keyword_feature.test new file mode 100644 index 0000000000..594afbb713 --- /dev/null +++ b/tests/v/keyword_feature.test @@ -0,0 +1,83 @@ +as +asm +assert +atomic +break +const +continue +defer +else +embed +enum +false +fn +for +__global +go +goto +if +import +in +interface +is +lock +match +module +mut +none +or +pub +return +rlock +select +shared +sizeof +static +struct +true +type +typeof +union +unsafe + +---------------------------------------------------- + +[ + ["keyword", "as"], + ["keyword", "asm"], + ["keyword", "assert"], + ["keyword", "atomic"], + ["keyword", "break"], + ["keyword", "const"], + ["keyword", "continue"], + ["keyword", "defer"], + ["keyword", "else"], + ["keyword", "embed"], + ["keyword", "enum"], ["class-name", "\r\nfalse"], + ["keyword", "fn"], + ["keyword", "for"], + ["keyword", "__global"], + ["keyword", "go"], + ["keyword", "goto"], + ["keyword", "if"], + ["keyword", "import"], + ["keyword", "in"], + ["keyword", "interface"], ["class-name", "\r\nis"], + ["keyword", "lock"], + ["keyword", "match"], + ["keyword", "module"], + ["keyword", "mut"], + ["keyword", "none"], + ["keyword", "or"], + ["keyword", "pub"], + ["keyword", "return"], + ["keyword", "rlock"], + ["keyword", "select"], + ["keyword", "shared"], + ["keyword", "sizeof"], + ["keyword", "static"], + ["keyword", "struct"], ["class-name", "\r\ntrue"], + ["keyword", "type"], ["class-name", "\r\ntypeof"], + ["keyword", "union"], + ["keyword", "unsafe"] +] \ No newline at end of file diff --git a/tests/v/number_feature.test b/tests/v/number_feature.test new file mode 100644 index 0000000000..d11d59077f --- /dev/null +++ b/tests/v/number_feature.test @@ -0,0 +1,25 @@ +123 +0x7B +0b01111011 +0o173 +1_000_000 +0xF_F +072.40 +2.71828 + +---------------------------------------------------- + +[ + ["number", "123"], + ["number", "0x7B"], + ["number", "0b01111011"], + ["number", "0o173"], + ["number", "1_000_000"], + ["number", "0xF_F"], + ["number", "072.40"], + ["number", "2.71828"] +] + +---------------------------------------------------- + +Check for numbers \ No newline at end of file diff --git a/tests/v/operator_feature.test b/tests/v/operator_feature.test new file mode 100644 index 0000000000..d242aef209 --- /dev/null +++ b/tests/v/operator_feature.test @@ -0,0 +1,67 @@ ++ +- +* +/ +% +~ +& +| +^ +! +&& +|| +!= +<< +>> +== +< +<= +> +>= ++= +-= +*= +/= +%= +&= +|= +^= +>>= +<<= +:= + +---------------------------------------------------- + +[ + ["operator", "+"], + ["operator", "-"], + ["operator", "*"], + ["operator", "/"], + ["operator", "%"], + ["operator", "~"], + ["operator", "&"], + ["operator", "|"], + ["operator", "^"], + ["operator", "!"], + ["operator", "&&"], + ["operator", "||"], + ["operator", "!="], + ["operator", "<<"], + ["operator", ">>"], + ["operator", "=="], + ["operator", "<"], + ["operator", "<="], + ["operator", ">"], + ["operator", ">="], + ["operator", "+="], + ["operator", "-="], + ["operator", "*="], + ["operator", "/="], + ["operator", "%="], + ["operator", "&="], + ["operator", "|="], + ["operator", "^="], + ["operator", ">>="], + ["operator", "<<="], + ["operator", ":="] +] \ No newline at end of file diff --git a/tests/v/string_feature.test b/tests/v/string_feature.test new file mode 100644 index 0000000000..ae47dcb83b --- /dev/null +++ b/tests/v/string_feature.test @@ -0,0 +1,35 @@ +"https://example.com" +'single quote' +'age = $user.age' +'x = ${x:4.2f}' +`Hello` +r'hello\nworld' + +---------------------------------------------------- + +[ + ["string", ["\"https://example.com\""]], + ["string", ["'single quote'"]], + ["string", [ + "'age = ", + ["interpolation", [ + ["interpolation-variable", "$user.age"] + ]], + "'" + ]], + ["string", [ + "'x = ", + ["interpolation", [ + ["interpolation-punctuation", "${"], + "x:4.2f", + ["interpolation-punctuation", "}"] + ]], + "'" + ]], + ["string", "`Hello`"], + ["string", ["r'hello\\nworld'"]] +] + +---------------------------------------------------- + +Check for strings and string interpolation \ No newline at end of file From b23ef0c12dcf5bfbc07e9a37cc4602482705e013 Mon Sep 17 00:00:00 2001 From: taggon Date: Sat, 2 Jan 2021 02:18:15 +0900 Subject: [PATCH 2/7] Fix a comment --- components/prism-v.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-v.js b/components/prism-v.js index 469b30b677..1aa2142236 100644 --- a/components/prism-v.js +++ b/components/prism-v.js @@ -40,7 +40,7 @@ Prism.languages.v = Prism.languages.extend('clike', { Prism.languages.insertBefore('v', 'function', { 'generic-function': { - // e.g. foo( ... + // e.g. foo( ... pattern: /\w+\s*<[^<>]*>(?=\()/, greedy: true, inside: { From 5ea3b50e2c35e08a9befe51fad8ce225a4ec2eca Mon Sep 17 00:00:00 2001 From: taggon Date: Sat, 2 Jan 2021 02:23:35 +0900 Subject: [PATCH 3/7] Remove unused capturing group --- components/prism-v.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-v.js b/components/prism-v.js index 1aa2142236..df76b4777f 100644 --- a/components/prism-v.js +++ b/components/prism-v.js @@ -3,15 +3,15 @@ Prism.languages.v = Prism.languages.extend('clike', { { pattern: /`(?:\\[\s\S]|[^\\`])*`/, alias: 'backtick-quoted-string', - greedy: true, + greedy: true }, { pattern: /r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, - alias: 'single-quoted-string', + alias: 'quoted-string', greedy: true, inside: { 'interpolation': { - pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/, + pattern: /(?:^|[^\\])(?:\\{2})*\$(?:\{[^{}]*\}|\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/, lookbehind: true, inside: { 'interpolation-variable': { From af1513fe3f6898df2d2abef70f332b2db3e9dc68 Mon Sep 17 00:00:00 2001 From: taggon Date: Sat, 2 Jan 2021 02:33:32 +0900 Subject: [PATCH 4/7] Fix tests failed with node v10 --- components/prism-v.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/prism-v.js b/components/prism-v.js index df76b4777f..61b81e19eb 100644 --- a/components/prism-v.js +++ b/components/prism-v.js @@ -11,11 +11,11 @@ Prism.languages.v = Prism.languages.extend('clike', { greedy: true, inside: { 'interpolation': { - pattern: /(?:^|[^\\])(?:\\{2})*\$(?:\{[^{}]*\}|\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/, + pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/, lookbehind: true, inside: { 'interpolation-variable': { - pattern: /^\$\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*$/, + pattern: /^\$\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*$/, alias: 'variable' }, 'interpolation-punctuation': { @@ -33,9 +33,9 @@ Prism.languages.v = Prism.languages.extend('clike', { lookbehind: true }, 'keyword': /\b(?:as|asm|assert|atomic|break|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)\b/, - 'number': /\b(?:0x[a-f\d]+(_[a-f\d]+)*|0b[01]+(_[01]+)*|0o[0-7]+(_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i, + 'number': /\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i, 'operator': /~|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./, - 'builtin': /\b(?:any(_int|_float)?|bool|byte(ptr)?|charptr|i(8|16|nt|64|128)|rune|size_t|u?string|u(16|32|64|128))\b/ + 'builtin': /\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128))\b/ }); Prism.languages.insertBefore('v', 'function', { From 9a11ee9e6162e38781043fdad26f911034847e22 Mon Sep 17 00:00:00 2001 From: taggon Date: Sat, 2 Jan 2021 02:36:22 +0900 Subject: [PATCH 5/7] Update the minified script --- components/prism-v.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-v.min.js b/components/prism-v.min.js index 6f0c33465c..e39d54b5d6 100644 --- a/components/prism-v.min.js +++ b/components/prism-v.min.js @@ -1 +1 @@ -Prism.languages.v=Prism.languages.extend("clike",{string:[{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,alias:"single-quoted-string",greedy:!0,inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/,lookbehind:!0,inside:{"interpolation-variable":{pattern:/^\$\w+(\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*$/,alias:"variable"},"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.v}}}}],"class-name":{pattern:/\b(enum|interface|struct|type)\s+[\w.\\]+/,lookbehind:!0},keyword:/\b(?:as|asm|assert|atomic|break|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)\b/,number:/\b(?:0x[a-f\d]+(_[a-f\d]+)*|0b[01]+(_[01]+)*|0o[0-7]+(_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i,operator:/~|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:any(_int|_float)?|bool|byte(ptr)?|charptr|i(8|16|nt|64|128)|rune|size_t|u?string|u(16|32|64|128))\b/}),Prism.languages.insertBefore("v","function",{"generic-function":{pattern:/\w+\s*<[^<>]*>(?=\()/,greedy:!0,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name"}}}}); \ No newline at end of file +Prism.languages.v=Prism.languages.extend("clike",{string:[{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,alias:"quoted-string",greedy:!0,inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/,lookbehind:!0,inside:{"interpolation-variable":{pattern:/^\$\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*$/,alias:"variable"},"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.v}}}}],"class-name":{pattern:/\b(enum|interface|struct|type)\s+[\w.\\]+/,lookbehind:!0},keyword:/\b(?:as|asm|assert|atomic|break|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)\b/,number:/\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i,operator:/~|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128))\b/}),Prism.languages.insertBefore("v","function",{"generic-function":{pattern:/\w+\s*<[^<>]*>(?=\()/,greedy:!0,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name"}}}}); \ No newline at end of file From 3d8947cfb39c8c1e9aefbf84a58a2bc786a9739c Mon Sep 17 00:00:00 2001 From: taggon Date: Thu, 7 Jan 2021 21:30:49 +0900 Subject: [PATCH 6/7] Fix all problems mentioned --- components/prism-v.js | 45 +++- components/prism-v.min.js | 2 +- tests/{ => languages}/v/boolean_feature.test | 24 +- .../{ => languages}/v/class-name_feature.test | 78 +++--- tests/{ => languages}/v/function_feature.test | 228 +++++++++--------- tests/languages/v/keyword_feature.test | 93 +++++++ tests/{ => languages}/v/number_feature.test | 48 ++-- tests/{ => languages}/v/operator_feature.test | 132 +++++----- tests/{ => languages}/v/string_feature.test | 72 +++--- tests/v/builtin_feature.test | 6 - tests/v/keyword_feature.test | 83 ------- 11 files changed, 425 insertions(+), 386 deletions(-) rename tests/{ => languages}/v/boolean_feature.test (84%) rename tests/{ => languages}/v/class-name_feature.test (66%) rename tests/{ => languages}/v/function_feature.test (81%) create mode 100644 tests/languages/v/keyword_feature.test rename tests/{ => languages}/v/number_feature.test (89%) rename tests/{ => languages}/v/operator_feature.test (92%) rename tests/{ => languages}/v/string_feature.test (68%) delete mode 100644 tests/v/builtin_feature.test delete mode 100644 tests/v/keyword_feature.test diff --git a/components/prism-v.js b/components/prism-v.js index 61b81e19eb..b817b3909a 100644 --- a/components/prism-v.js +++ b/components/prism-v.js @@ -1,9 +1,8 @@ Prism.languages.v = Prism.languages.extend('clike', { 'string': [ { - pattern: /`(?:\\[\s\S]|[^\\`])*`/, - alias: 'backtick-quoted-string', - greedy: true + pattern: /`(?:\\\`|\\?[^\`]{1,2})`/, // using {1,2} instead of `u` flag for compatibility + alias: 'rune' }, { pattern: /r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, @@ -15,39 +14,59 @@ Prism.languages.v = Prism.languages.extend('clike', { lookbehind: true, inside: { 'interpolation-variable': { - pattern: /^\$\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*$/, + pattern: /^\$\w[\s\S]*$/, alias: 'variable' }, 'interpolation-punctuation': { pattern: /^\${|}$/, alias: 'punctuation' }, - rest: Prism.languages.v + 'interpolation-expression': { + pattern: /[\s\S]+/, + inside: Prism.languages.v + } } } } } ], 'class-name': { - pattern: /\b(enum|interface|struct|type)\s+[\w.\\]+/, + pattern: /(\b(?:enum|interface|struct|type)\s+)\w+/, lookbehind: true }, - 'keyword': /\b(?:as|asm|assert|atomic|break|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)\b/, + 'keyword': /(?:\b(?:as|asm|assert|atomic|break|chan|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)|\$(?:if|else|for)|#(?:include|flag))\b/, 'number': /\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i, - 'operator': /~|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./, - 'builtin': /\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128))\b/ + 'operator': /~|\?|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\.?/, + 'builtin': /\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|f(?:32|64)|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128)|voidptr)\b/ +}); + +Prism.languages.insertBefore('v', 'operator', { + 'attribute': { + pattern: /^\s*\[(?:deprecated|unsafe_fn|typedef|live|inline|flag|ref_only|windows_stdcall|direct_array_access)\]/m, + alias: 'annotation', + inside: { + 'punctuation': /[\[\]]/, + 'keyword': /\w+/ + } + }, + 'generic': { + pattern: /\<\w+\>(?=\s*[\)\{])/, + inside: { + 'punctuation': /[<>]/, + 'class-name': /\w+/ + } + } }); Prism.languages.insertBefore('v', 'function', { 'generic-function': { // e.g. foo( ... - pattern: /\w+\s*<[^<>]*>(?=\()/, - greedy: true, + pattern: /\w+\s*<\w+>(?=\()/, inside: { 'function': /^\w+/, 'generic': { - pattern: /<[\s\S]+/, // everything after the first < - alias: 'class-name' + pattern: /<\w+>/, + inside: Prism.languages.v.generic.inside } } } diff --git a/components/prism-v.min.js b/components/prism-v.min.js index e39d54b5d6..125ba3160e 100644 --- a/components/prism-v.min.js +++ b/components/prism-v.min.js @@ -1 +1 @@ -Prism.languages.v=Prism.languages.extend("clike",{string:[{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,alias:"quoted-string",greedy:!0,inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/,lookbehind:!0,inside:{"interpolation-variable":{pattern:/^\$\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*$/,alias:"variable"},"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.v}}}}],"class-name":{pattern:/\b(enum|interface|struct|type)\s+[\w.\\]+/,lookbehind:!0},keyword:/\b(?:as|asm|assert|atomic|break|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)\b/,number:/\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i,operator:/~|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128))\b/}),Prism.languages.insertBefore("v","function",{"generic-function":{pattern:/\w+\s*<[^<>]*>(?=\()/,greedy:!0,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name"}}}}); \ No newline at end of file +Prism.languages.v=Prism.languages.extend("clike",{string:[{pattern:/`(?:\\\`|\\?[^\`]{1,2})`/,alias:"rune"},{pattern:/r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,alias:"quoted-string",greedy:!0,inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/,lookbehind:!0,inside:{"interpolation-variable":{pattern:/^\$\w[\s\S]*$/,alias:"variable"},"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},"interpolation-expression":{pattern:/[\s\S]+/,inside:Prism.languages.v}}}}}],"class-name":{pattern:/(\b(?:enum|interface|struct|type)\s+)\w+/,lookbehind:!0},keyword:/(?:\b(?:as|asm|assert|atomic|break|chan|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)|\$(?:if|else|for)|#(?:include|flag))\b/,number:/\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i,operator:/~|\?|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\.?/,builtin:/\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|f(?:32|64)|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128)|voidptr)\b/}),Prism.languages.insertBefore("v","operator",{attribute:{pattern:/^\s*\[(?:deprecated|unsafe_fn|typedef|live|inline|flag|ref_only|windows_stdcall|direct_array_access)\]/m,alias:"annotation",inside:{punctuation:/[\[\]]/,keyword:/\w+/}},generic:{pattern:/\<\w+\>(?=\s*[\)\{])/,inside:{punctuation:/[<>]/,"class-name":/\w+/}}}),Prism.languages.insertBefore("v","function",{"generic-function":{pattern:/\w+\s*<\w+>(?=\()/,inside:{function:/^\w+/,generic:{pattern:/<\w+>/,inside:Prism.languages.v.generic.inside}}}}); \ No newline at end of file diff --git a/tests/v/boolean_feature.test b/tests/languages/v/boolean_feature.test similarity index 84% rename from tests/v/boolean_feature.test rename to tests/languages/v/boolean_feature.test index b5c6580ccc..750aee53ad 100644 --- a/tests/v/boolean_feature.test +++ b/tests/languages/v/boolean_feature.test @@ -1,13 +1,13 @@ -true -false - ----------------------------------------------------- - -[ - ["boolean", "true"], - ["boolean", "false"] -] - ----------------------------------------------------- - +true +false + +---------------------------------------------------- + +[ + ["boolean", "true"], + ["boolean", "false"] +] + +---------------------------------------------------- + Check for boolean \ No newline at end of file diff --git a/tests/v/class-name_feature.test b/tests/languages/v/class-name_feature.test similarity index 66% rename from tests/v/class-name_feature.test rename to tests/languages/v/class-name_feature.test index 22d9ad6918..bf2387c159 100644 --- a/tests/v/class-name_feature.test +++ b/tests/languages/v/class-name_feature.test @@ -1,39 +1,41 @@ -struct Abc { } -type Alphabet = Abc | Xyz -enum Token { } -interface Speaker { } -struct Repo { } - ----------------------------------------------------- - -[ - ["keyword", "struct"], - ["class-name", " Abc"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "type"], - ["class-name", " Alphabet"], - ["operator", "="], - " Abc ", - ["operator", "|"], - " Xyz\r\n", - - ["keyword", "enum"], - ["class-name", " Token"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "interface"], - ["class-name", " Speaker"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "struct"], - ["class-name", " Repo"], - ["operator", "<"], - "T", - ["operator", ">"], - ["punctuation", "{"], - ["punctuation", "}"] +struct Abc { } +type Alphabet = Abc | Xyz +enum Token { } +interface Speaker { } +struct Repo { } + +---------------------------------------------------- + +[ + ["keyword", "struct"], + ["class-name", "Abc"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "type"], + ["class-name", "Alphabet"], + ["operator", "="], + " Abc ", + ["operator", "|"], + " Xyz\r\n", + + ["keyword", "enum"], + ["class-name", "Token"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "interface"], + ["class-name", "Speaker"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "struct"], + ["class-name", "Repo"], + ["generic", [ + ["punctuation", "<"], + ["class-name", "T"], + ["punctuation", ">"] + ]], + ["punctuation", "{"], + ["punctuation", "}"] ] \ No newline at end of file diff --git a/tests/v/function_feature.test b/tests/languages/v/function_feature.test similarity index 81% rename from tests/v/function_feature.test rename to tests/languages/v/function_feature.test index a96c6cbc84..41e1749c30 100644 --- a/tests/v/function_feature.test +++ b/tests/languages/v/function_feature.test @@ -1,110 +1,120 @@ -fn init() { } -fn add(x int, y int) int { } -fn sum(a ...int) int { } -fn (mut t MyTime) century() int { } -fn (d Dog) speak() string { } -fn (r Repo) find_user_by_id(id int) ?User { } -fn new_repo(db DB) Repo { } -fn (r Repo) find_by_id(id int) ?T { } - ----------------------------------------------------- - -[ - ["keyword", "fn"], - ["function", "init"], - ["punctuation", "("], - ["punctuation", ")"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "fn"], - ["function", "add"], - ["punctuation", "("], - "x ", - ["builtin", "int"], - ["punctuation", ","], - " y ", - ["builtin", "int"], - ["punctuation", ")"], - ["builtin", "int"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "fn"], - ["function", "sum"], - ["punctuation", "("], - "a ", - ["operator", "..."], - ["builtin", "int"], - ["punctuation", ")"], - ["builtin", "int"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "fn"], - ["punctuation", "("], - ["keyword", "mut"], - " t MyTime", - ["punctuation", ")"], - ["function", "century"], - ["punctuation", "("], - ["punctuation", ")"], - ["builtin", "int"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "fn"], - ["punctuation", "("], - "d Dog", - ["punctuation", ")"], - ["function", "speak"], - ["punctuation", "("], - ["punctuation", ")"], - ["builtin", "string"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "fn"], - ["punctuation", "("], - "r Repo", - ["punctuation", ")"], - ["function", "find_user_by_id"], - ["punctuation", "("], - "id ", - ["builtin", "int"], - ["punctuation", ")"], - " ?User ", - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "fn"], - ["generic-function", [ - ["function", "new_repo"], - ["generic", ""] - ]], - ["punctuation", "("], - "db DB", - ["punctuation", ")"], - " Repo", - ["operator", "<"], - "T", - ["operator", ">"], - ["punctuation", "{"], - ["punctuation", "}"], - - ["keyword", "fn"], - ["punctuation", "("], - "r Repo", - ["operator", "<"], - "T", - ["operator", ">"], - ["punctuation", ")"], - ["function", "find_by_id"], - ["punctuation", "("], - "id ", - ["builtin", "int"], - ["punctuation", ")"], - " ?T ", - ["punctuation", "{"], - ["punctuation", "}"] +fn init() { } +fn add(x int, y int) int { } +fn sum(a ...int) int { } +fn (mut t MyTime) century() int { } +fn (d Dog) speak() string { } +fn (r Repo) find_user_by_id(id int) ?User { } +fn new_repo(db DB) Repo { } +fn (r Repo) find_by_id(id int) ?T { } + +---------------------------------------------------- + +[ + ["keyword", "fn"], + ["function", "init"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["function", "add"], + ["punctuation", "("], + "x ", + ["builtin", "int"], + ["punctuation", ","], + " y ", + ["builtin", "int"], + ["punctuation", ")"], + ["builtin", "int"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["function", "sum"], + ["punctuation", "("], + "a ", + ["operator", "..."], + ["builtin", "int"], + ["punctuation", ")"], + ["builtin", "int"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["punctuation", "("], + ["keyword", "mut"], + " t MyTime", + ["punctuation", ")"], + ["function", "century"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "int"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["punctuation", "("], + "d Dog", + ["punctuation", ")"], + ["function", "speak"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "string"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["punctuation", "("], + "r Repo", + ["punctuation", ")"], + ["function", "find_user_by_id"], + ["punctuation", "("], + "id ", + ["builtin", "int"], + ["punctuation", ")"], + ["operator", "?"], + "User ", + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["generic-function", [ + ["function", "new_repo"], + ["generic", [ + ["punctuation", "<"], + ["class-name", "T"], + ["punctuation", ">"] + ]] + ]], + ["punctuation", "("], + "db DB", + ["punctuation", ")"], + " Repo", + ["generic", [ + ["punctuation", "<"], + ["class-name", "T"], + ["punctuation", ">"] + ]], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "fn"], + ["punctuation", "("], + "r Repo", + ["generic", [ + ["punctuation", "<"], + ["class-name", "T"], + ["punctuation", ">"] + ]], + ["punctuation", ")"], + ["function", "find_by_id"], + ["punctuation", "("], + "id ", + ["builtin", "int"], + ["punctuation", ")"], + ["operator", "?"], + "T ", + ["punctuation", "{"], + ["punctuation", "}"] ] \ No newline at end of file diff --git a/tests/languages/v/keyword_feature.test b/tests/languages/v/keyword_feature.test new file mode 100644 index 0000000000..279ed0d8da --- /dev/null +++ b/tests/languages/v/keyword_feature.test @@ -0,0 +1,93 @@ +as; +asm; +assert; +atomic; +break; +const; +continue; +defer; +else; +embed; +enum;; +fn; +for; +__global; +go; +goto; +if; +import; +in; +interface; +is; +lock; +match; +module; +mut; +none; +or; +pub; +return; +rlock; +select; +shared; +sizeof; +static; +struct; +type;; +typeof; +union; +unsafe; +$if; +$else; +$for; +#include; +#flag; + +---------------------------------------------------- + +[ + ["keyword", "as"], ["punctuation", ";"], + ["keyword", "asm"], ["punctuation", ";"], + ["keyword", "assert"], ["punctuation", ";"], + ["keyword", "atomic"], ["punctuation", ";"], + ["keyword", "break"], ["punctuation", ";"], + ["keyword", "const"], ["punctuation", ";"], + ["keyword", "continue"], ["punctuation", ";"], + ["keyword", "defer"], ["punctuation", ";"], + ["keyword", "else"], ["punctuation", ";"], + ["keyword", "embed"], ["punctuation", ";"], + ["keyword", "enum"], ["punctuation", ";"], ["punctuation", ";"], + ["keyword", "fn"], ["punctuation", ";"], + ["keyword", "for"], ["punctuation", ";"], + ["keyword", "__global"], ["punctuation", ";"], + ["keyword", "go"], ["punctuation", ";"], + ["keyword", "goto"], ["punctuation", ";"], + ["keyword", "if"], ["punctuation", ";"], + ["keyword", "import"], ["punctuation", ";"], + ["keyword", "in"], ["punctuation", ";"], + ["keyword", "interface"], ["punctuation", ";"], + ["keyword", "is"], ["punctuation", ";"], + ["keyword", "lock"], ["punctuation", ";"], + ["keyword", "match"], ["punctuation", ";"], + ["keyword", "module"], ["punctuation", ";"], + ["keyword", "mut"], ["punctuation", ";"], + ["keyword", "none"], ["punctuation", ";"], + ["keyword", "or"], ["punctuation", ";"], + ["keyword", "pub"], ["punctuation", ";"], + ["keyword", "return"], ["punctuation", ";"], + ["keyword", "rlock"], ["punctuation", ";"], + ["keyword", "select"], ["punctuation", ";"], + ["keyword", "shared"], ["punctuation", ";"], + ["keyword", "sizeof"], ["punctuation", ";"], + ["keyword", "static"], ["punctuation", ";"], + ["keyword", "struct"], ["punctuation", ";"], + ["keyword", "type"], ["punctuation", ";"], ["punctuation", ";"], + ["keyword", "typeof"], ["punctuation", ";"], + ["keyword", "union"], ["punctuation", ";"], + ["keyword", "unsafe"], ["punctuation", ";"], + ["keyword", "$if"], ["punctuation", ";"], + ["keyword", "$else"], ["punctuation", ";"], + ["keyword", "$for"], ["punctuation", ";"], + ["keyword", "#include"], ["punctuation", ";"], + ["keyword", "#flag"], ["punctuation", ";"] +] \ No newline at end of file diff --git a/tests/v/number_feature.test b/tests/languages/v/number_feature.test similarity index 89% rename from tests/v/number_feature.test rename to tests/languages/v/number_feature.test index d11d59077f..06820c7115 100644 --- a/tests/v/number_feature.test +++ b/tests/languages/v/number_feature.test @@ -1,25 +1,25 @@ -123 -0x7B -0b01111011 -0o173 -1_000_000 -0xF_F -072.40 -2.71828 - ----------------------------------------------------- - -[ - ["number", "123"], - ["number", "0x7B"], - ["number", "0b01111011"], - ["number", "0o173"], - ["number", "1_000_000"], - ["number", "0xF_F"], - ["number", "072.40"], - ["number", "2.71828"] -] - ----------------------------------------------------- - +123 +0x7B +0b01111011 +0o173 +1_000_000 +0xF_F +072.40 +2.71828 + +---------------------------------------------------- + +[ + ["number", "123"], + ["number", "0x7B"], + ["number", "0b01111011"], + ["number", "0o173"], + ["number", "1_000_000"], + ["number", "0xF_F"], + ["number", "072.40"], + ["number", "2.71828"] +] + +---------------------------------------------------- + Check for numbers \ No newline at end of file diff --git a/tests/v/operator_feature.test b/tests/languages/v/operator_feature.test similarity index 92% rename from tests/v/operator_feature.test rename to tests/languages/v/operator_feature.test index d242aef209..f7744026cb 100644 --- a/tests/v/operator_feature.test +++ b/tests/languages/v/operator_feature.test @@ -1,67 +1,67 @@ -+ -- -* -/ -% -~ -& -| -^ -! -&& -|| -!= -<< ->> -== -< -<= -> ->= -+= --= -*= -/= -%= -&= -|= -^= ->>= -<<= -:= - ----------------------------------------------------- - -[ - ["operator", "+"], - ["operator", "-"], - ["operator", "*"], - ["operator", "/"], - ["operator", "%"], - ["operator", "~"], - ["operator", "&"], - ["operator", "|"], - ["operator", "^"], - ["operator", "!"], - ["operator", "&&"], - ["operator", "||"], - ["operator", "!="], - ["operator", "<<"], - ["operator", ">>"], - ["operator", "=="], - ["operator", "<"], - ["operator", "<="], - ["operator", ">"], - ["operator", ">="], - ["operator", "+="], - ["operator", "-="], - ["operator", "*="], - ["operator", "/="], - ["operator", "%="], - ["operator", "&="], - ["operator", "|="], - ["operator", "^="], - ["operator", ">>="], - ["operator", "<<="], - ["operator", ":="] ++ +- +* +/ +% +~ +& +| +^ +! +&& +|| +!= +<< +>> +== +< +<= +> +>= ++= +-= +*= +/= +%= +&= +|= +^= +>>= +<<= +:= + +---------------------------------------------------- + +[ + ["operator", "+"], + ["operator", "-"], + ["operator", "*"], + ["operator", "/"], + ["operator", "%"], + ["operator", "~"], + ["operator", "&"], + ["operator", "|"], + ["operator", "^"], + ["operator", "!"], + ["operator", "&&"], + ["operator", "||"], + ["operator", "!="], + ["operator", "<<"], + ["operator", ">>"], + ["operator", "=="], + ["operator", "<"], + ["operator", "<="], + ["operator", ">"], + ["operator", ">="], + ["operator", "+="], + ["operator", "-="], + ["operator", "*="], + ["operator", "/="], + ["operator", "%="], + ["operator", "&="], + ["operator", "|="], + ["operator", "^="], + ["operator", ">>="], + ["operator", "<<="], + ["operator", ":="] ] \ No newline at end of file diff --git a/tests/v/string_feature.test b/tests/languages/v/string_feature.test similarity index 68% rename from tests/v/string_feature.test rename to tests/languages/v/string_feature.test index ae47dcb83b..9b7024611d 100644 --- a/tests/v/string_feature.test +++ b/tests/languages/v/string_feature.test @@ -1,35 +1,39 @@ -"https://example.com" -'single quote' -'age = $user.age' -'x = ${x:4.2f}' -`Hello` -r'hello\nworld' - ----------------------------------------------------- - -[ - ["string", ["\"https://example.com\""]], - ["string", ["'single quote'"]], - ["string", [ - "'age = ", - ["interpolation", [ - ["interpolation-variable", "$user.age"] - ]], - "'" - ]], - ["string", [ - "'x = ", - ["interpolation", [ - ["interpolation-punctuation", "${"], - "x:4.2f", - ["interpolation-punctuation", "}"] - ]], - "'" - ]], - ["string", "`Hello`"], - ["string", ["r'hello\\nworld'"]] -] - ----------------------------------------------------- - +"https://example.com" +'single quote' +'age = $user.age' +'x = ${x:4.2f}' +r'hello\nworld' +`🚀` +`\`` +`Not a Rune` + +---------------------------------------------------- + +[ + ["string", ["\"https://example.com\""]], + ["string", ["'single quote'"]], + ["string", [ + "'age = ", + ["interpolation", [ + ["interpolation-variable", "$user.age"] + ]], + "'" + ]], + ["string", [ + "'x = ", + ["interpolation", [ + ["interpolation-punctuation", "${"], + ["interpolation-expression", "x:4.2f"], + ["interpolation-punctuation", "}"] + ]], + "'" + ]], + ["string", ["r'hello\\nworld'"]], + ["string", "`🚀`"], + ["string", "`\\``"], + "\r\n`Not a Rune`" +] + +---------------------------------------------------- + Check for strings and string interpolation \ No newline at end of file diff --git a/tests/v/builtin_feature.test b/tests/v/builtin_feature.test deleted file mode 100644 index 151058666c..0000000000 --- a/tests/v/builtin_feature.test +++ /dev/null @@ -1,6 +0,0 @@ - - ----------------------------------------------------- - -[ -] \ No newline at end of file diff --git a/tests/v/keyword_feature.test b/tests/v/keyword_feature.test deleted file mode 100644 index 594afbb713..0000000000 --- a/tests/v/keyword_feature.test +++ /dev/null @@ -1,83 +0,0 @@ -as -asm -assert -atomic -break -const -continue -defer -else -embed -enum -false -fn -for -__global -go -goto -if -import -in -interface -is -lock -match -module -mut -none -or -pub -return -rlock -select -shared -sizeof -static -struct -true -type -typeof -union -unsafe - ----------------------------------------------------- - -[ - ["keyword", "as"], - ["keyword", "asm"], - ["keyword", "assert"], - ["keyword", "atomic"], - ["keyword", "break"], - ["keyword", "const"], - ["keyword", "continue"], - ["keyword", "defer"], - ["keyword", "else"], - ["keyword", "embed"], - ["keyword", "enum"], ["class-name", "\r\nfalse"], - ["keyword", "fn"], - ["keyword", "for"], - ["keyword", "__global"], - ["keyword", "go"], - ["keyword", "goto"], - ["keyword", "if"], - ["keyword", "import"], - ["keyword", "in"], - ["keyword", "interface"], ["class-name", "\r\nis"], - ["keyword", "lock"], - ["keyword", "match"], - ["keyword", "module"], - ["keyword", "mut"], - ["keyword", "none"], - ["keyword", "or"], - ["keyword", "pub"], - ["keyword", "return"], - ["keyword", "rlock"], - ["keyword", "select"], - ["keyword", "shared"], - ["keyword", "sizeof"], - ["keyword", "static"], - ["keyword", "struct"], ["class-name", "\r\ntrue"], - ["keyword", "type"], ["class-name", "\r\ntypeof"], - ["keyword", "union"], - ["keyword", "unsafe"] -] \ No newline at end of file From c64684632694b5b51ed0ba182eae50da7f5455b3 Mon Sep 17 00:00:00 2001 From: taggon Date: Fri, 8 Jan 2021 16:12:01 +0900 Subject: [PATCH 7/7] Fix string interpolation def --- components/prism-v.js | 136 ++++++++++++++------------ components/prism-v.min.js | 2 +- tests/languages/v/string_feature.test | 16 ++- 3 files changed, 84 insertions(+), 70 deletions(-) diff --git a/components/prism-v.js b/components/prism-v.js index b817b3909a..8a7cfde532 100644 --- a/components/prism-v.js +++ b/components/prism-v.js @@ -1,73 +1,79 @@ -Prism.languages.v = Prism.languages.extend('clike', { - 'string': [ - { - pattern: /`(?:\\\`|\\?[^\`]{1,2})`/, // using {1,2} instead of `u` flag for compatibility - alias: 'rune' - }, - { - pattern: /r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, - alias: 'quoted-string', - greedy: true, - inside: { - 'interpolation': { - pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/, - lookbehind: true, - inside: { - 'interpolation-variable': { - pattern: /^\$\w[\s\S]*$/, - alias: 'variable' - }, - 'interpolation-punctuation': { - pattern: /^\${|}$/, - alias: 'punctuation' - }, - 'interpolation-expression': { - pattern: /[\s\S]+/, - inside: Prism.languages.v +(function(Prism) { + var interpolationExpr = { + pattern: /[\s\S]+/, + inside: null + }; + + Prism.languages.v = Prism.languages.extend('clike', { + 'string': [ + { + pattern: /`(?:\\\`|\\?[^\`]{1,2})`/, // using {1,2} instead of `u` flag for compatibility + alias: 'rune' + }, + { + pattern: /r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + alias: 'quoted-string', + greedy: true, + inside: { + 'interpolation': { + pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/, + lookbehind: true, + inside: { + 'interpolation-variable': { + pattern: /^\$\w[\s\S]*$/, + alias: 'variable' + }, + 'interpolation-punctuation': { + pattern: /^\${|}$/, + alias: 'punctuation' + }, + 'interpolation-expression': interpolationExpr } } } } - } - ], - 'class-name': { - pattern: /(\b(?:enum|interface|struct|type)\s+)\w+/, - lookbehind: true - }, - 'keyword': /(?:\b(?:as|asm|assert|atomic|break|chan|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)|\$(?:if|else|for)|#(?:include|flag))\b/, - 'number': /\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i, - 'operator': /~|\?|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\.?/, - 'builtin': /\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|f(?:32|64)|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128)|voidptr)\b/ -}); + ], + 'class-name': { + pattern: /(\b(?:enum|interface|struct|type)\s+)(?:C\.)?[\w]+/, + lookbehind: true + }, + 'keyword': /(?:\b(?:as|asm|assert|atomic|break|chan|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)|\$(?:if|else|for)|#(?:include|flag))\b/, + 'number': /\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i, + 'operator': /~|\?|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\.?/, + 'builtin': /\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|f(?:32|64)|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128)|voidptr)\b/ + }); -Prism.languages.insertBefore('v', 'operator', { - 'attribute': { - pattern: /^\s*\[(?:deprecated|unsafe_fn|typedef|live|inline|flag|ref_only|windows_stdcall|direct_array_access)\]/m, - alias: 'annotation', - inside: { - 'punctuation': /[\[\]]/, - 'keyword': /\w+/ - } - }, - 'generic': { - pattern: /\<\w+\>(?=\s*[\)\{])/, - inside: { - 'punctuation': /[<>]/, - 'class-name': /\w+/ + interpolationExpr.inside = Prism.languages.v; + + Prism.languages.insertBefore('v', 'operator', { + 'attribute': { + pattern: /^\s*\[(?:deprecated|unsafe_fn|typedef|live|inline|flag|ref_only|windows_stdcall|direct_array_access)\]/m, + alias: 'annotation', + inside: { + 'punctuation': /[\[\]]/, + 'keyword': /\w+/ + } + }, + 'generic': { + pattern: /\<\w+\>(?=\s*[\)\{])/, + inside: { + 'punctuation': /[<>]/, + 'class-name': /\w+/ + } } - } -}); - -Prism.languages.insertBefore('v', 'function', { - 'generic-function': { - // e.g. foo( ... - pattern: /\w+\s*<\w+>(?=\()/, - inside: { - 'function': /^\w+/, - 'generic': { - pattern: /<\w+>/, - inside: Prism.languages.v.generic.inside + }); + + Prism.languages.insertBefore('v', 'function', { + 'generic-function': { + // e.g. foo( ... + pattern: /\w+\s*<\w+>(?=\()/, + inside: { + 'function': /^\w+/, + 'generic': { + pattern: /<\w+>/, + inside: Prism.languages.v.generic.inside + } } } - } -}); \ No newline at end of file + }); +})(Prism); \ No newline at end of file diff --git a/components/prism-v.min.js b/components/prism-v.min.js index 125ba3160e..0c6b4d52cf 100644 --- a/components/prism-v.min.js +++ b/components/prism-v.min.js @@ -1 +1 @@ -Prism.languages.v=Prism.languages.extend("clike",{string:[{pattern:/`(?:\\\`|\\?[^\`]{1,2})`/,alias:"rune"},{pattern:/r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,alias:"quoted-string",greedy:!0,inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/,lookbehind:!0,inside:{"interpolation-variable":{pattern:/^\$\w[\s\S]*$/,alias:"variable"},"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},"interpolation-expression":{pattern:/[\s\S]+/,inside:Prism.languages.v}}}}}],"class-name":{pattern:/(\b(?:enum|interface|struct|type)\s+)\w+/,lookbehind:!0},keyword:/(?:\b(?:as|asm|assert|atomic|break|chan|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)|\$(?:if|else|for)|#(?:include|flag))\b/,number:/\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i,operator:/~|\?|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\.?/,builtin:/\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|f(?:32|64)|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128)|voidptr)\b/}),Prism.languages.insertBefore("v","operator",{attribute:{pattern:/^\s*\[(?:deprecated|unsafe_fn|typedef|live|inline|flag|ref_only|windows_stdcall|direct_array_access)\]/m,alias:"annotation",inside:{punctuation:/[\[\]]/,keyword:/\w+/}},generic:{pattern:/\<\w+\>(?=\s*[\)\{])/,inside:{punctuation:/[<>]/,"class-name":/\w+/}}}),Prism.languages.insertBefore("v","function",{"generic-function":{pattern:/\w+\s*<\w+>(?=\()/,inside:{function:/^\w+/,generic:{pattern:/<\w+>/,inside:Prism.languages.v.generic.inside}}}}); \ No newline at end of file +!function(e){var n={pattern:/[\s\S]+/,inside:null};e.languages.v=e.languages.extend("clike",{string:[{pattern:/`(?:\\\`|\\?[^\`]{1,2})`/,alias:"rune"},{pattern:/r?(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,alias:"quoted-string",greedy:!0,inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:\{[^{}]*\}|\w+(?:\.\w+(?:\([^\(\)]*\))?|\[[^\[\]]+\])*)/,lookbehind:!0,inside:{"interpolation-variable":{pattern:/^\$\w[\s\S]*$/,alias:"variable"},"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},"interpolation-expression":n}}}}],"class-name":{pattern:/(\b(?:enum|interface|struct|type)\s+)(?:C\.)?[\w]+/,lookbehind:!0},keyword:/(?:\b(?:as|asm|assert|atomic|break|chan|const|continue|defer|else|embed|enum|fn|for|__global|go(?:to)?|if|import|in|interface|is|lock|match|module|mut|none|or|pub|return|rlock|select|shared|sizeof|static|struct|type(?:of)?|union|unsafe)|\$(?:if|else|for)|#(?:include|flag))\b/,number:/\b(?:0x[a-f\d]+(?:_[a-f\d]+)*|0b[01]+(?:_[01]+)*|0o[0-7]+(?:_[0-7]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?)\b/i,operator:/~|\?|[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\.?/,builtin:/\b(?:any(?:_int|_float)?|bool|byte(?:ptr)?|charptr|f(?:32|64)|i(?:8|16|nt|64|128)|rune|size_t|string|u(?:16|32|64|128)|voidptr)\b/}),n.inside=e.languages.v,e.languages.insertBefore("v","operator",{attribute:{pattern:/^\s*\[(?:deprecated|unsafe_fn|typedef|live|inline|flag|ref_only|windows_stdcall|direct_array_access)\]/m,alias:"annotation",inside:{punctuation:/[\[\]]/,keyword:/\w+/}},generic:{pattern:/\<\w+\>(?=\s*[\)\{])/,inside:{punctuation:/[<>]/,"class-name":/\w+/}}}),e.languages.insertBefore("v","function",{"generic-function":{pattern:/\w+\s*<\w+>(?=\()/,inside:{function:/^\w+/,generic:{pattern:/<\w+>/,inside:e.languages.v.generic.inside}}}})}(Prism); \ No newline at end of file diff --git a/tests/languages/v/string_feature.test b/tests/languages/v/string_feature.test index 9b7024611d..3040a7fc0d 100644 --- a/tests/languages/v/string_feature.test +++ b/tests/languages/v/string_feature.test @@ -1,7 +1,7 @@ "https://example.com" 'single quote' 'age = $user.age' -'x = ${x:4.2f}' +'[${int(x):-10}]' r'hello\nworld' `🚀` `\`` @@ -20,13 +20,21 @@ r'hello\nworld' "'" ]], ["string", [ - "'x = ", + "'[", ["interpolation", [ ["interpolation-punctuation", "${"], - ["interpolation-expression", "x:4.2f"], + ["interpolation-expression", [ + ["function", "int"], + ["punctuation", "("], + "x", + ["punctuation", ")"], + ["punctuation", ":"], + ["operator", "-"], + ["number", "10"] + ]], ["interpolation-punctuation", "}"] ]], - "'" + "]'" ]], ["string", ["r'hello\\nworld'"]], ["string", "`🚀`"],