From 482828e2ec0f7c0f070cd9472207ddecc9141f4a Mon Sep 17 00:00:00 2001 From: Arend van Beelen jr Date: Tue, 10 Nov 2020 16:55:34 +0100 Subject: [PATCH 1/9] Add PromQL language support --- components.js | 2 +- components.json | 4 + components/prism-promql.js | 170 ++++++++++++++++++ components/prism-promql.min.js | 1 + examples/prism-promql.html | 18 ++ plugins/show-language/prism-show-language.js | 1 + .../show-language/prism-show-language.min.js | 2 +- .../languages/promql/aggregate_selection.test | 29 +++ tests/languages/promql/comment_feature.test | 11 ++ .../languages/promql/subquery_selection.test | 38 ++++ .../promql/time_series_selection.test | 38 ++++ 11 files changed, 312 insertions(+), 2 deletions(-) create mode 100644 components/prism-promql.js create mode 100644 components/prism-promql.min.js create mode 100644 examples/prism-promql.html create mode 100644 tests/languages/promql/aggregate_selection.test create mode 100644 tests/languages/promql/comment_feature.test create mode 100644 tests/languages/promql/subquery_selection.test create mode 100644 tests/languages/promql/time_series_selection.test diff --git a/components.js b/components.js index bed22408b9..347beb8cc1 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"},"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"},"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","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"},"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"},"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"},"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","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"}}}; if (typeof module !== 'undefined' && module.exports) { module.exports = components; } \ No newline at end of file diff --git a/components.json b/components.json index bf1935df94..d7985f2742 100644 --- a/components.json +++ b/components.json @@ -875,6 +875,10 @@ "title": "Prolog", "owner": "Golmote" }, + "promql": { + "title": "PromQL", + "owner": "arendjr" + }, "properties": { "title": ".properties", "owner": "Golmote" diff --git a/components/prism-promql.js b/components/prism-promql.js new file mode 100644 index 0000000000..3f78daab3f --- /dev/null +++ b/components/prism-promql.js @@ -0,0 +1,170 @@ +// PromQL Aggregation Operators +// (https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators) +var aggregations = [ + "sum", + "min", + "max", + "avg", + "group", + "stddev", + "stdvar", + "count", + "count_values", + "bottomk", + "topk", + "quantile", +]; + +// PromQL functions +// (https://prometheus.io/docs/prometheus/latest/querying/functions/) +var functions = [ + "abs", + "absent", + "ceil", + "changes", + "clamp_max", + "clamp_min", + "day_of_month", + "day_of_week", + "days_in_month", + "delta", + "deriv", + "exp", + "floor", + "histogram_quantile", + "holt_winters", + "hour", + "idelta", + "increase", + "irate", + "label_join", + "label_replace", + "ln", + "log2", + "log10", + "minute", + "month", + "predict_linear", + "rate", + "resets", + "round", + "scalar", + "sort", + "sort_desc", + "sqrt", + "time", + "timestamp", + "vector", + "year", +]; + +// PromQL specific functions: Aggregations over time +// (https://prometheus.io/docs/prometheus/latest/querying/functions/#aggregation_over_time) +var aggregationsOverTime = []; +aggregations.forEach(function(agg) { + aggregationsOverTime.push(agg + "_over_time"); +}); + +// PromQL vector matching + the by and without clauses +// (https://prometheus.io/docs/prometheus/latest/querying/operators/#vector-matching) +var vectorMatching = [ + "on", + "ignoring", + "group_right", + "group_left", + "by", + "without", +]; + +// PromQL Operators +// (https://prometheus.io/docs/prometheus/latest/querying/operators/) +var operators = [ + "\\+", + "-", + "\\*", + "/", + "%", + "\\^", + "==", + "!=", + ">", + "<", + ">=", + "<=", + "and", + "or", + "unless", +]; + +// PromQL offset modifier +// (https://prometheus.io/docs/prometheus/latest/querying/basics/#offset-modifier) +var offsetModifier = ["offset"]; + +// Merging all the keywords in one list +var keywords = aggregations + .concat(functions) + .concat(aggregationsOverTime) + .concat(vectorMatching) + .concat(offsetModifier); + +Prism.languages.promql = { + comment: { + pattern: /^\s*#.*/m, + }, + "context-aggregation": { + pattern: new RegExp("((" + vectorMatching.join("|") + ")\\s*)\\([^)]*\\)"), + lookbehind: true, + inside: { + "label-key": { + pattern: /\b[^,]*\b/, + alias: "attr-name", + }, + }, + }, + "context-labels": { + pattern: /\{[^}]*\}/, + inside: { + "label-key": { + pattern: /[a-z_]\w*(?=\s*(?:=~?|![=~]))/, + alias: "attr-name", + }, + "label-value": { + pattern: /"(?:\\.|[^\\"])*"/, + alias: "attr-value", + }, + punctuation: /\{|\}|=~?|![=~]/, + }, + }, + function: new RegExp("\\b(?:" + keywords.join("|") + ")(?=\\s*\\()", "i"), + "context-range": [ + { + pattern: /(\[([^\]]*)\])/, // [1m] + inside: { + punctuation: /(\[|\])/, + "range-duration": { + pattern: /\b\d+[smhdwy]\b/i, + alias: "number", + }, + }, + }, + { + pattern: /(offset\s+)\w+/, // offset 1m + lookbehind: true, + inside: { + "range-duration": { + pattern: /\b\d+[smhdwy]\b/i, + alias: "number", + }, + }, + }, + ], + number: /-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/, + operator: new RegExp( + "/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:" + + operators.join("|") + + ")\\b", + "i" + ), + punctuation: /[{};()`,.[\]]/, +}; + \ No newline at end of file diff --git a/components/prism-promql.min.js b/components/prism-promql.min.js new file mode 100644 index 0000000000..5b415f9c7b --- /dev/null +++ b/components/prism-promql.min.js @@ -0,0 +1 @@ +var aggregations=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"],functions=["abs","absent","ceil","changes","clamp_max","clamp_min","day_of_month","day_of_week","days_in_month","delta","deriv","exp","floor","histogram_quantile","holt_winters","hour","idelta","increase","irate","label_join","label_replace","ln","log2","log10","minute","month","predict_linear","rate","resets","round","scalar","sort","sort_desc","sqrt","time","timestamp","vector","year"],aggregationsOverTime=[];aggregations.forEach(function(e){aggregationsOverTime.push(e+"_over_time")});var vectorMatching=["on","ignoring","group_right","group_left","by","without"],operators=["\\+","-","\\*","/","%","\\^","==","!=",">","<",">=","<=","and","or","unless"],offsetModifier=["offset"],keywords=aggregations.concat(functions).concat(aggregationsOverTime).concat(vectorMatching).concat(offsetModifier);Prism.languages.promql={comment:{pattern:/^\s*#.*/m},"context-aggregation":{pattern:new RegExp("(("+vectorMatching.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"}}},"context-labels":{pattern:/\{[^}]*\}/,inside:{"label-key":{pattern:/[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]/}},function:new RegExp("\\b(?:"+keywords.join("|")+")(?=\\s*\\()","i"),"context-range":[{pattern:/(\[([^\]]*)\])/,inside:{punctuation:/(\[|\])/,"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],number:/-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/,operator:new RegExp("/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:"+operators.join("|")+")\\b","i"),punctuation:/[{};()`,.[\]]/}; \ No newline at end of file diff --git a/examples/prism-promql.html b/examples/prism-promql.html new file mode 100644 index 0000000000..2c389f521b --- /dev/null +++ b/examples/prism-promql.html @@ -0,0 +1,18 @@ +

Examples

+

+# These examples are taken from: https://prometheus.io/docs/prometheus/latest/querying/examples/
+
+http_requests_total{job="apiserver", handler="/api/comments"}[5m]
+
+http_requests_total{job=~".*server"}
+
+max_over_time(deriv(rate(distance_covered_total[5s])[30s:5s])[10m:])
+
+sum by (job) (
+  rate(http_requests_total[5m])
+)
+
+sum by (app, proc) (
+  instance_memory_limit_bytes - instance_memory_usage_bytes
+) / 1024 / 1024
+
diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js index 672d991581..9ef73e3544 100644 --- a/plugins/show-language/prism-show-language.js +++ b/plugins/show-language/prism-show-language.js @@ -147,6 +147,7 @@ "pq": "PowerQuery", "mscript": "PowerQuery", "powershell": "PowerShell", + "promql": "PromQL", "properties": ".properties", "protobuf": "Protocol Buffers", "purebasic": "PureBasic", diff --git a/plugins/show-language/prism-show-language.min.js b/plugins/show-language/prism-show-language.min.js index 36298afbcd..85ce5f17b0 100644 --- a/plugins/show-language/prism-show-language.min.js +++ b/plugins/show-language/prism-show-language.min.js @@ -1 +1 @@ -!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var i={none:"Plain text",html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",ssml:"SSML",rss:"RSS",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"ABNF",al:"AL",antlr4:"ANTLR4",g4:"ANTLR4",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",aspnet:"ASP.NET (C#)",asm6502:"6502 Assembly",autohotkey:"AutoHotkey",autoit:"AutoIt",basic:"BASIC",bbcode:"BBcode",bnf:"BNF",rbnf:"RBNF",bsl:"BSL (1C:Enterprise)",oscript:"OneScript",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",cmake:"CMake",coffee:"CoffeeScript",conc:"Concurnas",csp:"Content-Security-Policy","css-extras":"CSS Extras",dax:"DAX",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"EBNF",editorconfig:"EditorConfig",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB","excel-formula":"Excel Formula",xlsx:"Excel Formula",xls:"Excel Formula",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",hlsl:"HLSL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",ignore:".ignore",gitignore:".gitignore",hgignore:".hgignore",npmignore:".npmignore",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras",json:"JSON",webmanifest:"Web App Manifest",json5:"JSON5",jsonp:"JSONP",jsstacktrace:"JS stack trace","js-templates":"JS Templates",kts:"Kotlin Script",kt:"Kotlin",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",llvm:"LLVM IR",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",mongodb:"MongoDB",moon:"MoonScript",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",naniscript:"Naninovel Script",nani:"Naninovel Script",nasm:"NASM",neon:"NEON",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",objc:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",peoplecode:"PeopleCode",pcode:"PeopleCode",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powerquery:"PowerQuery",pq:"PowerQuery",mscript:"PowerQuery",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",purebasic:"PureBasic",pbfasm:"PureBasic",purs:"PureScript",py:"Python",q:"Q (kdb+ database)",qml:"QML",rkt:"Racket",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rpy:"Ren'py",rest:"reST (reStructuredText)",robotframework:"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session","sh-session":"Shell session",shellsession:"Shell session",sml:"SML",smlnj:"SML/NJ",solidity:"Solidity (Ethereum)",sol:"Solidity (Ethereum)","solution-file":"Solution file",sln:"Solution file",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",sql:"SQL",iecst:"Structured Text (IEC 61131-3)","t4-templating":"T4 templating","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)",tap:"TAP",tt2:"Template Toolkit 2",toml:"TOML",trig:"TriG",ts:"TypeScript",tsconfig:"TSConfig",uscript:"UnrealScript",uc:"UnrealScript",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vba:"VBA",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube","xml-doc":"XML doc (.net)",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML",yang:"YANG"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s,t=a.getAttribute("data-language")||i[e.language]||((s=e.language)?(s.substring(0,1).toUpperCase()+s.substring(1)).replace(/s(?=cript)/,"S"):s);if(t){var o=document.createElement("span");return o.textContent=t,o}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}(); \ No newline at end of file +!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var r={none:"Plain text",html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",ssml:"SSML",rss:"RSS",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"ABNF",al:"AL",antlr4:"ANTLR4",g4:"ANTLR4",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",aspnet:"ASP.NET (C#)",asm6502:"6502 Assembly",autohotkey:"AutoHotkey",autoit:"AutoIt",basic:"BASIC",bbcode:"BBcode",bnf:"BNF",rbnf:"RBNF",bsl:"BSL (1C:Enterprise)",oscript:"OneScript",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",cmake:"CMake",coffee:"CoffeeScript",conc:"Concurnas",csp:"Content-Security-Policy","css-extras":"CSS Extras",dax:"DAX",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"EBNF",editorconfig:"EditorConfig",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB","excel-formula":"Excel Formula",xlsx:"Excel Formula",xls:"Excel Formula",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",hlsl:"HLSL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",ignore:".ignore",gitignore:".gitignore",hgignore:".hgignore",npmignore:".npmignore",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras",json:"JSON",webmanifest:"Web App Manifest",json5:"JSON5",jsonp:"JSONP",jsstacktrace:"JS stack trace","js-templates":"JS Templates",kts:"Kotlin Script",kt:"Kotlin",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",llvm:"LLVM IR",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",mongodb:"MongoDB",moon:"MoonScript",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",naniscript:"Naninovel Script",nani:"Naninovel Script",nasm:"NASM",neon:"NEON",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",objc:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",peoplecode:"PeopleCode",pcode:"PeopleCode",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powerquery:"PowerQuery",pq:"PowerQuery",mscript:"PowerQuery",powershell:"PowerShell",promql:"PromQL",properties:".properties",protobuf:"Protocol Buffers",purebasic:"PureBasic",pbfasm:"PureBasic",purs:"PureScript",py:"Python",q:"Q (kdb+ database)",qml:"QML",rkt:"Racket",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rpy:"Ren'py",rest:"reST (reStructuredText)",robotframework:"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session","sh-session":"Shell session",shellsession:"Shell session",sml:"SML",smlnj:"SML/NJ",solidity:"Solidity (Ethereum)",sol:"Solidity (Ethereum)","solution-file":"Solution file",sln:"Solution file",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",sql:"SQL",iecst:"Structured Text (IEC 61131-3)","t4-templating":"T4 templating","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)",tap:"TAP",tt2:"Template Toolkit 2",toml:"TOML",trig:"TriG",ts:"TypeScript",tsconfig:"TSConfig",uscript:"UnrealScript",uc:"UnrealScript",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vba:"VBA",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube","xml-doc":"XML doc (.net)",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML",yang:"YANG"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s,t=a.getAttribute("data-language")||r[e.language]||((s=e.language)?(s.substring(0,1).toUpperCase()+s.substring(1)).replace(/s(?=cript)/,"S"):s);if(t){var o=document.createElement("span");return o.textContent=t,o}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}(); \ No newline at end of file diff --git a/tests/languages/promql/aggregate_selection.test b/tests/languages/promql/aggregate_selection.test new file mode 100644 index 0000000000..00de0aad7e --- /dev/null +++ b/tests/languages/promql/aggregate_selection.test @@ -0,0 +1,29 @@ +sum by (job) ( + rate(http_requests_total[5m]) +) + +---------------------------------------------------- + +[ + "sum by ", + ["context-aggregation", [ + "(", + ["label-key", "job"], + ")" + ]], + ["punctuation", "("], + ["function", "rate"], + ["punctuation", "("], + "http_requests_total", + ["context-range", [ + ["punctuation", "["], + ["range-duration", "5m"], + ["punctuation", "]"] + ]], + ["punctuation", ")"], + ["punctuation", ")"] +] + +---------------------------------------------------- + +Checks aggregate query. diff --git a/tests/languages/promql/comment_feature.test b/tests/languages/promql/comment_feature.test new file mode 100644 index 0000000000..fdd069abcc --- /dev/null +++ b/tests/languages/promql/comment_feature.test @@ -0,0 +1,11 @@ +# These examples are taken from ... + +---------------------------------------------------- + +[ + ["comment", "# These examples are taken from ..."] +] + +---------------------------------------------------- + +Checks for comments. diff --git a/tests/languages/promql/subquery_selection.test b/tests/languages/promql/subquery_selection.test new file mode 100644 index 0000000000..39c206decd --- /dev/null +++ b/tests/languages/promql/subquery_selection.test @@ -0,0 +1,38 @@ +max_over_time(deriv(rate(distance_covered_total[5s])[30s:5s])[10m:]) + +---------------------------------------------------- + +[ + ["function", "max_over_time"], + ["punctuation", "("], + ["function", "deriv"], + ["punctuation", "("], + ["function", "rate"], + ["punctuation", "("], + "distance_covered_total", + ["context-range", [ + ["punctuation", "["], + ["range-duration", "5s"], + ["punctuation", "]"] + ]], + ["punctuation", ")"], + ["context-range", [ + ["punctuation", "["], + ["range-duration", "30s"], + ":", + ["range-duration", "5s"], + ["punctuation", "]"] + ]], + ["punctuation", ")"], + ["context-range", [ + ["punctuation", "["], + ["range-duration", "10m"], + ":", + ["punctuation", "]"] + ]], + ["punctuation", ")"] +] + +---------------------------------------------------- + +Checks subquery. diff --git a/tests/languages/promql/time_series_selection.test b/tests/languages/promql/time_series_selection.test new file mode 100644 index 0000000000..bfa677e8f0 --- /dev/null +++ b/tests/languages/promql/time_series_selection.test @@ -0,0 +1,38 @@ +http_requests_total{job="apiserver", handler="/api/comments"}[5m] + +http_requests_total{job=~".*server"} + +---------------------------------------------------- + +[ + "http_requests_total", + ["context-labels", [ + ["punctuation", "{"], + ["label-key", "job"], + ["punctuation", "="], + ["label-value", "\"apiserver\""], + ", ", + ["label-key", "handler"], + ["punctuation", "="], + ["label-value", "\"/api/comments\""], + ["punctuation", "}"] + ]], + ["context-range", [ + ["punctuation", "["], + ["range-duration", "5m"], + ["punctuation", "]"] + ]], + + "\r\n\r\nhttp_requests_total", + ["context-labels", [ + ["punctuation", "{"], + ["label-key", "job"], + ["punctuation", "=~"], + ["label-value", "\".*server\""], + ["punctuation", "}"] + ]] +] + +---------------------------------------------------- + +Checks simple time series queries. From d66f50e13c377b3930d540515ef1156d356ac186 Mon Sep 17 00:00:00 2001 From: Arend van Beelen jr Date: Tue, 10 Nov 2020 16:59:13 +0100 Subject: [PATCH 2/9] Add recognization --- components/prism-promql.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/prism-promql.js b/components/prism-promql.js index 3f78daab3f..6027708895 100644 --- a/components/prism-promql.js +++ b/components/prism-promql.js @@ -1,3 +1,6 @@ +// Thanks to: https://github.com/prometheus-community/monaco-promql/blob/master/src/promql/promql.ts +// As well as: https://kausal.co/blog/slate-prism-add-new-syntax-promql/ + // PromQL Aggregation Operators // (https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators) var aggregations = [ From 7e02aaa247354ff0952fae8817c5ae6e3a77c87c Mon Sep 17 00:00:00 2001 From: Arend van Beelen jr Date: Tue, 10 Nov 2020 17:08:52 +0100 Subject: [PATCH 3/9] Fix regex performance suggestions --- components/prism-promql.js | 8 ++++---- components/prism-promql.min.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/prism-promql.js b/components/prism-promql.js index 6027708895..b5b30cf68a 100644 --- a/components/prism-promql.js +++ b/components/prism-promql.js @@ -115,7 +115,7 @@ Prism.languages.promql = { pattern: /^\s*#.*/m, }, "context-aggregation": { - pattern: new RegExp("((" + vectorMatching.join("|") + ")\\s*)\\([^)]*\\)"), + pattern: new RegExp("((?:" + vectorMatching.join("|") + ")\\s*)\\([^)]*\\)"), lookbehind: true, inside: { "label-key": { @@ -141,9 +141,9 @@ Prism.languages.promql = { function: new RegExp("\\b(?:" + keywords.join("|") + ")(?=\\s*\\()", "i"), "context-range": [ { - pattern: /(\[([^\]]*)\])/, // [1m] + pattern: /\[[^\]]*\]/, // [1m] inside: { - punctuation: /(\[|\])/, + punctuation: /\[|\]/, "range-duration": { pattern: /\b\d+[smhdwy]\b/i, alias: "number", @@ -161,7 +161,7 @@ Prism.languages.promql = { }, }, ], - number: /-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/, + number: /-?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/, operator: new RegExp( "/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:" + operators.join("|") + diff --git a/components/prism-promql.min.js b/components/prism-promql.min.js index 5b415f9c7b..2743417828 100644 --- a/components/prism-promql.min.js +++ b/components/prism-promql.min.js @@ -1 +1 @@ -var aggregations=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"],functions=["abs","absent","ceil","changes","clamp_max","clamp_min","day_of_month","day_of_week","days_in_month","delta","deriv","exp","floor","histogram_quantile","holt_winters","hour","idelta","increase","irate","label_join","label_replace","ln","log2","log10","minute","month","predict_linear","rate","resets","round","scalar","sort","sort_desc","sqrt","time","timestamp","vector","year"],aggregationsOverTime=[];aggregations.forEach(function(e){aggregationsOverTime.push(e+"_over_time")});var vectorMatching=["on","ignoring","group_right","group_left","by","without"],operators=["\\+","-","\\*","/","%","\\^","==","!=",">","<",">=","<=","and","or","unless"],offsetModifier=["offset"],keywords=aggregations.concat(functions).concat(aggregationsOverTime).concat(vectorMatching).concat(offsetModifier);Prism.languages.promql={comment:{pattern:/^\s*#.*/m},"context-aggregation":{pattern:new RegExp("(("+vectorMatching.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"}}},"context-labels":{pattern:/\{[^}]*\}/,inside:{"label-key":{pattern:/[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]/}},function:new RegExp("\\b(?:"+keywords.join("|")+")(?=\\s*\\()","i"),"context-range":[{pattern:/(\[([^\]]*)\])/,inside:{punctuation:/(\[|\])/,"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],number:/-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/,operator:new RegExp("/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:"+operators.join("|")+")\\b","i"),punctuation:/[{};()`,.[\]]/}; \ No newline at end of file +var aggregations=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"],functions=["abs","absent","ceil","changes","clamp_max","clamp_min","day_of_month","day_of_week","days_in_month","delta","deriv","exp","floor","histogram_quantile","holt_winters","hour","idelta","increase","irate","label_join","label_replace","ln","log2","log10","minute","month","predict_linear","rate","resets","round","scalar","sort","sort_desc","sqrt","time","timestamp","vector","year"],aggregationsOverTime=[];aggregations.forEach(function(e){aggregationsOverTime.push(e+"_over_time")});var vectorMatching=["on","ignoring","group_right","group_left","by","without"],operators=["\\+","-","\\*","/","%","\\^","==","!=",">","<",">=","<=","and","or","unless"],offsetModifier=["offset"],keywords=aggregations.concat(functions).concat(aggregationsOverTime).concat(vectorMatching).concat(offsetModifier);Prism.languages.promql={comment:{pattern:/^\s*#.*/m},"context-aggregation":{pattern:new RegExp("((?:"+vectorMatching.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"}}},"context-labels":{pattern:/\{[^}]*\}/,inside:{"label-key":{pattern:/[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]/}},function:new RegExp("\\b(?:"+keywords.join("|")+")(?=\\s*\\()","i"),"context-range":[{pattern:/\[[^\]]*\]/,inside:{punctuation:/\[|\]/,"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],number:/-?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/,operator:new RegExp("/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:"+operators.join("|")+")\\b","i"),punctuation:/[{};()`,.[\]]/}; \ No newline at end of file From c4af08a380033c5ae230155419be877137489608 Mon Sep 17 00:00:00 2001 From: Arend van Beelen jr Date: Tue, 10 Nov 2020 17:11:56 +0100 Subject: [PATCH 4/9] Fix numbers in identifiers --- components/prism-promql.js | 2 +- components/prism-promql.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-promql.js b/components/prism-promql.js index b5b30cf68a..c318ef248d 100644 --- a/components/prism-promql.js +++ b/components/prism-promql.js @@ -161,7 +161,7 @@ Prism.languages.promql = { }, }, ], - number: /-?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/, + number: /\b-?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/, operator: new RegExp( "/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:" + operators.join("|") + diff --git a/components/prism-promql.min.js b/components/prism-promql.min.js index 2743417828..d4cfb18864 100644 --- a/components/prism-promql.min.js +++ b/components/prism-promql.min.js @@ -1 +1 @@ -var aggregations=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"],functions=["abs","absent","ceil","changes","clamp_max","clamp_min","day_of_month","day_of_week","days_in_month","delta","deriv","exp","floor","histogram_quantile","holt_winters","hour","idelta","increase","irate","label_join","label_replace","ln","log2","log10","minute","month","predict_linear","rate","resets","round","scalar","sort","sort_desc","sqrt","time","timestamp","vector","year"],aggregationsOverTime=[];aggregations.forEach(function(e){aggregationsOverTime.push(e+"_over_time")});var vectorMatching=["on","ignoring","group_right","group_left","by","without"],operators=["\\+","-","\\*","/","%","\\^","==","!=",">","<",">=","<=","and","or","unless"],offsetModifier=["offset"],keywords=aggregations.concat(functions).concat(aggregationsOverTime).concat(vectorMatching).concat(offsetModifier);Prism.languages.promql={comment:{pattern:/^\s*#.*/m},"context-aggregation":{pattern:new RegExp("((?:"+vectorMatching.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"}}},"context-labels":{pattern:/\{[^}]*\}/,inside:{"label-key":{pattern:/[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]/}},function:new RegExp("\\b(?:"+keywords.join("|")+")(?=\\s*\\()","i"),"context-range":[{pattern:/\[[^\]]*\]/,inside:{punctuation:/\[|\]/,"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],number:/-?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/,operator:new RegExp("/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:"+operators.join("|")+")\\b","i"),punctuation:/[{};()`,.[\]]/}; \ No newline at end of file +var aggregations=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"],functions=["abs","absent","ceil","changes","clamp_max","clamp_min","day_of_month","day_of_week","days_in_month","delta","deriv","exp","floor","histogram_quantile","holt_winters","hour","idelta","increase","irate","label_join","label_replace","ln","log2","log10","minute","month","predict_linear","rate","resets","round","scalar","sort","sort_desc","sqrt","time","timestamp","vector","year"],aggregationsOverTime=[];aggregations.forEach(function(e){aggregationsOverTime.push(e+"_over_time")});var vectorMatching=["on","ignoring","group_right","group_left","by","without"],operators=["\\+","-","\\*","/","%","\\^","==","!=",">","<",">=","<=","and","or","unless"],offsetModifier=["offset"],keywords=aggregations.concat(functions).concat(aggregationsOverTime).concat(vectorMatching).concat(offsetModifier);Prism.languages.promql={comment:{pattern:/^\s*#.*/m},"context-aggregation":{pattern:new RegExp("((?:"+vectorMatching.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"}}},"context-labels":{pattern:/\{[^}]*\}/,inside:{"label-key":{pattern:/[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]/}},function:new RegExp("\\b(?:"+keywords.join("|")+")(?=\\s*\\()","i"),"context-range":[{pattern:/\[[^\]]*\]/,inside:{punctuation:/\[|\]/,"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],number:/\b-?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/,operator:new RegExp("/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:"+operators.join("|")+")\\b","i"),punctuation:/[{};()`,.[\]]/}; \ No newline at end of file From 74863334add06d5d01d44bb62e799e3f631c03a5 Mon Sep 17 00:00:00 2001 From: Arend van Beelen jr Date: Tue, 10 Nov 2020 21:45:24 +0100 Subject: [PATCH 5/9] Address PR feedback --- components/prism-promql.js | 291 ++++++++---------- components/prism-promql.min.js | 2 +- .../languages/promql/aggregate_selection.test | 9 +- .../languages/promql/subquery_selection.test | 4 +- .../promql/time_series_selection.test | 2 +- 5 files changed, 142 insertions(+), 166 deletions(-) diff --git a/components/prism-promql.js b/components/prism-promql.js index c318ef248d..dbdf47b11b 100644 --- a/components/prism-promql.js +++ b/components/prism-promql.js @@ -1,173 +1,148 @@ // Thanks to: https://github.com/prometheus-community/monaco-promql/blob/master/src/promql/promql.ts // As well as: https://kausal.co/blog/slate-prism-add-new-syntax-promql/ -// PromQL Aggregation Operators -// (https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators) -var aggregations = [ - "sum", - "min", - "max", - "avg", - "group", - "stddev", - "stdvar", - "count", - "count_values", - "bottomk", - "topk", - "quantile", -]; +(function (Prism) { + // PromQL Aggregation Operators + // (https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators) + var aggregations = [ + 'sum', + 'min', + 'max', + 'avg', + 'group', + 'stddev', + 'stdvar', + 'count', + 'count_values', + 'bottomk', + 'topk', + 'quantile' + ]; -// PromQL functions -// (https://prometheus.io/docs/prometheus/latest/querying/functions/) -var functions = [ - "abs", - "absent", - "ceil", - "changes", - "clamp_max", - "clamp_min", - "day_of_month", - "day_of_week", - "days_in_month", - "delta", - "deriv", - "exp", - "floor", - "histogram_quantile", - "holt_winters", - "hour", - "idelta", - "increase", - "irate", - "label_join", - "label_replace", - "ln", - "log2", - "log10", - "minute", - "month", - "predict_linear", - "rate", - "resets", - "round", - "scalar", - "sort", - "sort_desc", - "sqrt", - "time", - "timestamp", - "vector", - "year", -]; - -// PromQL specific functions: Aggregations over time -// (https://prometheus.io/docs/prometheus/latest/querying/functions/#aggregation_over_time) -var aggregationsOverTime = []; -aggregations.forEach(function(agg) { - aggregationsOverTime.push(agg + "_over_time"); -}); - -// PromQL vector matching + the by and without clauses -// (https://prometheus.io/docs/prometheus/latest/querying/operators/#vector-matching) -var vectorMatching = [ - "on", - "ignoring", - "group_right", - "group_left", - "by", - "without", -]; - -// PromQL Operators -// (https://prometheus.io/docs/prometheus/latest/querying/operators/) -var operators = [ - "\\+", - "-", - "\\*", - "/", - "%", - "\\^", - "==", - "!=", - ">", - "<", - ">=", - "<=", - "and", - "or", - "unless", -]; + // PromQL functions + // (https://prometheus.io/docs/prometheus/latest/querying/functions/) + var functions = [ + 'abs', + 'absent', + 'ceil', + 'changes', + 'clamp_max', + 'clamp_min', + 'day_of_month', + 'day_of_week', + 'days_in_month', + 'delta', + 'deriv', + 'exp', + 'floor', + 'histogram_quantile', + 'holt_winters', + 'hour', + 'idelta', + 'increase', + 'irate', + 'label_join', + 'label_replace', + 'ln', + 'log2', + 'log10', + 'minute', + 'month', + 'predict_linear', + 'rate', + 'resets', + 'round', + 'scalar', + 'sort', + 'sort_desc', + 'sqrt', + 'time', + 'timestamp', + 'vector', + 'year' + ]; -// PromQL offset modifier -// (https://prometheus.io/docs/prometheus/latest/querying/basics/#offset-modifier) -var offsetModifier = ["offset"]; + // PromQL specific functions: Aggregations over time + // (https://prometheus.io/docs/prometheus/latest/querying/functions/#aggregation_over_time) + aggregations.forEach(function (agg) { + functions.push(agg + '_over_time'); + }); -// Merging all the keywords in one list -var keywords = aggregations - .concat(functions) - .concat(aggregationsOverTime) - .concat(vectorMatching) - .concat(offsetModifier); - -Prism.languages.promql = { - comment: { - pattern: /^\s*#.*/m, - }, - "context-aggregation": { - pattern: new RegExp("((?:" + vectorMatching.join("|") + ")\\s*)\\([^)]*\\)"), - lookbehind: true, - inside: { - "label-key": { - pattern: /\b[^,]*\b/, - alias: "attr-name", - }, - }, - }, - "context-labels": { - pattern: /\{[^}]*\}/, - inside: { - "label-key": { - pattern: /[a-z_]\w*(?=\s*(?:=~?|![=~]))/, - alias: "attr-name", - }, - "label-value": { - pattern: /"(?:\\.|[^\\"])*"/, - alias: "attr-value", - }, - punctuation: /\{|\}|=~?|![=~]/, + // PromQL vector matching + the by and without clauses + // (https://prometheus.io/docs/prometheus/latest/querying/operators/#vector-matching) + var vectorMatching = [ + 'on', + 'ignoring', + 'group_right', + 'group_left', + 'by', + 'without', + ]; + + // PromQL offset modifier + // (https://prometheus.io/docs/prometheus/latest/querying/basics/#offset-modifier) + var offsetModifier = ['offset']; + + var keywords = aggregations.concat(vectorMatching, offsetModifier); + + Prism.languages.promql = { + 'comment': { + pattern: /(^[ \t]*)#.*/m, + lookbehind: true }, - }, - function: new RegExp("\\b(?:" + keywords.join("|") + ")(?=\\s*\\()", "i"), - "context-range": [ - { - pattern: /\[[^\]]*\]/, // [1m] + 'vector-match': { + // Match the comma-separated label lists inside vector matching: + pattern: new RegExp('((?:' + vectorMatching.join('|') + ')\\s*)\\([^)]*\\)'), + lookbehind: true, inside: { - punctuation: /\[|\]/, - "range-duration": { - pattern: /\b\d+[smhdwy]\b/i, - alias: "number", + 'label-key': { + pattern: /\b[^,]*\b/, + alias: 'attr-name', }, + 'punctuation': /[(),]/ }, }, - { - pattern: /(offset\s+)\w+/, // offset 1m - lookbehind: true, + 'context-labels': { + pattern: /\{[^{}]*\}/, inside: { - "range-duration": { - pattern: /\b\d+[smhdwy]\b/i, - alias: "number", + 'label-key': { + pattern: /\b[a-z_]\w*(?=\s*(?:=~?|![=~]))/, + alias: 'attr-name', }, + 'label-value': { + pattern: /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/, + greedy: true, + alias: 'attr-value', + }, + 'punctuation': /\{|\}|=~?|![=~]|,/, }, }, - ], - number: /\b-?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/, - operator: new RegExp( - "/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:" + - operators.join("|") + - ")\\b", - "i" - ), - punctuation: /[{};()`,.[\]]/, -}; - \ No newline at end of file + 'context-range': [ + { + pattern: /\[[\w\s:]+\]/, // [1m] + inside: { + 'punctuation': /\[|\]|:/, + 'range-duration': { + pattern: /\b(?:\d+(?:[smhdwy]|ms))+\b/i, + alias: 'number', + }, + }, + }, + { + pattern: /(\boffset\s+)\w+/, // offset 1m + lookbehind: true, + inside: { + 'range-duration': { + pattern: /\b(?:\d+(?:[smhdwy]|ms))+\b/i, + alias: 'number', + }, + }, + }, + ], + 'function': new RegExp('\\b(?:' + functions.join('|') + ')(?=\\s*\\()', 'i'), + 'keyword': new RegExp('\\b(?:' + keywords.join('|') + ')\\b', 'i'), + 'number': /[-+]?(?:(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e[-+]?\d+)?\b|\b(?:0x[0-9a-f]+|nan|inf)\b)/i, + 'operator': /[\^*/%+-]|==|!=|<=|<|>=|>|\b(?:and|unless|or)\b/i, + 'punctuation': /[{};()`,.[\]]/, + }; +})(Prism); diff --git a/components/prism-promql.min.js b/components/prism-promql.min.js index d4cfb18864..ddff8433ba 100644 --- a/components/prism-promql.min.js +++ b/components/prism-promql.min.js @@ -1 +1 @@ -var aggregations=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"],functions=["abs","absent","ceil","changes","clamp_max","clamp_min","day_of_month","day_of_week","days_in_month","delta","deriv","exp","floor","histogram_quantile","holt_winters","hour","idelta","increase","irate","label_join","label_replace","ln","log2","log10","minute","month","predict_linear","rate","resets","round","scalar","sort","sort_desc","sqrt","time","timestamp","vector","year"],aggregationsOverTime=[];aggregations.forEach(function(e){aggregationsOverTime.push(e+"_over_time")});var vectorMatching=["on","ignoring","group_right","group_left","by","without"],operators=["\\+","-","\\*","/","%","\\^","==","!=",">","<",">=","<=","and","or","unless"],offsetModifier=["offset"],keywords=aggregations.concat(functions).concat(aggregationsOverTime).concat(vectorMatching).concat(offsetModifier);Prism.languages.promql={comment:{pattern:/^\s*#.*/m},"context-aggregation":{pattern:new RegExp("((?:"+vectorMatching.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"}}},"context-labels":{pattern:/\{[^}]*\}/,inside:{"label-key":{pattern:/[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]/}},function:new RegExp("\\b(?:"+keywords.join("|")+")(?=\\s*\\()","i"),"context-range":[{pattern:/\[[^\]]*\]/,inside:{punctuation:/\[|\]/,"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],number:/\b-?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/,operator:new RegExp("/[-+/%^*~]|=~?|![=~]|&&?|(?:\\|\\|?)|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:"+operators.join("|")+")\\b","i"),punctuation:/[{};()`,.[\]]/}; \ No newline at end of file +!function(e){var t=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"],a=["abs","absent","ceil","changes","clamp_max","clamp_min","day_of_month","day_of_week","days_in_month","delta","deriv","exp","floor","histogram_quantile","holt_winters","hour","idelta","increase","irate","label_join","label_replace","ln","log2","log10","minute","month","predict_linear","rate","resets","round","scalar","sort","sort_desc","sqrt","time","timestamp","vector","year"];t.forEach(function(e){a.push(e+"_over_time")});var n=["on","ignoring","group_right","group_left","by","without"],o=t.concat(n,["offset"]);e.languages.promql={comment:{pattern:/(^[ \t]*)#.*/m,lookbehind:!0},"vector-match":{pattern:new RegExp("((?:"+n.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"},punctuation:/[(),]/}},"context-labels":{pattern:/\{[^{}]*\}/,inside:{"label-key":{pattern:/\b[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/,greedy:!0,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]|,/}},"context-range":[{pattern:/\[[\w\s:]+\]/,inside:{punctuation:/\[|\]|:/,"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}},{pattern:/(\boffset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}}],function:new RegExp("\\b(?:"+a.join("|")+")(?=\\s*\\()","i"),keyword:new RegExp("\\b(?:"+o.join("|")+")\\b","i"),number:/[-+]?(?:(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e[-+]?\d+)?\b|\b(?:0x[0-9a-f]+|nan|inf)\b)/i,operator:/[\^*/%+-]|==|!=|<=|<|>=|>|\b(?:and|unless|or)\b/i,punctuation:/[{};()`,.[\]]/}}(Prism); \ No newline at end of file diff --git a/tests/languages/promql/aggregate_selection.test b/tests/languages/promql/aggregate_selection.test index 00de0aad7e..8e4ea3f05c 100644 --- a/tests/languages/promql/aggregate_selection.test +++ b/tests/languages/promql/aggregate_selection.test @@ -5,11 +5,12 @@ sum by (job) ( ---------------------------------------------------- [ - "sum by ", - ["context-aggregation", [ - "(", + ["keyword", "sum"], + ["keyword", "by"], + ["vector-match", [ + ["punctuation", "("], ["label-key", "job"], - ")" + ["punctuation", ")"] ]], ["punctuation", "("], ["function", "rate"], diff --git a/tests/languages/promql/subquery_selection.test b/tests/languages/promql/subquery_selection.test index 39c206decd..f8340b19c8 100644 --- a/tests/languages/promql/subquery_selection.test +++ b/tests/languages/promql/subquery_selection.test @@ -19,7 +19,7 @@ max_over_time(deriv(rate(distance_covered_total[5s])[30s:5s])[10m:]) ["context-range", [ ["punctuation", "["], ["range-duration", "30s"], - ":", + ["punctuation", ":"], ["range-duration", "5s"], ["punctuation", "]"] ]], @@ -27,7 +27,7 @@ max_over_time(deriv(rate(distance_covered_total[5s])[30s:5s])[10m:]) ["context-range", [ ["punctuation", "["], ["range-duration", "10m"], - ":", + ["punctuation", ":"], ["punctuation", "]"] ]], ["punctuation", ")"] diff --git a/tests/languages/promql/time_series_selection.test b/tests/languages/promql/time_series_selection.test index bfa677e8f0..dc7edbe954 100644 --- a/tests/languages/promql/time_series_selection.test +++ b/tests/languages/promql/time_series_selection.test @@ -11,7 +11,7 @@ http_requests_total{job=~".*server"} ["label-key", "job"], ["punctuation", "="], ["label-value", "\"apiserver\""], - ", ", + ["punctuation", ","], ["label-key", "handler"], ["punctuation", "="], ["label-value", "\"/api/comments\""], From ab12d10ee764ee6c338f7f1d0d500c53e8029ce3 Mon Sep 17 00:00:00 2001 From: Arend van Beelen jr Date: Tue, 10 Nov 2020 22:18:09 +0100 Subject: [PATCH 6/9] Clean-up example. Co-authored-by: Michael Schmidt --- examples/prism-promql.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/prism-promql.html b/examples/prism-promql.html index 2c389f521b..5570bbda63 100644 --- a/examples/prism-promql.html +++ b/examples/prism-promql.html @@ -1,6 +1,5 @@

Examples

-

-# These examples are taken from: https://prometheus.io/docs/prometheus/latest/querying/examples/
+
# These examples are taken from: https://prometheus.io/docs/prometheus/latest/querying/examples/
 
 http_requests_total{job="apiserver", handler="/api/comments"}[5m]
 

From b575d4a7db5407f2042ca21399690ae7e3cc3075 Mon Sep 17 00:00:00 2001
From: Arend van Beelen jr 
Date: Thu, 12 Nov 2020 17:28:31 +0100
Subject: [PATCH 7/9] Generalize function highlighting

---
 components/prism-promql.js     | 51 +---------------------------------
 components/prism-promql.min.js |  2 +-
 2 files changed, 2 insertions(+), 51 deletions(-)

diff --git a/components/prism-promql.js b/components/prism-promql.js
index dbdf47b11b..8f94e74d7e 100644
--- a/components/prism-promql.js
+++ b/components/prism-promql.js
@@ -19,55 +19,6 @@
 		'quantile'
 	];
 
-	// PromQL functions
-	// (https://prometheus.io/docs/prometheus/latest/querying/functions/)
-	var functions = [
-		'abs',
-		'absent',
-		'ceil',
-		'changes',
-		'clamp_max',
-		'clamp_min',
-		'day_of_month',
-		'day_of_week',
-		'days_in_month',
-		'delta',
-		'deriv',
-		'exp',
-		'floor',
-		'histogram_quantile',
-		'holt_winters',
-		'hour',
-		'idelta',
-		'increase',
-		'irate',
-		'label_join',
-		'label_replace',
-		'ln',
-		'log2',
-		'log10',
-		'minute',
-		'month',
-		'predict_linear',
-		'rate',
-		'resets',
-		'round',
-		'scalar',
-		'sort',
-		'sort_desc',
-		'sqrt',
-		'time',
-		'timestamp',
-		'vector',
-		'year'
-	];
-
-	// PromQL specific functions: Aggregations over time
-	// (https://prometheus.io/docs/prometheus/latest/querying/functions/#aggregation_over_time)
-	aggregations.forEach(function (agg) {
-		functions.push(agg + '_over_time');
-	});
-
 	// PromQL vector matching + the by and without clauses
 	// (https://prometheus.io/docs/prometheus/latest/querying/operators/#vector-matching)
 	var vectorMatching = [
@@ -139,7 +90,7 @@
 				},
 			},
 		],
