From 25c3b1f8682eff3944742d178703274c5f516a2a Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Sun, 13 Feb 2022 11:13:09 +0100 Subject: [PATCH 01/21] Added cooklang definition incl. tests, examples --- components.js | 2 +- components.json | 4 + components/prism-cooklang.js | 84 ++++++++++++ examples/prism-cooklang.html | 41 ++++++ tests/languages/cooklang/comment_feature.test | 20 +++ .../languages/cooklang/cookware_feature.test | 129 ++++++++++++++++++ .../cooklang/ingredient_feature.test | 129 ++++++++++++++++++ tests/languages/cooklang/meta_feature.test | 19 +++ tests/languages/cooklang/timer_feature.test | 42 ++++++ 9 files changed, 469 insertions(+), 1 deletion(-) create mode 100644 components/prism-cooklang.js create mode 100644 examples/prism-cooklang.html create mode 100644 tests/languages/cooklang/comment_feature.test create mode 100644 tests/languages/cooklang/cookware_feature.test create mode 100644 tests/languages/cooklang/ingredient_feature.test create mode 100644 tests/languages/cooklang/meta_feature.test create mode 100644 tests/languages/cooklang/timer_feature.test diff --git a/components.js b/components.js index 6d3c1562e0..8f9f6e7801 100644 --- a/components.js +++ b/components.js @@ -1,2 +1,2 @@ -var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml","ssml","atom","rss"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","ssml":"SSML","atom":"Atom","rss":"RSS"},"option":"default"},"css":{"title":"CSS","option":"default","modify":"markup"},"clike":{"title":"C-like","option":"default"},"javascript":{"title":"JavaScript","require":"clike","modify":"markup","optional":"regex","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"ABNF","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","modify":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"agda":{"title":"Agda","owner":"xy-ren"},"al":{"title":"AL","owner":"RunDevelopment"},"antlr4":{"title":"ANTLR4","alias":"g4","owner":"RunDevelopment"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apex":{"title":"Apex","require":["clike","sql"],"owner":"RunDevelopment"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","alias":"ino","owner":"dkern"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"asmatmel":{"title":"Atmel AVR Assembly","owner":"cerkit"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"avisynth":{"title":"AviSynth","alias":"avs","owner":"Zinfidel"},"avro-idl":{"title":"Avro IDL","alias":"avdl","owner":"RunDevelopment"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bbcode":{"title":"BBcode","alias":"shortcode","aliasTitles":{"shortcode":"Shortcode"},"owner":"RunDevelopment"},"bicep":{"title":"Bicep","owner":"johnnyreilly"},"birb":{"title":"Birb","require":"clike","owner":"Calamity210"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"BNF","alias":"rbnf","aliasTitles":{"rbnf":"RBNF"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"brightscript":{"title":"BrightScript","owner":"RunDevelopment"},"bro":{"title":"Bro","owner":"wayward710"},"bsl":{"title":"BSL (1C:Enterprise)","alias":"oscript","aliasTitles":{"oscript":"OneScript"},"owner":"Diversus23"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cfscript":{"title":"CFScript","require":"clike","alias":"cfc","owner":"mjclemente"},"chaiscript":{"title":"ChaiScript","require":["clike","cpp"],"owner":"RunDevelopment"},"cil":{"title":"CIL","owner":"sbrl"},"clojure":{"title":"Clojure","owner":"troglotit"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"cobol":{"title":"COBOL","owner":"RunDevelopment"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"concurnas":{"title":"Concurnas","alias":"conc","owner":"jasontatton"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"coq":{"title":"Coq","owner":"RunDevelopment"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"csv":{"title":"CSV","owner":"RunDevelopment"},"cypher":{"title":"Cypher","owner":"RunDevelopment"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"dataweave":{"title":"DataWeave","owner":"machaval"},"dax":{"title":"DAX","owner":"peterbud"},"dhall":{"title":"Dhall","owner":"RunDevelopment"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"dot":{"title":"DOT (Graphviz)","alias":"gv","optional":"markup","owner":"RunDevelopment"},"ebnf":{"title":"EBNF","owner":"RunDevelopment"},"editorconfig":{"title":"EditorConfig","owner":"osipxd"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment","alias":"eta","aliasTitles":{"eta":"Eta"}},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"etlua":{"title":"Embedded Lua templating","require":["lua","markup-templating"],"owner":"RunDevelopment"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"excel-formula":{"title":"Excel Formula","alias":["xlsx","xls"],"owner":"RunDevelopment"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"factor":{"title":"Factor","owner":"catb0t"},"false":{"title":"False","owner":"edukisto"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"ftl":{"title":"FreeMarker Template Language","require":"markup-templating","owner":"RunDevelopment"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"gap":{"title":"GAP (CAS)","owner":"RunDevelopment"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"c","owner":"Golmote"},"gn":{"title":"GN","alias":"gni","owner":"RunDevelopment"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"go-module":{"title":"Go module","alias":"go-mod","owner":"RunDevelopment"},"graphql":{"title":"GraphQL","optional":"markdown","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","optional":["css","css-extras","coffeescript","erb","javascript","less","markdown","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","alias":"hbs","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","optional":"regex","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"hlsl":{"title":"HLSL","require":"c","owner":"RunDevelopment"},"hoon":{"title":"Hoon","owner":"matildepark"},"http":{"title":"HTTP","optional":["csp","css","hpkp","hsts","javascript","json","markup","uri"],"owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"icu-message-format":{"title":"ICU Message Format","owner":"RunDevelopment"},"idris":{"title":"Idris","alias":"idr","owner":"KeenS","require":"haskell"},"ignore":{"title":".ignore","owner":"osipxd","alias":["gitignore","hgignore","npmignore"],"aliasTitles":{"gitignore":".gitignore","hgignore":".hgignore","npmignore":".npmignore"}},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"modify":"java","optional":"scala","owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","modify":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jexl":{"title":"Jexl","owner":"czosel"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike","typescript"],"modify":"javascript","optional":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","modify":"javascript","optional":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"json":{"title":"JSON","alias":"webmanifest","aliasTitles":{"webmanifest":"Web App Manifest"},"owner":"CupOfTea696"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"jsstacktrace":{"title":"JS stack trace","owner":"sbrl"},"js-templates":{"title":"JS Templates","require":"javascript","modify":"javascript","optional":["css","css-extras","graphql","markdown","markup","sql"],"owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keepalived":{"title":"Keepalived Configure","owner":"dev-itsheng"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","alias":["kt","kts"],"aliasTitles":{"kts":"Kotlin Script"},"require":"clike","owner":"Golmote"},"kumir":{"title":"KuMir (КуМир)","alias":"kum","owner":"edukisto"},"kusto":{"title":"Kusto","owner":"RunDevelopment"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"latte":{"title":"Latte","require":["clike","markup-templating","php"],"owner":"nette"},"less":{"title":"Less","require":"css","optional":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","require":"markup-templating","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"llvm":{"title":"LLVM IR","owner":"porglezomp"},"log":{"title":"Log file","optional":"javastacktrace","owner":"RunDevelopment"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"magma":{"title":"Magma (CAS)","owner":"RunDevelopment"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","optional":"yaml","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"maxscript":{"title":"MAXScript","owner":"RunDevelopment"},"mel":{"title":"MEL","owner":"Golmote"},"mermaid":{"title":"Mermaid","owner":"RunDevelopment"},"mizar":{"title":"Mizar","owner":"Golmote"},"mongodb":{"title":"MongoDB","owner":"airs0urce","require":"javascript"},"monkey":{"title":"Monkey","owner":"Golmote"},"moonscript":{"title":"MoonScript","alias":"moon","owner":"RunDevelopment"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","optional":"jsdoc","alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"naniscript":{"title":"Naninovel Script","owner":"Elringus","alias":"nani"},"nasm":{"title":"NASM","owner":"rbmj"},"neon":{"title":"NEON","owner":"nette"},"nevod":{"title":"Nevod","owner":"nezaboodka"},"nginx":{"title":"nginx","owner":"volado"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","alias":"objc","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"c","modify":["c","cpp"],"owner":"Milania1"},"openqasm":{"title":"OpenQasm","alias":"qasm","owner":"RunDevelopment"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"psl":{"title":"PATROL Scripting Language","owner":"bertysentry"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"peoplecode":{"title":"PeopleCode","alias":"pcode","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":"markup-templating","owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"modify":"php","owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","modify":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powerquery":{"title":"PowerQuery","alias":["pq","mscript"],"owner":"peterbud"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"promql":{"title":"PromQL","owner":"arendjr"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"optional":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","optional":["c","cpp","fortran"],"owner":"Golmote"},"purebasic":{"title":"PureBasic","require":"clike","alias":"pbfasm","owner":"HeX0R101"},"purescript":{"title":"PureScript","require":"haskell","alias":"purs","owner":"sriharshachilakapati"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"qsharp":{"title":"Q#","require":"clike","alias":"qs","owner":"fedonman"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qml":{"title":"QML","require":"javascript","owner":"RunDevelopment"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"racket":{"title":"Racket","require":"scheme","alias":"rkt","owner":"RunDevelopment"},"cshtml":{"title":"Razor C#","alias":"razor","require":["markup","csharp"],"optional":["css","css-extras","javascript","js-extras"],"owner":"RunDevelopment"},"jsx":{"title":"React JSX","require":["markup","javascript"],"optional":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","owner":"RunDevelopment"},"rego":{"title":"Rego","owner":"JordanSh"},"renpy":{"title":"Ren'py","alias":"rpy","owner":"HyuchiaDiego"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robotframework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","optional":["groovy","lua","sql"],"owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","optional":"css-extras","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","optional":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","alias":["sh-session","shellsession"],"owner":"RunDevelopment"},"smali":{"title":"Smali","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","optional":"php","owner":"Golmote"},"sml":{"title":"SML","alias":"smlnj","aliasTitles":{"smlnj":"SML/NJ"},"owner":"RunDevelopment"},"solidity":{"title":"Solidity (Ethereum)","alias":"sol","require":"clike","owner":"glachaud"},"solution-file":{"title":"Solution file","alias":"sln","owner":"RunDevelopment"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"sparql":{"title":"SPARQL","require":"turtle","owner":"Triply-Dev","alias":"rq"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","require":"clike","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"squirrel":{"title":"Squirrel","require":"clike","owner":"RunDevelopment"},"stan":{"title":"Stan","owner":"RunDevelopment"},"iecst":{"title":"Structured Text (IEC 61131-3)","owner":"serhioromano"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","owner":"chrischares"},"systemd":{"title":"Systemd configuration file","owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","vbnet"],"owner":"RunDevelopment"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"textile":{"title":"Textile","require":"markup","optional":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tremor":{"title":"Tremor","alias":["trickle","troy"],"owner":"darach","aliasTitles":{"trickle":"trickle","troy":"troy"}},"turtle":{"title":"Turtle","alias":"trig","aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup-templating","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","optional":"js-templates","alias":"ts","owner":"vkbansal"},"typoscript":{"title":"TypoScript","alias":"tsconfig","aliasTitles":{"tsconfig":"TSConfig"},"owner":"dkern"},"unrealscript":{"title":"UnrealScript","alias":["uscript","uc"],"owner":"RunDevelopment"},"uorazor":{"title":"UO Razor Script","owner":"jaseowns"},"uri":{"title":"URI","alias":"url","aliasTitles":{"url":"URL"},"owner":"RunDevelopment"},"v":{"title":"V","require":"clike","owner":"taggon"},"vala":{"title":"Vala","require":"clike","optional":"regex","owner":"TemplarVolk"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","alias":["vb","vba"],"aliasTitles":{"vba":"VBA"},"owner":"Golmote"},"warpscript":{"title":"WarpScript","owner":"RunDevelopment"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"web-idl":{"title":"Web IDL","alias":"webidl","owner":"RunDevelopment"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"wolfram":{"title":"Wolfram language","alias":["mathematica","nb","wl"],"aliasTitles":{"mathematica":"Mathematica","nb":"Mathematica Notebook"},"owner":"msollami"},"wren":{"title":"Wren","owner":"clsource"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xml-doc":{"title":"XML doc (.net)","require":"markup","modify":["csharp","fsharp","vbnet"],"owner":"RunDevelopment"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"yang":{"title":"YANG","owner":"RunDevelopment"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":{"title":"Line Highlight","description":"Highlights specific lines and/or line ranges."},"line-numbers":{"title":"Line Numbers","description":"Line number at the beginning of code lines.","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","description":"Show hidden characters such as tabs and line breaks.","optional":["autolinker","data-uri-highlight"]},"autolinker":{"title":"Autolinker","description":"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},"wpd":{"title":"WebPlatform Docs","description":"Makes tokens link to WebPlatform.org documentation. The links open in a new tab."},"custom-class":{"title":"Custom Class","description":"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","description":"Fetch external files and highlight them with Prism. Used on the Prism website itself.","noCSS":true},"show-language":{"title":"Show Language","description":"Display the highlighted language in code blocks (inline code does not show the label).","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","description":"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","description":"Adds special CSS classes for each keyword for fine-grained highlighting.","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","description":"Removes the initial line feed in code blocks.","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","description":"Adds a small inline preview for colors in style sheets.","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","description":"Previewers for angles, colors, gradients, easing and time.","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","description":"Automatically loads the needed languages to highlight the code blocks.","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","description":"Prevents custom markup from being dropped out during highlighting.","owner":"Golmote","optional":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","description":"Display a command line with a prompt and, optionally, the output/response from the commands.","owner":"chriswells0"},"unescaped-markup":{"title":"Unescaped Markup","description":"Write markup without having to escape anything."},"normalize-whitespace":{"title":"Normalize Whitespace","description":"Supports multiple operations to normalize whitespace in code blocks.","owner":"zeitgeist87","optional":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","description":"Highlights data-URI contents.","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","description":"Attach a toolbar for plugins to easily register buttons on the top of a code block.","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","description":"Add a button that copies the code block to the clipboard when clicked.","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","description":"A button in the toolbar of a code block adding a convenient way to download a code file.","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","description":"Highlights matching braces.","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","description":"Highlights the code inside diff blocks.","owner":"RunDevelopment","require":"diff"},"filter-highlight-all":{"title":"Filter highlightAll","description":"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.","owner":"RunDevelopment","noCSS":true},"treeview":{"title":"Treeview","description":"A language with special styles to highlight file system tree structures.","owner":"Golmote"}}}; +var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml","ssml","atom","rss"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","ssml":"SSML","atom":"Atom","rss":"RSS"},"option":"default"},"css":{"title":"CSS","option":"default","modify":"markup"},"clike":{"title":"C-like","option":"default"},"javascript":{"title":"JavaScript","require":"clike","modify":"markup","optional":"regex","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"ABNF","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","modify":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"agda":{"title":"Agda","owner":"xy-ren"},"al":{"title":"AL","owner":"RunDevelopment"},"antlr4":{"title":"ANTLR4","alias":"g4","owner":"RunDevelopment"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apex":{"title":"Apex","require":["clike","sql"],"owner":"RunDevelopment"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","alias":"ino","owner":"dkern"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"asmatmel":{"title":"Atmel AVR Assembly","owner":"cerkit"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"avisynth":{"title":"AviSynth","alias":"avs","owner":"Zinfidel"},"avro-idl":{"title":"Avro IDL","alias":"avdl","owner":"RunDevelopment"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bbcode":{"title":"BBcode","alias":"shortcode","aliasTitles":{"shortcode":"Shortcode"},"owner":"RunDevelopment"},"bicep":{"title":"Bicep","owner":"johnnyreilly"},"birb":{"title":"Birb","require":"clike","owner":"Calamity210"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"BNF","alias":"rbnf","aliasTitles":{"rbnf":"RBNF"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"brightscript":{"title":"BrightScript","owner":"RunDevelopment"},"bro":{"title":"Bro","owner":"wayward710"},"bsl":{"title":"BSL (1C:Enterprise)","alias":"oscript","aliasTitles":{"oscript":"OneScript"},"owner":"Diversus23"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cfscript":{"title":"CFScript","require":"clike","alias":"cfc","owner":"mjclemente"},"chaiscript":{"title":"ChaiScript","require":["clike","cpp"],"owner":"RunDevelopment"},"cil":{"title":"CIL","owner":"sbrl"},"clojure":{"title":"Clojure","owner":"troglotit"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"cobol":{"title":"COBOL","owner":"RunDevelopment"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"concurnas":{"title":"Concurnas","alias":"conc","owner":"jasontatton"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"cooklang":{"title":"Cooklang","owner":"ahue"},"coq":{"title":"Coq","owner":"RunDevelopment"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"csv":{"title":"CSV","owner":"RunDevelopment"},"cypher":{"title":"Cypher","owner":"RunDevelopment"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"dataweave":{"title":"DataWeave","owner":"machaval"},"dax":{"title":"DAX","owner":"peterbud"},"dhall":{"title":"Dhall","owner":"RunDevelopment"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"dot":{"title":"DOT (Graphviz)","alias":"gv","optional":"markup","owner":"RunDevelopment"},"ebnf":{"title":"EBNF","owner":"RunDevelopment"},"editorconfig":{"title":"EditorConfig","owner":"osipxd"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment","alias":"eta","aliasTitles":{"eta":"Eta"}},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"etlua":{"title":"Embedded Lua templating","require":["lua","markup-templating"],"owner":"RunDevelopment"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"excel-formula":{"title":"Excel Formula","alias":["xlsx","xls"],"owner":"RunDevelopment"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"factor":{"title":"Factor","owner":"catb0t"},"false":{"title":"False","owner":"edukisto"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"ftl":{"title":"FreeMarker Template Language","require":"markup-templating","owner":"RunDevelopment"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"gap":{"title":"GAP (CAS)","owner":"RunDevelopment"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"c","owner":"Golmote"},"gn":{"title":"GN","alias":"gni","owner":"RunDevelopment"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"go-module":{"title":"Go module","alias":"go-mod","owner":"RunDevelopment"},"graphql":{"title":"GraphQL","optional":"markdown","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","optional":["css","css-extras","coffeescript","erb","javascript","less","markdown","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","alias":"hbs","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","optional":"regex","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"hlsl":{"title":"HLSL","require":"c","owner":"RunDevelopment"},"hoon":{"title":"Hoon","owner":"matildepark"},"http":{"title":"HTTP","optional":["csp","css","hpkp","hsts","javascript","json","markup","uri"],"owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"icu-message-format":{"title":"ICU Message Format","owner":"RunDevelopment"},"idris":{"title":"Idris","alias":"idr","owner":"KeenS","require":"haskell"},"ignore":{"title":".ignore","owner":"osipxd","alias":["gitignore","hgignore","npmignore"],"aliasTitles":{"gitignore":".gitignore","hgignore":".hgignore","npmignore":".npmignore"}},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"modify":"java","optional":"scala","owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","modify":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jexl":{"title":"Jexl","owner":"czosel"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike","typescript"],"modify":"javascript","optional":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","modify":"javascript","optional":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"json":{"title":"JSON","alias":"webmanifest","aliasTitles":{"webmanifest":"Web App Manifest"},"owner":"CupOfTea696"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"jsstacktrace":{"title":"JS stack trace","owner":"sbrl"},"js-templates":{"title":"JS Templates","require":"javascript","modify":"javascript","optional":["css","css-extras","graphql","markdown","markup","sql"],"owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keepalived":{"title":"Keepalived Configure","owner":"dev-itsheng"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","alias":["kt","kts"],"aliasTitles":{"kts":"Kotlin Script"},"require":"clike","owner":"Golmote"},"kumir":{"title":"KuMir (КуМир)","alias":"kum","owner":"edukisto"},"kusto":{"title":"Kusto","owner":"RunDevelopment"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"latte":{"title":"Latte","require":["clike","markup-templating","php"],"owner":"nette"},"less":{"title":"Less","require":"css","optional":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","require":"markup-templating","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"llvm":{"title":"LLVM IR","owner":"porglezomp"},"log":{"title":"Log file","optional":"javastacktrace","owner":"RunDevelopment"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"magma":{"title":"Magma (CAS)","owner":"RunDevelopment"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","optional":"yaml","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"maxscript":{"title":"MAXScript","owner":"RunDevelopment"},"mel":{"title":"MEL","owner":"Golmote"},"mermaid":{"title":"Mermaid","owner":"RunDevelopment"},"mizar":{"title":"Mizar","owner":"Golmote"},"mongodb":{"title":"MongoDB","owner":"airs0urce","require":"javascript"},"monkey":{"title":"Monkey","owner":"Golmote"},"moonscript":{"title":"MoonScript","alias":"moon","owner":"RunDevelopment"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","optional":"jsdoc","alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"naniscript":{"title":"Naninovel Script","owner":"Elringus","alias":"nani"},"nasm":{"title":"NASM","owner":"rbmj"},"neon":{"title":"NEON","owner":"nette"},"nevod":{"title":"Nevod","owner":"nezaboodka"},"nginx":{"title":"nginx","owner":"volado"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","alias":"objc","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"c","modify":["c","cpp"],"owner":"Milania1"},"openqasm":{"title":"OpenQasm","alias":"qasm","owner":"RunDevelopment"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"psl":{"title":"PATROL Scripting Language","owner":"bertysentry"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"peoplecode":{"title":"PeopleCode","alias":"pcode","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":"markup-templating","owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"modify":"php","owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","modify":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powerquery":{"title":"PowerQuery","alias":["pq","mscript"],"owner":"peterbud"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"promql":{"title":"PromQL","owner":"arendjr"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"optional":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","optional":["c","cpp","fortran"],"owner":"Golmote"},"purebasic":{"title":"PureBasic","require":"clike","alias":"pbfasm","owner":"HeX0R101"},"purescript":{"title":"PureScript","require":"haskell","alias":"purs","owner":"sriharshachilakapati"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"qsharp":{"title":"Q#","require":"clike","alias":"qs","owner":"fedonman"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qml":{"title":"QML","require":"javascript","owner":"RunDevelopment"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"racket":{"title":"Racket","require":"scheme","alias":"rkt","owner":"RunDevelopment"},"cshtml":{"title":"Razor C#","alias":"razor","require":["markup","csharp"],"optional":["css","css-extras","javascript","js-extras"],"owner":"RunDevelopment"},"jsx":{"title":"React JSX","require":["markup","javascript"],"optional":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","owner":"RunDevelopment"},"rego":{"title":"Rego","owner":"JordanSh"},"renpy":{"title":"Ren'py","alias":"rpy","owner":"HyuchiaDiego"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robotframework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","optional":["groovy","lua","sql"],"owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","optional":"css-extras","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","optional":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","alias":["sh-session","shellsession"],"owner":"RunDevelopment"},"smali":{"title":"Smali","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","optional":"php","owner":"Golmote"},"sml":{"title":"SML","alias":"smlnj","aliasTitles":{"smlnj":"SML/NJ"},"owner":"RunDevelopment"},"solidity":{"title":"Solidity (Ethereum)","alias":"sol","require":"clike","owner":"glachaud"},"solution-file":{"title":"Solution file","alias":"sln","owner":"RunDevelopment"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"sparql":{"title":"SPARQL","require":"turtle","owner":"Triply-Dev","alias":"rq"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","require":"clike","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"squirrel":{"title":"Squirrel","require":"clike","owner":"RunDevelopment"},"stan":{"title":"Stan","owner":"RunDevelopment"},"iecst":{"title":"Structured Text (IEC 61131-3)","owner":"serhioromano"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","owner":"chrischares"},"systemd":{"title":"Systemd configuration file","owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","vbnet"],"owner":"RunDevelopment"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"textile":{"title":"Textile","require":"markup","optional":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tremor":{"title":"Tremor","alias":["trickle","troy"],"owner":"darach","aliasTitles":{"trickle":"trickle","troy":"troy"}},"turtle":{"title":"Turtle","alias":"trig","aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup-templating","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","optional":"js-templates","alias":"ts","owner":"vkbansal"},"typoscript":{"title":"TypoScript","alias":"tsconfig","aliasTitles":{"tsconfig":"TSConfig"},"owner":"dkern"},"unrealscript":{"title":"UnrealScript","alias":["uscript","uc"],"owner":"RunDevelopment"},"uorazor":{"title":"UO Razor Script","owner":"jaseowns"},"uri":{"title":"URI","alias":"url","aliasTitles":{"url":"URL"},"owner":"RunDevelopment"},"v":{"title":"V","require":"clike","owner":"taggon"},"vala":{"title":"Vala","require":"clike","optional":"regex","owner":"TemplarVolk"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","alias":["vb","vba"],"aliasTitles":{"vba":"VBA"},"owner":"Golmote"},"warpscript":{"title":"WarpScript","owner":"RunDevelopment"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"web-idl":{"title":"Web IDL","alias":"webidl","owner":"RunDevelopment"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"wolfram":{"title":"Wolfram language","alias":["mathematica","nb","wl"],"aliasTitles":{"mathematica":"Mathematica","nb":"Mathematica Notebook"},"owner":"msollami"},"wren":{"title":"Wren","owner":"clsource"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xml-doc":{"title":"XML doc (.net)","require":"markup","modify":["csharp","fsharp","vbnet"],"owner":"RunDevelopment"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"yang":{"title":"YANG","owner":"RunDevelopment"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":{"title":"Line Highlight","description":"Highlights specific lines and/or line ranges."},"line-numbers":{"title":"Line Numbers","description":"Line number at the beginning of code lines.","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","description":"Show hidden characters such as tabs and line breaks.","optional":["autolinker","data-uri-highlight"]},"autolinker":{"title":"Autolinker","description":"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},"wpd":{"title":"WebPlatform Docs","description":"Makes tokens link to WebPlatform.org documentation. The links open in a new tab."},"custom-class":{"title":"Custom Class","description":"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","description":"Fetch external files and highlight them with Prism. Used on the Prism website itself.","noCSS":true},"show-language":{"title":"Show Language","description":"Display the highlighted language in code blocks (inline code does not show the label).","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","description":"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","description":"Adds special CSS classes for each keyword for fine-grained highlighting.","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","description":"Removes the initial line feed in code blocks.","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","description":"Adds a small inline preview for colors in style sheets.","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","description":"Previewers for angles, colors, gradients, easing and time.","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","description":"Automatically loads the needed languages to highlight the code blocks.","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","description":"Prevents custom markup from being dropped out during highlighting.","owner":"Golmote","optional":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","description":"Display a command line with a prompt and, optionally, the output/response from the commands.","owner":"chriswells0"},"unescaped-markup":{"title":"Unescaped Markup","description":"Write markup without having to escape anything."},"normalize-whitespace":{"title":"Normalize Whitespace","description":"Supports multiple operations to normalize whitespace in code blocks.","owner":"zeitgeist87","optional":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","description":"Highlights data-URI contents.","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","description":"Attach a toolbar for plugins to easily register buttons on the top of a code block.","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","description":"Add a button that copies the code block to the clipboard when clicked.","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","description":"A button in the toolbar of a code block adding a convenient way to download a code file.","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","description":"Highlights matching braces.","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","description":"Highlights the code inside diff blocks.","owner":"RunDevelopment","require":"diff"},"filter-highlight-all":{"title":"Filter highlightAll","description":"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.","owner":"RunDevelopment","noCSS":true},"treeview":{"title":"Treeview","description":"A language with special styles to highlight file system tree structures.","owner":"Golmote"}}}; if (typeof module !== 'undefined' && module.exports) { module.exports = components; } \ No newline at end of file diff --git a/components.json b/components.json index 903e4cfbc1..50bcaa60de 100644 --- a/components.json +++ b/components.json @@ -299,6 +299,10 @@ "title": "Content-Security-Policy", "owner": "ScottHelme" }, + "cooklang": { + "title": "Cooklang", + "owner": "ahue" + }, "coq": { "title": "Coq", "owner": "RunDevelopment" diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js new file mode 100644 index 0000000000..9c8c7f6b7f --- /dev/null +++ b/components/prism-cooklang.js @@ -0,0 +1,84 @@ +(function (Prism) { + + var ingr_cw_prefix = /(?:[@#][^{@#]+)\{/ + var ingr_cw_suffix = /\}/ + var quant1 = /(?:[^}|*%]*[*]?)/ + var quant_unit = /(?:[^}|*%]+[*]?%[^}]+)/ + var quant_servings_unit = /(?:(?:[^*}%|]+[|])+[^*}%|]+(?:%[^*|%}]+)?)/ + + Prism.languages.cooklang = { + 'comment': [ + /\[-[\s\S]*?-\]/, // -- comment + /\-{2}[^\r\n]*/, // [- comment -] + ], + 'meta': { // >> key: value + 'pattern': /\>{2}.*:.*/, + 'inside': { + "property": { // key: + 'pattern': /(\>{2}\s*)[^:]+/, + 'lookbehind': true, + } + } + }, + 'quant': { // @some ingredient{...} #some cookware{...} + 'pattern': new RegExp( + ingr_cw_prefix.source + + "(?:" + + quant1.source + "|" + + quant_unit.source + "|" + + quant_servings_unit.source + + ")" + + ingr_cw_suffix.source, + ), + 'inside': { + 'variable': { // some ingredient, some cookware + pattern: /([@#])[^{@#]+/, + lookbehind: true + }, + 'amount-group': { + 'pattern': /\{[^{}]*\}/, // {...} + 'inside': { + 'punctuation': /[{}]/, + 'symbol': { // unit + 'pattern': /(%)[^}]+/, + 'lookbehind': true + }, + 'operator': /\*%|\*|%|\|/, // already includes not yet officially implemented servings operators + 'number': /[^{}*%]+/, // amount + } + }, + 'keyword': /[@#]/, + } + }, + 'no-quant': { // ingredient, cookware + 'pattern': /[@#][^{@#\s]+/, + 'inside': { + 'keyword': /[@#]/, + 'variable': /[^{@#]+/ + } + }, + 'timer-group': { // ~timer{...} + 'pattern': /\~[^{}]*\{\d+%(?:minutes|hours)\}/, + 'inside': { + 'variable': { // timer name + pattern: /(~)[^{]+/, + lookbehind: true + }, + 'duration-group': { // {...} + 'pattern': /\{[^{}]+\}/, + 'inside': { + 'punctuation': /[{}]/, + 'symbol': { // unit + 'pattern': /(%)(?:minutes|min|m|hours|hrs|h)/, + 'lookbehind': true + }, + 'operator': /%/, + 'number': /\d+/, // amount + } + }, + 'keyword': /~/, + } + } + }; +}(Prism)); + \ No newline at end of file diff --git a/examples/prism-cooklang.html b/examples/prism-cooklang.html new file mode 100644 index 0000000000..4ba6ff1f6b --- /dev/null +++ b/examples/prism-cooklang.html @@ -0,0 +1,41 @@ +

Comments

+

+-- This is a single line comment
+[- this
+is
+a multi line comment -]
+
+ +

Meta

+

+>> servings: 3
+>> source: https://cooklang.org/docs/spec
+>> any key: any value
+
+ +

Ingredients

+

+@salt without amount
+@egg{1}
+@milk{1%l}
+@milk{1|2%l}
+@egg{1|2}
+@egg{1*}
+@milk{2*%l}
+
+ +

Cookware

+

+#spoon without amount
+#spoon{10%pair}
+#spoon{1|2}
+#spoon{1*%pair}
+#spoon{1|2%pair}
+#spoon{1*}
+
+ +

Timer

+

+~{25%minutes} without name
+~named timer{1%hours}
+
\ No newline at end of file diff --git a/tests/languages/cooklang/comment_feature.test b/tests/languages/cooklang/comment_feature.test new file mode 100644 index 0000000000..7d21f249cf --- /dev/null +++ b/tests/languages/cooklang/comment_feature.test @@ -0,0 +1,20 @@ +-- a single line comment +[- a multi line comment on a single line -] +[- a multi +line comment 1 -] +[- a multi +line comment 2 +-] +[- +a multi +line comment 3 -] + +---------------------------------------------------- + +[ + ["comment", "-- a single line comment"], + ["comment", "[- a multi line comment on a single line -]"], + ["comment", "[- a multi\r\nline comment 1 -]"], + ["comment", "[- a multi\r\nline comment 2 \r\n-]"], + ["comment", "[- \r\na multi\r\nline comment 3 -]"] +] diff --git a/tests/languages/cooklang/cookware_feature.test b/tests/languages/cooklang/cookware_feature.test new file mode 100644 index 0000000000..bb12b078bb --- /dev/null +++ b/tests/languages/cooklang/cookware_feature.test @@ -0,0 +1,129 @@ +#spoon +#spoon and more @spoon +#more spoon{} +#even more spoon{1} +#spoon{1%set} +#spoon{2*%kg} +#spoon{3|1%set} +#spoon{3*set} must not match +#spoon{3|set} +#spoon{3%*set} +#spoon{3%*%set} + +---------------------------------------------------- + +[ + ["no-quant", [ + ["keyword", "#"], + ["variable", "spoon"] + ]], + + ["no-quant", [ + ["keyword", "#"], + ["variable", "spoon"] + ]], + " and more ", + ["no-quant", [ + ["keyword", "@"], + ["variable", "spoon"] + ]], + + ["quant", [ + ["keyword", "#"], + ["variable", "more spoon"], + ["amount-group", [ + ["punctuation", "{"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "#"], + ["variable", "even more spoon"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "1"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "#"], + ["variable", "spoon"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "1"], + ["operator", "%"], + ["symbol", "set"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "#"], + ["variable", "spoon"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "2"], + ["operator", "*%"], + ["symbol", "kg"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "#"], + ["variable", "spoon"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "3"], + ["operator", "|"], + ["number", "1"], + ["operator", "%"], + ["symbol", "set"], + ["punctuation", "}"] + ]] + ]], + + ["no-quant", [ + ["keyword", "#"], + ["variable", "spoon"] + ]], + "{3*set} must not match\r\n", + + ["quant", [ + ["keyword", "#"], + ["variable", "spoon"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "3"], + ["operator", "|"], + ["number", "set"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "#"], + ["variable", "spoon"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "3"], + ["operator", "%"], + ["symbol", "*set"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "#"], + ["variable", "spoon"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "3"], + ["operator", "%"], + ["symbol", "*%set"], + ["punctuation", "}"] + ]] + ]] +] diff --git a/tests/languages/cooklang/ingredient_feature.test b/tests/languages/cooklang/ingredient_feature.test new file mode 100644 index 0000000000..27fa8617b1 --- /dev/null +++ b/tests/languages/cooklang/ingredient_feature.test @@ -0,0 +1,129 @@ +@milk +@milk and more @milk +@more milk{} +@even more milk{1} +@milk{1%l} +@milk{2*%kg} +@milk{3|1%L} +@milk{3*L} must not match +@milk{3|L} +@milk{3%*L} +@milk{3%*%L} + +---------------------------------------------------- + +[ + ["no-quant", [ + ["keyword", "@"], + ["variable", "milk"] + ]], + + ["no-quant", [ + ["keyword", "@"], + ["variable", "milk"] + ]], + " and more ", + ["no-quant", [ + ["keyword", "@"], + ["variable", "milk"] + ]], + + ["quant", [ + ["keyword", "@"], + ["variable", "more milk"], + ["amount-group", [ + ["punctuation", "{"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "@"], + ["variable", "even more milk"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "1"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "@"], + ["variable", "milk"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "1"], + ["operator", "%"], + ["symbol", "l"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "@"], + ["variable", "milk"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "2"], + ["operator", "*%"], + ["symbol", "kg"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "@"], + ["variable", "milk"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "3"], + ["operator", "|"], + ["number", "1"], + ["operator", "%"], + ["symbol", "L"], + ["punctuation", "}"] + ]] + ]], + + ["no-quant", [ + ["keyword", "@"], + ["variable", "milk"] + ]], + "{3*L} must not match\r\n", + + ["quant", [ + ["keyword", "@"], + ["variable", "milk"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "3"], + ["operator", "|"], + ["number", "L"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "@"], + ["variable", "milk"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "3"], + ["operator", "%"], + ["symbol", "*L"], + ["punctuation", "}"] + ]] + ]], + + ["quant", [ + ["keyword", "@"], + ["variable", "milk"], + ["amount-group", [ + ["punctuation", "{"], + ["number", "3"], + ["operator", "%"], + ["symbol", "*%L"], + ["punctuation", "}"] + ]] + ]] +] diff --git a/tests/languages/cooklang/meta_feature.test b/tests/languages/cooklang/meta_feature.test new file mode 100644 index 0000000000..0550f4e8a9 --- /dev/null +++ b/tests/languages/cooklang/meta_feature.test @@ -0,0 +1,19 @@ +>> servings: 1|2|3 +>> servings: 3 +>> meta without colon must not match + +---------------------------------------------------- + +[ + ["meta", [ + ">> ", + ["property", "servings"], + ": 1|2|3" + ]], + ["meta", [ + ">> ", + ["property", "servings"], + ": 3" + ]], + "\r\n>> meta without colon must not match" +] diff --git a/tests/languages/cooklang/timer_feature.test b/tests/languages/cooklang/timer_feature.test new file mode 100644 index 0000000000..2db42bd700 --- /dev/null +++ b/tests/languages/cooklang/timer_feature.test @@ -0,0 +1,42 @@ +~{25%minutes} +~eggs{25%minutes} +~{abc%minutes} must not match +~eggs{2%hours} + +---------------------------------------------------- + +[ + ["timer-group", [ + ["keyword", "~"], + ["duration-group", [ + ["punctuation", "{"], + ["number", "25"], + ["operator", "%"], + ["symbol", "minutes"], + ["punctuation", "}"] + ]] + ]], + ["timer-group", [ + ["keyword", "~"], + ["variable", "eggs"], + ["duration-group", [ + ["punctuation", "{"], + ["number", "25"], + ["operator", "%"], + ["symbol", "minutes"], + ["punctuation", "}"] + ]] + ]], + "\r\n~{abc%minutes} must not match\r\n", + ["timer-group", [ + ["keyword", "~"], + ["variable", "eggs"], + ["duration-group", [ + ["punctuation", "{"], + ["number", "2"], + ["operator", "%"], + ["symbol", "hours"], + ["punctuation", "}"] + ]] + ]] +] From 6dc18afadae7c831ff7cd668e43f2c35b6677f1c Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Sun, 13 Feb 2022 11:19:22 +0100 Subject: [PATCH 02/21] Fixed syntax error --- components/prism-cooklang.js | 2 +- components/prism-cooklang.min.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 components/prism-cooklang.min.js diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 9c8c7f6b7f..362bf67ec9 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -28,7 +28,7 @@ + quant_unit.source + "|" + quant_servings_unit.source + ")" - + ingr_cw_suffix.source, + + ingr_cw_suffix.source ), 'inside': { 'variable': { // some ingredient, some cookware diff --git a/components/prism-cooklang.min.js b/components/prism-cooklang.min.js new file mode 100644 index 0000000000..71d9e647cf --- /dev/null +++ b/components/prism-cooklang.min.js @@ -0,0 +1 @@ +Prism.languages.cooklang={comment:[/\[-[\s\S]*?-\]/,/\-{2}[^\r\n]*/],meta:{pattern:/\>{2}.*:.*/,inside:{property:{pattern:/(\>{2}\s*)[^:]+/,lookbehind:!0}}},quant:{pattern:new RegExp(/(?:[@#][^{@#]+)\{/.source+"(?:"+/(?:[^}|*%]*[*]?)/.source+"|"+/(?:[^}|*%]+[*]?%[^}]+)/.source+"|"+/(?:(?:[^*}%|]+[|])+[^*}%|]+(?:%[^*|%}]+)?)/.source+")"+/\}/.source),inside:{variable:{pattern:/([@#])[^{@#]+/,lookbehind:!0},"amount-group":{pattern:/\{[^{}]*\}/,inside:{punctuation:/[{}]/,symbol:{pattern:/(%)[^}]+/,lookbehind:!0},operator:/\*%|\*|%|\|/,number:/[^{}*%]+/}},keyword:/[@#]/}},"no-quant":{pattern:/[@#][^{@#\s]+/,inside:{keyword:/[@#]/,variable:/[^{@#]+/}},"timer-group":{pattern:/\~[^{}]*\{\d+%(?:minutes|hours)\}/,inside:{variable:{pattern:/(~)[^{]+/,lookbehind:!0},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,symbol:{pattern:/(%)(?:minutes|min|m|hours|hrs|h)/,lookbehind:!0},operator:/%/,number:/\d+/}},keyword:/~/}}}; \ No newline at end of file From bc46a9c46c1f9becc7a823af2506ac34d1c6fa38 Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Sun, 13 Feb 2022 11:25:53 +0100 Subject: [PATCH 03/21] Fixed linting problems --- components/prism-cooklang.js | 35 ++++++++++++++++---------------- components/prism-cooklang.min.js | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 362bf67ec9..53ba715437 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -1,21 +1,21 @@ (function (Prism) { - var ingr_cw_prefix = /(?:[@#][^{@#]+)\{/ - var ingr_cw_suffix = /\}/ - var quant1 = /(?:[^}|*%]*[*]?)/ - var quant_unit = /(?:[^}|*%]+[*]?%[^}]+)/ - var quant_servings_unit = /(?:(?:[^*}%|]+[|])+[^*}%|]+(?:%[^*|%}]+)?)/ + var ingr_cw_prefix = /(?:[@#][^{@#]+)\{/; + var ingr_cw_suffix = /\}/; + var quant1 = /(?:[^}|*%]*\*?)/; + var quant_unit = /(?:[^}|*%]+\*?%[^}]+)/; + var quant_servings_unit = /(?:(?:[^*}%|]+\|)+[^*}%|]+(?:%[^*|%}]+)?)/; Prism.languages.cooklang = { 'comment': [ /\[-[\s\S]*?-\]/, // -- comment - /\-{2}[^\r\n]*/, // [- comment -] + /-{2}[^\r\n]*/, // [- comment -] ], 'meta': { // >> key: value - 'pattern': /\>{2}.*:.*/, + 'pattern': />{2}.*:.*/, 'inside': { - "property": { // key: - 'pattern': /(\>{2}\s*)[^:]+/, + 'property': { // key: + 'pattern': /(>{2}\s*)[^:]+/, 'lookbehind': true, } } @@ -23,11 +23,11 @@ 'quant': { // @some ingredient{...} #some cookware{...} 'pattern': new RegExp( ingr_cw_prefix.source - + "(?:" - + quant1.source + "|" - + quant_unit.source + "|" + + '(?:' + + quant1.source + '|' + + quant_unit.source + '|' + quant_servings_unit.source - + ")" + + ')' + ingr_cw_suffix.source ), 'inside': { @@ -42,7 +42,7 @@ 'symbol': { // unit 'pattern': /(%)[^}]+/, 'lookbehind': true - }, + }, 'operator': /\*%|\*|%|\|/, // already includes not yet officially implemented servings operators 'number': /[^{}*%]+/, // amount } @@ -58,20 +58,20 @@ } }, 'timer-group': { // ~timer{...} - 'pattern': /\~[^{}]*\{\d+%(?:minutes|hours)\}/, + 'pattern': /~[^{}]*\{\d+%(?:hours|minutes)\}/, 'inside': { 'variable': { // timer name pattern: /(~)[^{]+/, lookbehind: true }, 'duration-group': { // {...} - 'pattern': /\{[^{}]+\}/, + 'pattern': /\{[^{}]+\}/, 'inside': { 'punctuation': /[{}]/, 'symbol': { // unit 'pattern': /(%)(?:minutes|min|m|hours|hrs|h)/, 'lookbehind': true - }, + }, 'operator': /%/, 'number': /\d+/, // amount } @@ -81,4 +81,3 @@ } }; }(Prism)); - \ No newline at end of file diff --git a/components/prism-cooklang.min.js b/components/prism-cooklang.min.js index 71d9e647cf..57634af2cb 100644 --- a/components/prism-cooklang.min.js +++ b/components/prism-cooklang.min.js @@ -1 +1 @@ -Prism.languages.cooklang={comment:[/\[-[\s\S]*?-\]/,/\-{2}[^\r\n]*/],meta:{pattern:/\>{2}.*:.*/,inside:{property:{pattern:/(\>{2}\s*)[^:]+/,lookbehind:!0}}},quant:{pattern:new RegExp(/(?:[@#][^{@#]+)\{/.source+"(?:"+/(?:[^}|*%]*[*]?)/.source+"|"+/(?:[^}|*%]+[*]?%[^}]+)/.source+"|"+/(?:(?:[^*}%|]+[|])+[^*}%|]+(?:%[^*|%}]+)?)/.source+")"+/\}/.source),inside:{variable:{pattern:/([@#])[^{@#]+/,lookbehind:!0},"amount-group":{pattern:/\{[^{}]*\}/,inside:{punctuation:/[{}]/,symbol:{pattern:/(%)[^}]+/,lookbehind:!0},operator:/\*%|\*|%|\|/,number:/[^{}*%]+/}},keyword:/[@#]/}},"no-quant":{pattern:/[@#][^{@#\s]+/,inside:{keyword:/[@#]/,variable:/[^{@#]+/}},"timer-group":{pattern:/\~[^{}]*\{\d+%(?:minutes|hours)\}/,inside:{variable:{pattern:/(~)[^{]+/,lookbehind:!0},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,symbol:{pattern:/(%)(?:minutes|min|m|hours|hrs|h)/,lookbehind:!0},operator:/%/,number:/\d+/}},keyword:/~/}}}; \ No newline at end of file +Prism.languages.cooklang={comment:[/\[-[\s\S]*?-\]/,/-{2}[^\r\n]*/],meta:{pattern:/>{2}.*:.*/,inside:{property:{pattern:/(>{2}\s*)[^:]+/,lookbehind:!0}}},quant:{pattern:new RegExp(/(?:[@#][^{@#]+)\{/.source+"(?:"+/(?:[^}|*%]*\*?)/.source+"|"+/(?:[^}|*%]+\*?%[^}]+)/.source+"|"+/(?:(?:[^*}%|]+\|)+[^*}%|]+(?:%[^*|%}]+)?)/.source+")"+/\}/.source),inside:{variable:{pattern:/([@#])[^{@#]+/,lookbehind:!0},"amount-group":{pattern:/\{[^{}]*\}/,inside:{punctuation:/[{}]/,symbol:{pattern:/(%)[^}]+/,lookbehind:!0},operator:/\*%|\*|%|\|/,number:/[^{}*%]+/}},keyword:/[@#]/}},"no-quant":{pattern:/[@#][^{@#\s]+/,inside:{keyword:/[@#]/,variable:/[^{@#]+/}},"timer-group":{pattern:/~[^{}]*\{\d+%(?:hours|minutes)\}/,inside:{variable:{pattern:/(~)[^{]+/,lookbehind:!0},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,symbol:{pattern:/(%)(?:minutes|min|m|hours|hrs|h)/,lookbehind:!0},operator:/%/,number:/\d+/}},keyword:/~/}}}; \ No newline at end of file From c808f1bc23becac322653061a207f2b1c1941452 Mon Sep 17 00:00:00 2001 From: ahue Date: Tue, 15 Feb 2022 22:16:35 +0100 Subject: [PATCH 04/21] comment regex now greedy Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 53ba715437..762445cc99 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -7,10 +7,12 @@ var quant_servings_unit = /(?:(?:[^*}%|]+\|)+[^*}%|]+(?:%[^*|%}]+)?)/; Prism.languages.cooklang = { - 'comment': [ - /\[-[\s\S]*?-\]/, // -- comment - /-{2}[^\r\n]*/, // [- comment -] - ], + 'comment': { + // [- comment -] + // -- comment + pattern: /\[-[\s\S]*?-\]|--.*/, + greedy: true + }, 'meta': { // >> key: value 'pattern': />{2}.*:.*/, 'inside': { From a8c6a400579b4cd858f76d0e3124aa2e0150a7e6 Mon Sep 17 00:00:00 2001 From: ahue Date: Tue, 15 Feb 2022 22:17:17 +0100 Subject: [PATCH 05/21] no empty meta key, no space after key Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 762445cc99..62253cc5cd 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -17,8 +17,8 @@ 'pattern': />{2}.*:.*/, 'inside': { 'property': { // key: - 'pattern': /(>{2}\s*)[^:]+/, - 'lookbehind': true, + pattern: /(>>\s*)[^\s:](?:[^:]*[^\s:])?/, + lookbehind: true, } } }, From 5755bb97c44becc7391f1cf6f9d99a6fb58ae8bb Mon Sep 17 00:00:00 2001 From: ahue Date: Tue, 15 Feb 2022 22:17:41 +0100 Subject: [PATCH 06/21] simplified meta line start regex Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 62253cc5cd..3f833a2a64 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -14,8 +14,8 @@ greedy: true }, 'meta': { // >> key: value - 'pattern': />{2}.*:.*/, - 'inside': { + pattern: />>.*:.*/, + inside: { 'property': { // key: pattern: /(>>\s*)[^\s:](?:[^:]*[^\s:])?/, lookbehind: true, From eef1b8fd59e3d61804da35ed5b7315f37ebcc1f8 Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Wed, 16 Feb 2022 07:53:11 +0100 Subject: [PATCH 07/21] fixed suggestions on PR #3337 (round1) --- components/prism-cooklang.js | 151 ++++++++++++------ .../languages/cooklang/cookware_feature.test | 146 +++++++++-------- .../cooklang/ingredient_feature.test | 144 +++++++++-------- tests/languages/cooklang/timer_feature.test | 25 +-- 4 files changed, 266 insertions(+), 200 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 3f833a2a64..fe9b7f49f6 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -1,84 +1,139 @@ (function (Prism) { - var ingr_cw_prefix = /(?:[@#][^{@#]+)\{/; - var ingr_cw_suffix = /\}/; - var quant1 = /(?:[^}|*%]*\*?)/; - var quant_unit = /(?:[^}|*%]+\*?%[^}]+)/; - var quant_servings_unit = /(?:(?:[^*}%|]+\|)+[^*}%|]+(?:%[^*|%}]+)?)/; + var single_token_suffix = /[^{}@#\s]+/.source; + var multi_token_infix = /[^{}@#]+/.source; + var multi_token_suffix = /\{[^}#@]*\}/.source; + + var multi_token = multi_token_infix + multi_token_suffix; + + var timer_units = /(?:h|hours|hrs|m|min|minutes)/.source; + + var amount_group_impl = { + pattern: new RegExp(/\{/.source + + '(?:(?:' + + /(?:[^{}|*%]+\*?)/.source // optional serving scale + + '|' + + /(?:(?:[^{}|*%]+\|)+[^{}|*%]+)/.source // serving alternatives + + ')' + /(?:%[^{}|*%]+)?/.source //optional unit + + ')?' + + /\}/.source + ), + inside: { + 'amount': { + pattern: /([\{|])[^{}|*%]+/, + lookbehind: true, + alias: 'number', + }, + 'unit': { + pattern: /(%)[^}]+/, + lookbehind: true, + alias: 'symbol', + }, + 'servings-scaler': { + pattern: /\*/, + alias: 'operator', + }, + 'servings-alternative-seperator': { + pattern: /\|/, + alias: 'operator', + }, + 'unit-separator': { + pattern: /(?:%|(\*)%)/, + lookbehind: true, + alias: 'operator', + }, + 'punctuation': /[{}]/, + } + }; Prism.languages.cooklang = { 'comment': { // [- comment -] // -- comment pattern: /\[-[\s\S]*?-\]|--.*/, - greedy: true + greedy: true, }, 'meta': { // >> key: value pattern: />>.*:.*/, inside: { - 'property': { // key: + property: { // key: pattern: /(>>\s*)[^\s:](?:[^:]*[^\s:])?/, lookbehind: true, } } }, - 'quant': { // @some ingredient{...} #some cookware{...} - 'pattern': new RegExp( - ingr_cw_prefix.source - + '(?:' - + quant1.source + '|' - + quant_unit.source + '|' - + quant_servings_unit.source + 'cookware-group': { // #...{...}, #... + pattern: new RegExp('#(?:' + + multi_token + + '|' + + single_token_suffix + ')' - + ingr_cw_suffix.source ), - 'inside': { - 'variable': { // some ingredient, some cookware - pattern: /([@#])[^{@#]+/, - lookbehind: true + inside: { + 'cookware': { + pattern: new RegExp('(#)(?:' + + multi_token_infix + + ')' + ), + lookbehind: true, + alias: 'variable', }, - 'amount-group': { - 'pattern': /\{[^{}]*\}/, // {...} - 'inside': { - 'punctuation': /[{}]/, - 'symbol': { // unit - 'pattern': /(%)[^}]+/, - 'lookbehind': true - }, - 'operator': /\*%|\*|%|\|/, // already includes not yet officially implemented servings operators - 'number': /[^{}*%]+/, // amount - } + 'cookware-keyword': { + pattern: /^#/, + alias: 'keyword', }, - 'keyword': /[@#]/, - } + 'amount-group': amount_group_impl, + }, }, - 'no-quant': { // ingredient, cookware - 'pattern': /[@#][^{@#\s]+/, - 'inside': { - 'keyword': /[@#]/, - 'variable': /[^{@#]+/ + 'ingredient-group': { // @...{...}, @... + pattern: new RegExp('@(?:' + + multi_token + + '|' + + single_token_suffix + + ')'), + inside: { + 'ingredient': { + pattern: new RegExp('(@)(?:' + + multi_token_infix + + ')'), + lookbehind: true, + alias: 'variable', + }, + 'ingredient-keyword': { + pattern: /^@/, + alias: 'keyword', + }, + 'amount-group': amount_group_impl } }, 'timer-group': { // ~timer{...} - 'pattern': /~[^{}]*\{\d+%(?:hours|minutes)\}/, - 'inside': { - 'variable': { // timer name + pattern: new RegExp(/~[^{}]*\{\d+%/.source + timer_units + /\}/.source), + inside: { + 'timer': { pattern: /(~)[^{]+/, - lookbehind: true + lookbehind: true, + alias: 'variable', }, 'duration-group': { // {...} - 'pattern': /\{[^{}]+\}/, - 'inside': { + pattern: /\{[^{}]+\}/, + inside: { 'punctuation': /[{}]/, - 'symbol': { // unit - 'pattern': /(%)(?:minutes|min|m|hours|hrs|h)/, - 'lookbehind': true + 'unit': { + pattern: new RegExp(/(%)/.source + timer_units), + lookbehind: true, + alias: 'symbol', }, 'operator': /%/, - 'number': /\d+/, // amount + 'duration': { + pattern: /\d+/, + alias: 'number', + }, } }, - 'keyword': /~/, + 'timer-keyword': { + pattern: /^~/, + alias: 'keyword', + }, } } }; diff --git a/tests/languages/cooklang/cookware_feature.test b/tests/languages/cooklang/cookware_feature.test index bb12b078bb..8f882d849b 100644 --- a/tests/languages/cooklang/cookware_feature.test +++ b/tests/languages/cooklang/cookware_feature.test @@ -1,129 +1,133 @@ #spoon -#spoon and more @spoon +#spoon and more #spoon +#spoon is good but more #spoon are better #more spoon{} #even more spoon{1} #spoon{1%set} #spoon{2*%kg} #spoon{3|1%set} -#spoon{3*set} must not match +#spoon{3*set} must not match amount-group #spoon{3|set} -#spoon{3%*set} -#spoon{3%*%set} +#spoon{3%*set} must noch match amount-group +#spoon{3%*%set} must noch match amount-group ---------------------------------------------------- [ - ["no-quant", [ - ["keyword", "#"], - ["variable", "spoon"] + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"] ]], - ["no-quant", [ - ["keyword", "#"], - ["variable", "spoon"] + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"] ]], " and more ", - ["no-quant", [ - ["keyword", "@"], - ["variable", "spoon"] + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"] ]], - ["quant", [ - ["keyword", "#"], - ["variable", "more spoon"], + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"] + ]], + " is good but more ", + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"] + ]], + " are better\r\n", + + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "more spoon"], ["amount-group", [ ["punctuation", "{"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "#"], - ["variable", "even more spoon"], + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "even more spoon"], ["amount-group", [ ["punctuation", "{"], - ["number", "1"], + ["amount", "1"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "#"], - ["variable", "spoon"], + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"], ["amount-group", [ ["punctuation", "{"], - ["number", "1"], - ["operator", "%"], - ["symbol", "set"], + ["amount", "1"], + ["unit-separator", "%"], + ["unit", "set"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "#"], - ["variable", "spoon"], + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"], ["amount-group", [ ["punctuation", "{"], - ["number", "2"], - ["operator", "*%"], - ["symbol", "kg"], + ["amount", "2"], + ["servings-scaler", "*"], + ["unit-separator", "%"], + ["unit", "kg"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "#"], - ["variable", "spoon"], + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"], ["amount-group", [ ["punctuation", "{"], - ["number", "3"], - ["operator", "|"], - ["number", "1"], - ["operator", "%"], - ["symbol", "set"], + ["amount", "3"], + ["servings-alternative-seperator", "|"], + ["amount", "1"], + ["unit-separator", "%"], + ["unit", "set"], ["punctuation", "}"] ]] ]], - ["no-quant", [ - ["keyword", "#"], - ["variable", "spoon"] + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"], + "{3*set}" ]], - "{3*set} must not match\r\n", + " must not match amount-group\r\n", - ["quant", [ - ["keyword", "#"], - ["variable", "spoon"], + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"], ["amount-group", [ ["punctuation", "{"], - ["number", "3"], - ["operator", "|"], - ["number", "set"], + ["amount", "3"], + ["servings-alternative-seperator", "|"], + ["amount", "set"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "#"], - ["variable", "spoon"], - ["amount-group", [ - ["punctuation", "{"], - ["number", "3"], - ["operator", "%"], - ["symbol", "*set"], - ["punctuation", "}"] - ]] + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"], + "{3%*set}" ]], + " must noch match amount-group\r\n", - ["quant", [ - ["keyword", "#"], - ["variable", "spoon"], - ["amount-group", [ - ["punctuation", "{"], - ["number", "3"], - ["operator", "%"], - ["symbol", "*%set"], - ["punctuation", "}"] - ]] - ]] + ["cookware-group", [ + ["cookware-keyword", "#"], + ["cookware", "spoon"], + "{3%*%set}" + ]], + " must noch match amount-group" ] diff --git a/tests/languages/cooklang/ingredient_feature.test b/tests/languages/cooklang/ingredient_feature.test index 27fa8617b1..a059b8c817 100644 --- a/tests/languages/cooklang/ingredient_feature.test +++ b/tests/languages/cooklang/ingredient_feature.test @@ -1,129 +1,133 @@ @milk @milk and more @milk +@milk is good but more @milk is better @more milk{} @even more milk{1} @milk{1%l} @milk{2*%kg} @milk{3|1%L} -@milk{3*L} must not match +@milk{3*L} must not match amount-group @milk{3|L} -@milk{3%*L} -@milk{3%*%L} +@milk{3%*L} must noch match amount-group +@milk{3%*%L} must noch match amount-group ---------------------------------------------------- [ - ["no-quant", [ - ["keyword", "@"], - ["variable", "milk"] + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"] ]], - ["no-quant", [ - ["keyword", "@"], - ["variable", "milk"] + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"] ]], " and more ", - ["no-quant", [ - ["keyword", "@"], - ["variable", "milk"] + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"] ]], - ["quant", [ - ["keyword", "@"], - ["variable", "more milk"], + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"] + ]], + " is good but more ", + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"] + ]], + " is better\r\n", + + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "more milk"], ["amount-group", [ ["punctuation", "{"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "@"], - ["variable", "even more milk"], + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "even more milk"], ["amount-group", [ ["punctuation", "{"], - ["number", "1"], + ["amount", "1"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "@"], - ["variable", "milk"], + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"], ["amount-group", [ ["punctuation", "{"], - ["number", "1"], - ["operator", "%"], - ["symbol", "l"], + ["amount", "1"], + ["unit-separator", "%"], + ["unit", "l"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "@"], - ["variable", "milk"], + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"], ["amount-group", [ ["punctuation", "{"], - ["number", "2"], - ["operator", "*%"], - ["symbol", "kg"], + ["amount", "2"], + ["servings-scaler", "*"], + ["unit-separator", "%"], + ["unit", "kg"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "@"], - ["variable", "milk"], + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"], ["amount-group", [ ["punctuation", "{"], - ["number", "3"], - ["operator", "|"], - ["number", "1"], - ["operator", "%"], - ["symbol", "L"], + ["amount", "3"], + ["servings-alternative-seperator", "|"], + ["amount", "1"], + ["unit-separator", "%"], + ["unit", "L"], ["punctuation", "}"] ]] ]], - ["no-quant", [ - ["keyword", "@"], - ["variable", "milk"] + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"], + "{3*L}" ]], - "{3*L} must not match\r\n", + " must not match amount-group\r\n", - ["quant", [ - ["keyword", "@"], - ["variable", "milk"], + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"], ["amount-group", [ ["punctuation", "{"], - ["number", "3"], - ["operator", "|"], - ["number", "L"], + ["amount", "3"], + ["servings-alternative-seperator", "|"], + ["amount", "L"], ["punctuation", "}"] ]] ]], - ["quant", [ - ["keyword", "@"], - ["variable", "milk"], - ["amount-group", [ - ["punctuation", "{"], - ["number", "3"], - ["operator", "%"], - ["symbol", "*L"], - ["punctuation", "}"] - ]] + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"], + "{3%*L}" ]], + " must noch match amount-group\r\n", - ["quant", [ - ["keyword", "@"], - ["variable", "milk"], - ["amount-group", [ - ["punctuation", "{"], - ["number", "3"], - ["operator", "%"], - ["symbol", "*%L"], - ["punctuation", "}"] - ]] - ]] + ["ingredient-group", [ + ["ingredient-keyword", "@"], + ["ingredient", "milk"], + "{3%*%L}" + ]], + " must noch match amount-group" ] diff --git a/tests/languages/cooklang/timer_feature.test b/tests/languages/cooklang/timer_feature.test index 2db42bd700..153dfa3ac1 100644 --- a/tests/languages/cooklang/timer_feature.test +++ b/tests/languages/cooklang/timer_feature.test @@ -7,35 +7,38 @@ [ ["timer-group", [ - ["keyword", "~"], + ["timer-keyword", "~"], ["duration-group", [ ["punctuation", "{"], - ["number", "25"], + ["duration", "25"], ["operator", "%"], - ["symbol", "minutes"], + ["unit", "m"], + "inutes", ["punctuation", "}"] ]] ]], ["timer-group", [ - ["keyword", "~"], - ["variable", "eggs"], + ["timer-keyword", "~"], + ["timer", "eggs"], ["duration-group", [ ["punctuation", "{"], - ["number", "25"], + ["duration", "25"], ["operator", "%"], - ["symbol", "minutes"], + ["unit", "m"], + "inutes", ["punctuation", "}"] ]] ]], "\r\n~{abc%minutes} must not match\r\n", ["timer-group", [ - ["keyword", "~"], - ["variable", "eggs"], + ["timer-keyword", "~"], + ["timer", "eggs"], ["duration-group", [ ["punctuation", "{"], - ["number", "2"], + ["duration", "2"], ["operator", "%"], - ["symbol", "hours"], + ["unit", "h"], + "ours", ["punctuation", "}"] ]] ]] From 7b31918f358b4b20a5f25afa12088be5c083462f Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Wed, 16 Feb 2022 08:01:50 +0100 Subject: [PATCH 08/21] ran build --- components/prism-cooklang.js | 2 ++ components/prism-cooklang.min.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index fe9b7f49f6..140270c095 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -107,6 +107,7 @@ } }, 'timer-group': { // ~timer{...} + // eslint-disable-next-line regexp/sort-alternatives pattern: new RegExp(/~[^{}]*\{\d+%/.source + timer_units + /\}/.source), inside: { 'timer': { @@ -119,6 +120,7 @@ inside: { 'punctuation': /[{}]/, 'unit': { + // eslint-disable-next-line regexp/no-dupe-disjunctions pattern: new RegExp(/(%)/.source + timer_units), lookbehind: true, alias: 'symbol', diff --git a/components/prism-cooklang.min.js b/components/prism-cooklang.min.js index 57634af2cb..4213861571 100644 --- a/components/prism-cooklang.min.js +++ b/components/prism-cooklang.min.js @@ -1 +1 @@ -Prism.languages.cooklang={comment:[/\[-[\s\S]*?-\]/,/-{2}[^\r\n]*/],meta:{pattern:/>{2}.*:.*/,inside:{property:{pattern:/(>{2}\s*)[^:]+/,lookbehind:!0}}},quant:{pattern:new RegExp(/(?:[@#][^{@#]+)\{/.source+"(?:"+/(?:[^}|*%]*\*?)/.source+"|"+/(?:[^}|*%]+\*?%[^}]+)/.source+"|"+/(?:(?:[^*}%|]+\|)+[^*}%|]+(?:%[^*|%}]+)?)/.source+")"+/\}/.source),inside:{variable:{pattern:/([@#])[^{@#]+/,lookbehind:!0},"amount-group":{pattern:/\{[^{}]*\}/,inside:{punctuation:/[{}]/,symbol:{pattern:/(%)[^}]+/,lookbehind:!0},operator:/\*%|\*|%|\|/,number:/[^{}*%]+/}},keyword:/[@#]/}},"no-quant":{pattern:/[@#][^{@#\s]+/,inside:{keyword:/[@#]/,variable:/[^{@#]+/}},"timer-group":{pattern:/~[^{}]*\{\d+%(?:hours|minutes)\}/,inside:{variable:{pattern:/(~)[^{]+/,lookbehind:!0},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,symbol:{pattern:/(%)(?:minutes|min|m|hours|hrs|h)/,lookbehind:!0},operator:/%/,number:/\d+/}},keyword:/~/}}}; \ No newline at end of file +!function(e){var a="[^{}@#\\s]+",t="[^{}@#]+",n=t+"\\{[^}#@]*\\}",r="(?:h|hours|hrs|m|min|minutes)",i={pattern:new RegExp("\\{(?:(?:(?:[^{}|*%]+\\*?)|(?:(?:[^{}|*%]+\\|)+[^{}|*%]+))(?:%[^{}|*%]+)?)?\\}"),inside:{amount:{pattern:/([\{|])[^{}|*%]+/,lookbehind:!0,alias:"number"},unit:{pattern:/(%)[^}]+/,lookbehind:!0,alias:"symbol"},"servings-scaler":{pattern:/\*/,alias:"operator"},"servings-alternative-seperator":{pattern:/\|/,alias:"operator"},"unit-separator":{pattern:/(?:%|(\*)%)/,lookbehind:!0,alias:"operator"},punctuation:/[{}]/}};e.languages.cooklang={comment:{pattern:/\[-[\s\S]*?-\]|--.*/,greedy:!0},meta:{pattern:/>>.*:.*/,inside:{property:{pattern:/(>>\s*)[^\s:](?:[^:]*[^\s:])?/,lookbehind:!0}}},"cookware-group":{pattern:new RegExp("#(?:"+n+"|"+a+")"),inside:{cookware:{pattern:new RegExp("(#)(?:"+t+")"),lookbehind:!0,alias:"variable"},"cookware-keyword":{pattern:/^#/,alias:"keyword"},"amount-group":i}},"ingredient-group":{pattern:new RegExp("@(?:"+n+"|"+a+")"),inside:{ingredient:{pattern:new RegExp("(@)(?:"+t+")"),lookbehind:!0,alias:"variable"},"ingredient-keyword":{pattern:/^@/,alias:"keyword"},"amount-group":i}},"timer-group":{pattern:new RegExp("~[^{}]*\\{\\d+%"+r+"\\}"),inside:{timer:{pattern:/(~)[^{]+/,lookbehind:!0,alias:"variable"},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,unit:{pattern:new RegExp("(%)"+r),lookbehind:!0,alias:"symbol"},operator:/%/,duration:{pattern:/\d+/,alias:"number"}}},"timer-keyword":{pattern:/^~/,alias:"keyword"}}}}}(Prism); \ No newline at end of file From 359ab0a55239b18734916b3a0aeb771b0b91269e Mon Sep 17 00:00:00 2001 From: ahue Date: Wed, 16 Feb 2022 22:41:02 +0100 Subject: [PATCH 09/21] using ^ to mark pattern start for timer Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 140270c095..c74fd0f71d 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -111,7 +111,7 @@ pattern: new RegExp(/~[^{}]*\{\d+%/.source + timer_units + /\}/.source), inside: { 'timer': { - pattern: /(~)[^{]+/, + pattern: /(^~)[^{]+/, lookbehind: true, alias: 'variable', }, From 5f9dc49b0ff421c5ce314c423753b26eceff8bbc Mon Sep 17 00:00:00 2001 From: ahue Date: Wed, 16 Feb 2022 22:41:18 +0100 Subject: [PATCH 10/21] Update components/prism-cooklang.js Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index c74fd0f71d..b126383998 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -56,7 +56,7 @@ 'meta': { // >> key: value pattern: />>.*:.*/, inside: { - property: { // key: + 'property': { // key: pattern: /(>>\s*)[^\s:](?:[^:]*[^\s:])?/, lookbehind: true, } From 1723c159da7b14e45035279f3e44561e51847767 Mon Sep 17 00:00:00 2001 From: ahue Date: Wed, 16 Feb 2022 22:41:33 +0100 Subject: [PATCH 11/21] fixed spelling Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index b126383998..81cd5fe728 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -33,7 +33,7 @@ pattern: /\*/, alias: 'operator', }, - 'servings-alternative-seperator': { + 'servings-alternative-separator': { pattern: /\|/, alias: 'operator', }, From 45184a6e05fb9d07478b67262de04d0fa44e088d Mon Sep 17 00:00:00 2001 From: ahue Date: Wed, 16 Feb 2022 22:42:50 +0100 Subject: [PATCH 12/21] fixed regexp/no-dupe-disjunctions Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 81cd5fe728..96a9a33792 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -120,8 +120,7 @@ inside: { 'punctuation': /[{}]/, 'unit': { - // eslint-disable-next-line regexp/no-dupe-disjunctions - pattern: new RegExp(/(%)/.source + timer_units), + pattern: new RegExp(/(%)/.source + timer_units + /\b/.source), lookbehind: true, alias: 'symbol', }, From 6441cf2c3045290a0282f974608690554725ffd0 Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Wed, 16 Feb 2022 23:12:46 +0100 Subject: [PATCH 13/21] fixed suggestions on PR PrismJS#3337 (round2) --- components/prism-cooklang.js | 4 ++-- components/prism-cooklang.min.js | 2 +- .../languages/cooklang/cookware_feature.test | 4 ++-- .../cooklang/ingredient_feature.test | 4 ++-- tests/languages/cooklang/timer_feature.test | 19 ++++++++++++++----- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 96a9a33792..22a1d79428 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -71,7 +71,7 @@ ), inside: { 'cookware': { - pattern: new RegExp('(#)(?:' + pattern: new RegExp('(^#)(?:' + multi_token_infix + ')' ), @@ -93,7 +93,7 @@ + ')'), inside: { 'ingredient': { - pattern: new RegExp('(@)(?:' + pattern: new RegExp('(^@)(?:' + multi_token_infix + ')'), lookbehind: true, diff --git a/components/prism-cooklang.min.js b/components/prism-cooklang.min.js index 4213861571..2c1fd18e6c 100644 --- a/components/prism-cooklang.min.js +++ b/components/prism-cooklang.min.js @@ -1 +1 @@ -!function(e){var a="[^{}@#\\s]+",t="[^{}@#]+",n=t+"\\{[^}#@]*\\}",r="(?:h|hours|hrs|m|min|minutes)",i={pattern:new RegExp("\\{(?:(?:(?:[^{}|*%]+\\*?)|(?:(?:[^{}|*%]+\\|)+[^{}|*%]+))(?:%[^{}|*%]+)?)?\\}"),inside:{amount:{pattern:/([\{|])[^{}|*%]+/,lookbehind:!0,alias:"number"},unit:{pattern:/(%)[^}]+/,lookbehind:!0,alias:"symbol"},"servings-scaler":{pattern:/\*/,alias:"operator"},"servings-alternative-seperator":{pattern:/\|/,alias:"operator"},"unit-separator":{pattern:/(?:%|(\*)%)/,lookbehind:!0,alias:"operator"},punctuation:/[{}]/}};e.languages.cooklang={comment:{pattern:/\[-[\s\S]*?-\]|--.*/,greedy:!0},meta:{pattern:/>>.*:.*/,inside:{property:{pattern:/(>>\s*)[^\s:](?:[^:]*[^\s:])?/,lookbehind:!0}}},"cookware-group":{pattern:new RegExp("#(?:"+n+"|"+a+")"),inside:{cookware:{pattern:new RegExp("(#)(?:"+t+")"),lookbehind:!0,alias:"variable"},"cookware-keyword":{pattern:/^#/,alias:"keyword"},"amount-group":i}},"ingredient-group":{pattern:new RegExp("@(?:"+n+"|"+a+")"),inside:{ingredient:{pattern:new RegExp("(@)(?:"+t+")"),lookbehind:!0,alias:"variable"},"ingredient-keyword":{pattern:/^@/,alias:"keyword"},"amount-group":i}},"timer-group":{pattern:new RegExp("~[^{}]*\\{\\d+%"+r+"\\}"),inside:{timer:{pattern:/(~)[^{]+/,lookbehind:!0,alias:"variable"},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,unit:{pattern:new RegExp("(%)"+r),lookbehind:!0,alias:"symbol"},operator:/%/,duration:{pattern:/\d+/,alias:"number"}}},"timer-keyword":{pattern:/^~/,alias:"keyword"}}}}}(Prism); \ No newline at end of file +!function(e){var a="[^{}@#\\s]+",t="[^{}@#]+",n=t+"\\{[^}#@]*\\}",r="(?:h|hours|hrs|m|min|minutes)",i={pattern:new RegExp("\\{(?:(?:(?:[^{}|*%]+\\*?)|(?:(?:[^{}|*%]+\\|)+[^{}|*%]+))(?:%[^{}|*%]+)?)?\\}"),inside:{amount:{pattern:/([\{|])[^{}|*%]+/,lookbehind:!0,alias:"number"},unit:{pattern:/(%)[^}]+/,lookbehind:!0,alias:"symbol"},"servings-scaler":{pattern:/\*/,alias:"operator"},"servings-alternative-separator":{pattern:/\|/,alias:"operator"},"unit-separator":{pattern:/(?:%|(\*)%)/,lookbehind:!0,alias:"operator"},punctuation:/[{}]/}};e.languages.cooklang={comment:{pattern:/\[-[\s\S]*?-\]|--.*/,greedy:!0},meta:{pattern:/>>.*:.*/,inside:{property:{pattern:/(>>\s*)[^\s:](?:[^:]*[^\s:])?/,lookbehind:!0}}},"cookware-group":{pattern:new RegExp("#(?:"+n+"|"+a+")"),inside:{cookware:{pattern:new RegExp("(^#)(?:"+t+")"),lookbehind:!0,alias:"variable"},"cookware-keyword":{pattern:/^#/,alias:"keyword"},"amount-group":i}},"ingredient-group":{pattern:new RegExp("@(?:"+n+"|"+a+")"),inside:{ingredient:{pattern:new RegExp("(^@)(?:"+t+")"),lookbehind:!0,alias:"variable"},"ingredient-keyword":{pattern:/^@/,alias:"keyword"},"amount-group":i}},"timer-group":{pattern:new RegExp("~[^{}]*\\{\\d+%"+r+"\\}"),inside:{timer:{pattern:/(^~)[^{]+/,lookbehind:!0,alias:"variable"},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,unit:{pattern:new RegExp("(%)"+r+"\\b"),lookbehind:!0,alias:"symbol"},operator:/%/,duration:{pattern:/\d+/,alias:"number"}}},"timer-keyword":{pattern:/^~/,alias:"keyword"}}}}}(Prism); \ No newline at end of file diff --git a/tests/languages/cooklang/cookware_feature.test b/tests/languages/cooklang/cookware_feature.test index 8f882d849b..67b5ef4a2e 100644 --- a/tests/languages/cooklang/cookware_feature.test +++ b/tests/languages/cooklang/cookware_feature.test @@ -90,7 +90,7 @@ ["amount-group", [ ["punctuation", "{"], ["amount", "3"], - ["servings-alternative-seperator", "|"], + ["servings-alternative-separator", "|"], ["amount", "1"], ["unit-separator", "%"], ["unit", "set"], @@ -111,7 +111,7 @@ ["amount-group", [ ["punctuation", "{"], ["amount", "3"], - ["servings-alternative-seperator", "|"], + ["servings-alternative-separator", "|"], ["amount", "set"], ["punctuation", "}"] ]] diff --git a/tests/languages/cooklang/ingredient_feature.test b/tests/languages/cooklang/ingredient_feature.test index a059b8c817..4e9e70d9a2 100644 --- a/tests/languages/cooklang/ingredient_feature.test +++ b/tests/languages/cooklang/ingredient_feature.test @@ -90,7 +90,7 @@ ["amount-group", [ ["punctuation", "{"], ["amount", "3"], - ["servings-alternative-seperator", "|"], + ["servings-alternative-separator", "|"], ["amount", "1"], ["unit-separator", "%"], ["unit", "L"], @@ -111,7 +111,7 @@ ["amount-group", [ ["punctuation", "{"], ["amount", "3"], - ["servings-alternative-seperator", "|"], + ["servings-alternative-separator", "|"], ["amount", "L"], ["punctuation", "}"] ]] diff --git a/tests/languages/cooklang/timer_feature.test b/tests/languages/cooklang/timer_feature.test index 153dfa3ac1..7b619a7986 100644 --- a/tests/languages/cooklang/timer_feature.test +++ b/tests/languages/cooklang/timer_feature.test @@ -2,6 +2,7 @@ ~eggs{25%minutes} ~{abc%minutes} must not match ~eggs{2%hours} +~eggs{2%h} ---------------------------------------------------- @@ -12,8 +13,7 @@ ["punctuation", "{"], ["duration", "25"], ["operator", "%"], - ["unit", "m"], - "inutes", + ["unit", "minutes"], ["punctuation", "}"] ]] ]], @@ -24,12 +24,22 @@ ["punctuation", "{"], ["duration", "25"], ["operator", "%"], - ["unit", "m"], - "inutes", + ["unit", "minutes"], ["punctuation", "}"] ]] ]], "\r\n~{abc%minutes} must not match\r\n", + ["timer-group", [ + ["timer-keyword", "~"], + ["timer", "eggs"], + ["duration-group", [ + ["punctuation", "{"], + ["duration", "2"], + ["operator", "%"], + ["unit", "hours"], + ["punctuation", "}"] + ]] + ]], ["timer-group", [ ["timer-keyword", "~"], ["timer", "eggs"], @@ -38,7 +48,6 @@ ["duration", "2"], ["operator", "%"], ["unit", "h"], - "ours", ["punctuation", "}"] ]] ]] From 2457e88b10de4800aef607662f5892e9eab6f17e Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Fri, 18 Feb 2022 06:47:44 +0100 Subject: [PATCH 14/21] proper single word regex --- components/prism-cooklang.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 22a1d79428..300d7cd10e 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -1,7 +1,7 @@ (function (Prism) { - var single_token_suffix = /[^{}@#\s]+/.source; - var multi_token_infix = /[^{}@#]+/.source; + var single_token_suffix = /(?:(?!\s)[\d$+<=a-zA-Z\x80-\uFFFF])+/.source; + var multi_token_infix = /[^{}@#]+/.source; // /(?:(?!\s)[\d$+<=A-Z\x80-\uFFFF])+/ var multi_token_suffix = /\{[^}#@]*\}/.source; var multi_token = multi_token_infix + multi_token_suffix; @@ -46,6 +46,7 @@ } }; + Prism.languages.cooklang = { 'comment': { // [- comment -] From 98d0e7a42d754f975968164caf49a11399d2d464 Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Fri, 18 Feb 2022 06:55:28 +0100 Subject: [PATCH 15/21] cookware quantity now aligned with EBNF --- components/prism-cooklang.js | 15 +++++++++++++-- tests/languages/cooklang/cookware_feature.test | 8 ++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 300d7cd10e..0eb2438a19 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -83,7 +83,18 @@ pattern: /^#/, alias: 'keyword', }, - 'amount-group': amount_group_impl, + 'quantity-group': { + pattern: new RegExp(/\{[^{}@#]*\}/), + inside: { + 'quantity': { + pattern: new RegExp(/(^\{)/.source + multi_token_infix), + lookbehind: true, + alias: 'number', + }, + 'punctuation': /[{}]/, + } + } + }, }, 'ingredient-group': { // @...{...}, @... @@ -104,7 +115,7 @@ pattern: /^@/, alias: 'keyword', }, - 'amount-group': amount_group_impl + 'amount-group': amount_group_impl, } }, 'timer-group': { // ~timer{...} diff --git a/tests/languages/cooklang/cookware_feature.test b/tests/languages/cooklang/cookware_feature.test index 67b5ef4a2e..f3a72f3b7e 100644 --- a/tests/languages/cooklang/cookware_feature.test +++ b/tests/languages/cooklang/cookware_feature.test @@ -6,10 +6,10 @@ #spoon{1%set} #spoon{2*%kg} #spoon{3|1%set} -#spoon{3*set} must not match amount-group -#spoon{3|set} -#spoon{3%*set} must noch match amount-group -#spoon{3%*%set} must noch match amount-group +#spoon{3*set} +#spoon{3|set} +#spoon{3%*set} +#spoon{3%*%set} ---------------------------------------------------- From ff0d21fb0c0fc09c9611a1c94ce7df7fd95ff730 Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Fri, 18 Feb 2022 07:08:25 +0100 Subject: [PATCH 16/21] adapted cookware tests, ran build --- components/prism-cooklang.js | 3 +- components/prism-cooklang.min.js | 2 +- .../languages/cooklang/cookware_feature.test | 56 +++++++++---------- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 0eb2438a19..1f294e475f 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -1,7 +1,7 @@ (function (Prism) { var single_token_suffix = /(?:(?!\s)[\d$+<=a-zA-Z\x80-\uFFFF])+/.source; - var multi_token_infix = /[^{}@#]+/.source; // /(?:(?!\s)[\d$+<=A-Z\x80-\uFFFF])+/ + var multi_token_infix = /[^{}@#]+/.source; var multi_token_suffix = /\{[^}#@]*\}/.source; var multi_token = multi_token_infix + multi_token_suffix; @@ -94,7 +94,6 @@ 'punctuation': /[{}]/, } } - }, }, 'ingredient-group': { // @...{...}, @... diff --git a/components/prism-cooklang.min.js b/components/prism-cooklang.min.js index 2c1fd18e6c..9f2ec79c4e 100644 --- a/components/prism-cooklang.min.js +++ b/components/prism-cooklang.min.js @@ -1 +1 @@ -!function(e){var a="[^{}@#\\s]+",t="[^{}@#]+",n=t+"\\{[^}#@]*\\}",r="(?:h|hours|hrs|m|min|minutes)",i={pattern:new RegExp("\\{(?:(?:(?:[^{}|*%]+\\*?)|(?:(?:[^{}|*%]+\\|)+[^{}|*%]+))(?:%[^{}|*%]+)?)?\\}"),inside:{amount:{pattern:/([\{|])[^{}|*%]+/,lookbehind:!0,alias:"number"},unit:{pattern:/(%)[^}]+/,lookbehind:!0,alias:"symbol"},"servings-scaler":{pattern:/\*/,alias:"operator"},"servings-alternative-separator":{pattern:/\|/,alias:"operator"},"unit-separator":{pattern:/(?:%|(\*)%)/,lookbehind:!0,alias:"operator"},punctuation:/[{}]/}};e.languages.cooklang={comment:{pattern:/\[-[\s\S]*?-\]|--.*/,greedy:!0},meta:{pattern:/>>.*:.*/,inside:{property:{pattern:/(>>\s*)[^\s:](?:[^:]*[^\s:])?/,lookbehind:!0}}},"cookware-group":{pattern:new RegExp("#(?:"+n+"|"+a+")"),inside:{cookware:{pattern:new RegExp("(^#)(?:"+t+")"),lookbehind:!0,alias:"variable"},"cookware-keyword":{pattern:/^#/,alias:"keyword"},"amount-group":i}},"ingredient-group":{pattern:new RegExp("@(?:"+n+"|"+a+")"),inside:{ingredient:{pattern:new RegExp("(^@)(?:"+t+")"),lookbehind:!0,alias:"variable"},"ingredient-keyword":{pattern:/^@/,alias:"keyword"},"amount-group":i}},"timer-group":{pattern:new RegExp("~[^{}]*\\{\\d+%"+r+"\\}"),inside:{timer:{pattern:/(^~)[^{]+/,lookbehind:!0,alias:"variable"},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,unit:{pattern:new RegExp("(%)"+r+"\\b"),lookbehind:!0,alias:"symbol"},operator:/%/,duration:{pattern:/\d+/,alias:"number"}}},"timer-keyword":{pattern:/^~/,alias:"keyword"}}}}}(Prism); \ No newline at end of file +!function(e){var a="(?:(?!\\s)[\\d$+<=a-zA-Z\\x80-\\uFFFF])+",n="[^{}@#]+",t=n+"\\{[^}#@]*\\}",r="(?:h|hours|hrs|m|min|minutes)",i={pattern:new RegExp("\\{(?:(?:(?:[^{}|*%]+\\*?)|(?:(?:[^{}|*%]+\\|)+[^{}|*%]+))(?:%[^{}|*%]+)?)?\\}"),inside:{amount:{pattern:/([\{|])[^{}|*%]+/,lookbehind:!0,alias:"number"},unit:{pattern:/(%)[^}]+/,lookbehind:!0,alias:"symbol"},"servings-scaler":{pattern:/\*/,alias:"operator"},"servings-alternative-separator":{pattern:/\|/,alias:"operator"},"unit-separator":{pattern:/(?:%|(\*)%)/,lookbehind:!0,alias:"operator"},punctuation:/[{}]/}};e.languages.cooklang={comment:{pattern:/\[-[\s\S]*?-\]|--.*/,greedy:!0},meta:{pattern:/>>.*:.*/,inside:{property:{pattern:/(>>\s*)[^\s:](?:[^:]*[^\s:])?/,lookbehind:!0}}},"cookware-group":{pattern:new RegExp("#(?:"+t+"|"+a+")"),inside:{cookware:{pattern:new RegExp("(^#)(?:"+n+")"),lookbehind:!0,alias:"variable"},"cookware-keyword":{pattern:/^#/,alias:"keyword"},"quantity-group":{pattern:new RegExp(/\{[^{}@#]*\}/),inside:{quantity:{pattern:new RegExp("(^\\{)"+n),lookbehind:!0,alias:"number"},punctuation:/[{}]/}}}},"ingredient-group":{pattern:new RegExp("@(?:"+t+"|"+a+")"),inside:{ingredient:{pattern:new RegExp("(^@)(?:"+n+")"),lookbehind:!0,alias:"variable"},"ingredient-keyword":{pattern:/^@/,alias:"keyword"},"amount-group":i}},"timer-group":{pattern:new RegExp("~[^{}]*\\{\\d+%"+r+"\\}"),inside:{timer:{pattern:/(^~)[^{]+/,lookbehind:!0,alias:"variable"},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,unit:{pattern:new RegExp("(%)"+r+"\\b"),lookbehind:!0,alias:"symbol"},operator:/%/,duration:{pattern:/\d+/,alias:"number"}}},"timer-keyword":{pattern:/^~/,alias:"keyword"}}}}}(Prism); \ No newline at end of file diff --git a/tests/languages/cooklang/cookware_feature.test b/tests/languages/cooklang/cookware_feature.test index f3a72f3b7e..5da3430cdb 100644 --- a/tests/languages/cooklang/cookware_feature.test +++ b/tests/languages/cooklang/cookware_feature.test @@ -43,7 +43,7 @@ ["cookware-group", [ ["cookware-keyword", "#"], ["cookware", "more spoon"], - ["amount-group", [ + ["quantity-group", [ ["punctuation", "{"], ["punctuation", "}"] ]] @@ -52,9 +52,9 @@ ["cookware-group", [ ["cookware-keyword", "#"], ["cookware", "even more spoon"], - ["amount-group", [ + ["quantity-group", [ ["punctuation", "{"], - ["amount", "1"], + ["quantity", "1"], ["punctuation", "}"] ]] ]], @@ -62,11 +62,9 @@ ["cookware-group", [ ["cookware-keyword", "#"], ["cookware", "spoon"], - ["amount-group", [ + ["quantity-group", [ ["punctuation", "{"], - ["amount", "1"], - ["unit-separator", "%"], - ["unit", "set"], + ["quantity", "1%set"], ["punctuation", "}"] ]] ]], @@ -74,12 +72,9 @@ ["cookware-group", [ ["cookware-keyword", "#"], ["cookware", "spoon"], - ["amount-group", [ + ["quantity-group", [ ["punctuation", "{"], - ["amount", "2"], - ["servings-scaler", "*"], - ["unit-separator", "%"], - ["unit", "kg"], + ["quantity", "2*%kg"], ["punctuation", "}"] ]] ]], @@ -87,13 +82,9 @@ ["cookware-group", [ ["cookware-keyword", "#"], ["cookware", "spoon"], - ["amount-group", [ + ["quantity-group", [ ["punctuation", "{"], - ["amount", "3"], - ["servings-alternative-separator", "|"], - ["amount", "1"], - ["unit-separator", "%"], - ["unit", "set"], + ["quantity", "3|1%set"], ["punctuation", "}"] ]] ]], @@ -101,18 +92,19 @@ ["cookware-group", [ ["cookware-keyword", "#"], ["cookware", "spoon"], - "{3*set}" + ["quantity-group", [ + ["punctuation", "{"], + ["quantity", "3*set"], + ["punctuation", "}"] + ]] ]], - " must not match amount-group\r\n", ["cookware-group", [ ["cookware-keyword", "#"], ["cookware", "spoon"], - ["amount-group", [ + ["quantity-group", [ ["punctuation", "{"], - ["amount", "3"], - ["servings-alternative-separator", "|"], - ["amount", "set"], + ["quantity", "3|set"], ["punctuation", "}"] ]] ]], @@ -120,14 +112,20 @@ ["cookware-group", [ ["cookware-keyword", "#"], ["cookware", "spoon"], - "{3%*set}" + ["quantity-group", [ + ["punctuation", "{"], + ["quantity", "3%*set"], + ["punctuation", "}"] + ]] ]], - " must noch match amount-group\r\n", ["cookware-group", [ ["cookware-keyword", "#"], ["cookware", "spoon"], - "{3%*%set}" - ]], - " must noch match amount-group" + ["quantity-group", [ + ["punctuation", "{"], + ["quantity", "3%*%set"], + ["punctuation", "}"] + ]] + ]] ] From 4c4af12a78f17c667a713c7935e2fb51e2852669 Mon Sep 17 00:00:00 2001 From: ahue Date: Fri, 18 Feb 2022 23:59:33 +0100 Subject: [PATCH 17/21] revised timer-group pattern Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 1f294e475f..9f1f8a549a 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -119,7 +119,7 @@ }, 'timer-group': { // ~timer{...} // eslint-disable-next-line regexp/sort-alternatives - pattern: new RegExp(/~[^{}]*\{\d+%/.source + timer_units + /\}/.source), + pattern: /~(?!\s)[^@#~{}]*\{[^{}]*\}/, inside: { 'timer': { pattern: /(^~)[^{]+/, From be88670d99ba0bc5dde5545de80b4d148b8cd5cc Mon Sep 17 00:00:00 2001 From: ahue Date: Sat, 19 Feb 2022 00:00:06 +0100 Subject: [PATCH 18/21] duration-group in line with EBNF Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 9f1f8a549a..65711470cc 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -127,7 +127,7 @@ alias: 'variable', }, 'duration-group': { // {...} - pattern: /\{[^{}]+\}/, + pattern: /\{[^{}]*\}/, inside: { 'punctuation': /[{}]/, 'unit': { From 29d8fa328739813c8a9662ce27a5580732d69e25 Mon Sep 17 00:00:00 2001 From: ahue Date: Sat, 19 Feb 2022 00:01:17 +0100 Subject: [PATCH 19/21] more flexibility on the timer units separator Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 65711470cc..15d0d5abad 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -131,7 +131,7 @@ inside: { 'punctuation': /[{}]/, 'unit': { - pattern: new RegExp(/(%)/.source + timer_units + /\b/.source), + pattern: new RegExp(/(%\s*)/.source + timer_units + /\b/.source), lookbehind: true, alias: 'symbol', }, From fa33e585dcca9393438ffaec936ee1259fd4392b Mon Sep 17 00:00:00 2001 From: ahue Date: Sat, 19 Feb 2022 00:03:39 +0100 Subject: [PATCH 20/21] allowing almost anything in the amount-group Co-authored-by: Michael Schmidt --- components/prism-cooklang.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index 15d0d5abad..ebf793a94e 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -9,15 +9,7 @@ var timer_units = /(?:h|hours|hrs|m|min|minutes)/.source; var amount_group_impl = { - pattern: new RegExp(/\{/.source - + '(?:(?:' - + /(?:[^{}|*%]+\*?)/.source // optional serving scale - + '|' - + /(?:(?:[^{}|*%]+\|)+[^{}|*%]+)/.source // serving alternatives - + ')' + /(?:%[^{}|*%]+)?/.source //optional unit - + ')?' - + /\}/.source - ), + pattern: /\{[^{}]*\}/, inside: { 'amount': { pattern: /([\{|])[^{}|*%]+/, From 42770777ae233ff59a6f1d12ff9d94ed1056bc72 Mon Sep 17 00:00:00 2001 From: Andreas Huebner Date: Sat, 19 Feb 2022 00:20:23 +0100 Subject: [PATCH 21/21] updated tests, ran build --- components/prism-cooklang.js | 2 ++ components/prism-cooklang.min.js | 2 +- .../cooklang/ingredient_feature.test | 32 ++++++++++++++----- tests/languages/cooklang/timer_feature.test | 16 +++++++++- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/components/prism-cooklang.js b/components/prism-cooklang.js index ebf793a94e..cb49ed1260 100644 --- a/components/prism-cooklang.js +++ b/components/prism-cooklang.js @@ -1,5 +1,7 @@ (function (Prism) { + // see https://github.com/cooklang/spec/blob/main/EBNF.md + var single_token_suffix = /(?:(?!\s)[\d$+<=a-zA-Z\x80-\uFFFF])+/.source; var multi_token_infix = /[^{}@#]+/.source; var multi_token_suffix = /\{[^}#@]*\}/.source; diff --git a/components/prism-cooklang.min.js b/components/prism-cooklang.min.js index 9f2ec79c4e..4a46dbcad4 100644 --- a/components/prism-cooklang.min.js +++ b/components/prism-cooklang.min.js @@ -1 +1 @@ -!function(e){var a="(?:(?!\\s)[\\d$+<=a-zA-Z\\x80-\\uFFFF])+",n="[^{}@#]+",t=n+"\\{[^}#@]*\\}",r="(?:h|hours|hrs|m|min|minutes)",i={pattern:new RegExp("\\{(?:(?:(?:[^{}|*%]+\\*?)|(?:(?:[^{}|*%]+\\|)+[^{}|*%]+))(?:%[^{}|*%]+)?)?\\}"),inside:{amount:{pattern:/([\{|])[^{}|*%]+/,lookbehind:!0,alias:"number"},unit:{pattern:/(%)[^}]+/,lookbehind:!0,alias:"symbol"},"servings-scaler":{pattern:/\*/,alias:"operator"},"servings-alternative-separator":{pattern:/\|/,alias:"operator"},"unit-separator":{pattern:/(?:%|(\*)%)/,lookbehind:!0,alias:"operator"},punctuation:/[{}]/}};e.languages.cooklang={comment:{pattern:/\[-[\s\S]*?-\]|--.*/,greedy:!0},meta:{pattern:/>>.*:.*/,inside:{property:{pattern:/(>>\s*)[^\s:](?:[^:]*[^\s:])?/,lookbehind:!0}}},"cookware-group":{pattern:new RegExp("#(?:"+t+"|"+a+")"),inside:{cookware:{pattern:new RegExp("(^#)(?:"+n+")"),lookbehind:!0,alias:"variable"},"cookware-keyword":{pattern:/^#/,alias:"keyword"},"quantity-group":{pattern:new RegExp(/\{[^{}@#]*\}/),inside:{quantity:{pattern:new RegExp("(^\\{)"+n),lookbehind:!0,alias:"number"},punctuation:/[{}]/}}}},"ingredient-group":{pattern:new RegExp("@(?:"+t+"|"+a+")"),inside:{ingredient:{pattern:new RegExp("(^@)(?:"+n+")"),lookbehind:!0,alias:"variable"},"ingredient-keyword":{pattern:/^@/,alias:"keyword"},"amount-group":i}},"timer-group":{pattern:new RegExp("~[^{}]*\\{\\d+%"+r+"\\}"),inside:{timer:{pattern:/(^~)[^{]+/,lookbehind:!0,alias:"variable"},"duration-group":{pattern:/\{[^{}]+\}/,inside:{punctuation:/[{}]/,unit:{pattern:new RegExp("(%)"+r+"\\b"),lookbehind:!0,alias:"symbol"},operator:/%/,duration:{pattern:/\d+/,alias:"number"}}},"timer-keyword":{pattern:/^~/,alias:"keyword"}}}}}(Prism); \ No newline at end of file +!function(e){var a="(?:(?!\\s)[\\d$+<=a-zA-Z\\x80-\\uFFFF])+",t="[^{}@#]+",n=t+"\\{[^}#@]*\\}";Prism.languages.cooklang={comment:{pattern:/\[-[\s\S]*?-\]|--.*/,greedy:!0},meta:{pattern:/>>.*:.*/,inside:{property:{pattern:/(>>\s*)[^\s:](?:[^:]*[^\s:])?/,lookbehind:!0}}},"cookware-group":{pattern:new RegExp("#(?:"+n+"|"+a+")"),inside:{cookware:{pattern:new RegExp("(^#)(?:"+t+")"),lookbehind:!0,alias:"variable"},"cookware-keyword":{pattern:/^#/,alias:"keyword"},"quantity-group":{pattern:new RegExp(/\{[^{}@#]*\}/),inside:{quantity:{pattern:new RegExp("(^\\{)"+t),lookbehind:!0,alias:"number"},punctuation:/[{}]/}}}},"ingredient-group":{pattern:new RegExp("@(?:"+n+"|"+a+")"),inside:{ingredient:{pattern:new RegExp("(^@)(?:"+t+")"),lookbehind:!0,alias:"variable"},"ingredient-keyword":{pattern:/^@/,alias:"keyword"},"amount-group":{pattern:/\{[^{}]*\}/,inside:{amount:{pattern:/([\{|])[^{}|*%]+/,lookbehind:!0,alias:"number"},unit:{pattern:/(%)[^}]+/,lookbehind:!0,alias:"symbol"},"servings-scaler":{pattern:/\*/,alias:"operator"},"servings-alternative-separator":{pattern:/\|/,alias:"operator"},"unit-separator":{pattern:/(?:%|(\*)%)/,lookbehind:!0,alias:"operator"},punctuation:/[{}]/}}}},"timer-group":{pattern:/~(?!\s)[^@#~{}]*\{[^{}]*\}/,inside:{timer:{pattern:/(^~)[^{]+/,lookbehind:!0,alias:"variable"},"duration-group":{pattern:/\{[^{}]*\}/,inside:{punctuation:/[{}]/,unit:{pattern:new RegExp("(%\\s*)(?:h|hours|hrs|m|min|minutes)\\b"),lookbehind:!0,alias:"symbol"},operator:/%/,duration:{pattern:/\d+/,alias:"number"}}},"timer-keyword":{pattern:/^~/,alias:"keyword"}}}}}(); \ No newline at end of file diff --git a/tests/languages/cooklang/ingredient_feature.test b/tests/languages/cooklang/ingredient_feature.test index 4e9e70d9a2..a9f2bcb281 100644 --- a/tests/languages/cooklang/ingredient_feature.test +++ b/tests/languages/cooklang/ingredient_feature.test @@ -8,8 +8,8 @@ @milk{3|1%L} @milk{3*L} must not match amount-group @milk{3|L} -@milk{3%*L} must noch match amount-group -@milk{3%*%L} must noch match amount-group +@milk{3%*L} +@milk{3%*%L} ---------------------------------------------------- @@ -101,7 +101,13 @@ ["ingredient-group", [ ["ingredient-keyword", "@"], ["ingredient", "milk"], - "{3*L}" + ["amount-group", [ + ["punctuation", "{"], + ["amount", "3"], + ["servings-scaler", "*"], + "L", + ["punctuation", "}"] + ]] ]], " must not match amount-group\r\n", @@ -120,14 +126,24 @@ ["ingredient-group", [ ["ingredient-keyword", "@"], ["ingredient", "milk"], - "{3%*L}" + ["amount-group", [ + ["punctuation", "{"], + ["amount", "3"], + ["unit-separator", "%"], + ["unit", "*L"], + ["punctuation", "}"] + ]] ]], - " must noch match amount-group\r\n", ["ingredient-group", [ ["ingredient-keyword", "@"], ["ingredient", "milk"], - "{3%*%L}" - ]], - " must noch match amount-group" + ["amount-group", [ + ["punctuation", "{"], + ["amount", "3"], + ["unit-separator", "%"], + ["unit", "*%L"], + ["punctuation", "}"] + ]] + ]] ] diff --git a/tests/languages/cooklang/timer_feature.test b/tests/languages/cooklang/timer_feature.test index 7b619a7986..4244bd9937 100644 --- a/tests/languages/cooklang/timer_feature.test +++ b/tests/languages/cooklang/timer_feature.test @@ -17,6 +17,7 @@ ["punctuation", "}"] ]] ]], + ["timer-group", [ ["timer-keyword", "~"], ["timer", "eggs"], @@ -28,7 +29,19 @@ ["punctuation", "}"] ]] ]], - "\r\n~{abc%minutes} must not match\r\n", + + ["timer-group", [ + ["timer-keyword", "~"], + ["duration-group", [ + ["punctuation", "{"], + "abc", + ["operator", "%"], + ["unit", "minutes"], + ["punctuation", "}"] + ]] + ]], + " must not match\r\n", + ["timer-group", [ ["timer-keyword", "~"], ["timer", "eggs"], @@ -40,6 +53,7 @@ ["punctuation", "}"] ]] ]], + ["timer-group", [ ["timer-keyword", "~"], ["timer", "eggs"],