-		'function': new RegExp('\\b(?:' + functions.join('|') + ')(?=\\s*\\()', 'i'),
+		'function': /\b[a-zA-Z_]\w*(?=\s*\()/i,
 		'keyword': new RegExp('\\b(?:' + keywords.join('|') + ')\\b', 'i'),
 		'number': /[-+]?(?:(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e[-+]?\d+)?\b|\b(?:0x[0-9a-f]+|nan|inf)\b)/i,
 		'operator': /[\^*/%+-]|==|!=|<=|<|>=|>|\b(?:and|unless|or)\b/i,
diff --git a/components/prism-promql.min.js b/components/prism-promql.min.js
index ddff8433ba..0fd320bb7d 100644
--- a/components/prism-promql.min.js
+++ b/components/prism-promql.min.js
@@ -1 +1 @@
-!function(e){var t=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"],a=["abs","absent","ceil","changes","clamp_max","clamp_min","day_of_month","day_of_week","days_in_month","delta","deriv","exp","floor","histogram_quantile","holt_winters","hour","idelta","increase","irate","label_join","label_replace","ln","log2","log10","minute","month","predict_linear","rate","resets","round","scalar","sort","sort_desc","sqrt","time","timestamp","vector","year"];t.forEach(function(e){a.push(e+"_over_time")});var n=["on","ignoring","group_right","group_left","by","without"],o=t.concat(n,["offset"]);e.languages.promql={comment:{pattern:/(^[ \t]*)#.*/m,lookbehind:!0},"vector-match":{pattern:new RegExp("((?:"+n.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"},punctuation:/[(),]/}},"context-labels":{pattern:/\{[^{}]*\}/,inside:{"label-key":{pattern:/\b[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/,greedy:!0,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]|,/}},"context-range":[{pattern:/\[[\w\s:]+\]/,inside:{punctuation:/\[|\]|:/,"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}},{pattern:/(\boffset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}}],function:new RegExp("\\b(?:"+a.join("|")+")(?=\\s*\\()","i"),keyword:new RegExp("\\b(?:"+o.join("|")+")\\b","i"),number:/[-+]?(?:(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e[-+]?\d+)?\b|\b(?:0x[0-9a-f]+|nan|inf)\b)/i,operator:/[\^*/%+-]|==|!=|<=|<|>=|>|\b(?:and|unless|or)\b/i,punctuation:/[{};()`,.[\]]/}}(Prism);
\ No newline at end of file
+!function(t){var n=["on","ignoring","group_right","group_left","by","without"],a=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"].concat(n,["offset"]);t.languages.promql={comment:{pattern:/(^[ \t]*)#.*/m,lookbehind:!0},"vector-match":{pattern:new RegExp("((?:"+n.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"},punctuation:/[(),]/}},"context-labels":{pattern:/\{[^{}]*\}/,inside:{"label-key":{pattern:/\b[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/,greedy:!0,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]|,/}},"context-range":[{pattern:/\[[\w\s:]+\]/,inside:{punctuation:/\[|\]|:/,"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}},{pattern:/(\boffset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}}],function:/\b[a-zA-Z_]\w*(?=\s*\()/i,keyword:new RegExp("\\b(?:"+a.join("|")+")\\b","i"),number:/[-+]?(?:(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e[-+]?\d+)?\b|\b(?:0x[0-9a-f]+|nan|inf)\b)/i,operator:/[\^*/%+-]|==|!=|<=|<|>=|>|\b(?:and|unless|or)\b/i,punctuation:/[{};()`,.[\]]/}}(Prism);
\ No newline at end of file

From ebded9f3c8da4376659069c8efe45850c948fb2f Mon Sep 17 00:00:00 2001
From: Arend van Beelen jr 
Date: Thu, 12 Nov 2020 18:59:52 +0100
Subject: [PATCH 8/9] Process keywords first

Co-authored-by: Michael Schmidt 
---
 components/prism-promql.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/prism-promql.js b/components/prism-promql.js
index 8f94e74d7e..39761cff06 100644
--- a/components/prism-promql.js
+++ b/components/prism-promql.js
@@ -90,8 +90,8 @@
 				},
 			},
 		],
-		'function': /\b[a-zA-Z_]\w*(?=\s*\()/i,
 		'keyword': new RegExp('\\b(?:' + keywords.join('|') + ')\\b', 'i'),
+		'function': /\b[a-zA-Z_]\w*(?=\s*\()/i,
 		'number': /[-+]?(?:(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e[-+]?\d+)?\b|\b(?:0x[0-9a-f]+|nan|inf)\b)/i,
 		'operator': /[\^*/%+-]|==|!=|<=|<|>=|>|\b(?:and|unless|or)\b/i,
 		'punctuation': /[{};()`,.[\]]/,

From 2fb475618c62788394c5894b9b1f7f0c52a5b3b6 Mon Sep 17 00:00:00 2001
From: Arend van Beelen jr 
Date: Thu, 12 Nov 2020 20:24:44 +0100
Subject: [PATCH 9/9] Rebuild PromQL component

---
 components/prism-promql.min.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/prism-promql.min.js b/components/prism-promql.min.js
index 0fd320bb7d..f76a2e2164 100644
--- a/components/prism-promql.min.js
+++ b/components/prism-promql.min.js
@@ -1 +1 @@
-!function(t){var n=["on","ignoring","group_right","group_left","by","without"],a=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"].concat(n,["offset"]);t.languages.promql={comment:{pattern:/(^[ \t]*)#.*/m,lookbehind:!0},"vector-match":{pattern:new RegExp("((?:"+n.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"},punctuation:/[(),]/}},"context-labels":{pattern:/\{[^{}]*\}/,inside:{"label-key":{pattern:/\b[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/,greedy:!0,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]|,/}},"context-range":[{pattern:/\[[\w\s:]+\]/,inside:{punctuation:/\[|\]|:/,"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}},{pattern:/(\boffset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}}],function:/\b[a-zA-Z_]\w*(?=\s*\()/i,keyword:new RegExp("\\b(?:"+a.join("|")+")\\b","i"),number:/[-+]?(?:(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e[-+]?\d+)?\b|\b(?:0x[0-9a-f]+|nan|inf)\b)/i,operator:/[\^*/%+-]|==|!=|<=|<|>=|>|\b(?:and|unless|or)\b/i,punctuation:/[{};()`,.[\]]/}}(Prism);
\ No newline at end of file
+!function(t){var n=["on","ignoring","group_right","group_left","by","without"],a=["sum","min","max","avg","group","stddev","stdvar","count","count_values","bottomk","topk","quantile"].concat(n,["offset"]);t.languages.promql={comment:{pattern:/(^[ \t]*)#.*/m,lookbehind:!0},"vector-match":{pattern:new RegExp("((?:"+n.join("|")+")\\s*)\\([^)]*\\)"),lookbehind:!0,inside:{"label-key":{pattern:/\b[^,]*\b/,alias:"attr-name"},punctuation:/[(),]/}},"context-labels":{pattern:/\{[^{}]*\}/,inside:{"label-key":{pattern:/\b[a-z_]\w*(?=\s*(?:=~?|![=~]))/,alias:"attr-name"},"label-value":{pattern:/(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/,greedy:!0,alias:"attr-value"},punctuation:/\{|\}|=~?|![=~]|,/}},"context-range":[{pattern:/\[[\w\s:]+\]/,inside:{punctuation:/\[|\]|:/,"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}},{pattern:/(\boffset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b(?:\d+(?:[smhdwy]|ms))+\b/i,alias:"number"}}}],keyword:new RegExp("\\b(?:"+a.join("|")+")\\b","i"),function:/\b[a-zA-Z_]\w*(?=\s*\()/i,number:/[-+]?(?:(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e[-+]?\d+)?\b|\b(?:0x[0-9a-f]+|nan|inf)\b)/i,operator:/[\^*/%+-]|==|!=|<=|<|>=|>|\b(?:and|unless|or)\b/i,punctuation:/[{};()`,.[\]]/}}(Prism);
\ No newline at end of file