Add support for NaniScript (#2494)

This commit is contained in:
Artyom Sovetnikov 2020-08-07 21:14:34 +03:00 committed by GitHub
parent 187c8a607e
commit 388ad996c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 707 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -728,6 +728,11 @@
"title": "Nand To Tetris HDL",
"owner": "stephanmax"
},
"naniscript": {
"title": "Naninovel Script",
"owner": "Elringus",
"alias": "nani"
},
"nasm": {
"title": "NASM",
"owner": "rbmj"

View File

@ -0,0 +1,170 @@
(function (Prism) {
var expressionDef = /\{[^\r\n\[\]{}]*\}/;
var params = {
'quoted-string': {
pattern: /"(?:[^"\\]|\\.)*"/,
alias: 'operator'
},
'command-param-id': {
pattern: /(\s)\w+:/,
lookbehind: true,
alias: 'property'
},
'command-param-value': [
{
pattern: expressionDef,
alias: 'selector',
},
{
pattern: /([\t ])\S+/,
lookbehind: true,
greedy: true,
alias: 'operator',
},
{
pattern: /\S(?:.*\S)?/,
alias: 'operator',
}
]
};
Prism.languages.naniscript = {
// ; ...
'comment': {
pattern: /^([\t ]*);.*/m,
lookbehind: true,
},
// > ...
// Define is a control line starting with '>' followed by a word, a space and a text.
'define': {
pattern: /^>.+/m,
alias: 'tag',
inside: {
'value': {
pattern: /(^>\w+[\t ]+)(?!\s)[^{}\r\n]+/,
lookbehind: true,
alias: 'operator'
},
'key': {
pattern: /(^>)\w+/,
lookbehind: true,
}
}
},
// # ...
'label': {
pattern: /^([\t ]*)#[\t ]*\w+[\t ]*$/m,
lookbehind: true,
alias: 'regex'
},
'command': {
pattern: /^([\t ]*)@\w+(?=[\t ]|$).*/m,
lookbehind: true,
alias: 'function',
inside: {
'command-name': /^@\w+/,
'expression': {
pattern: expressionDef,
greedy: true,
alias: 'selector'
},
'command-params': {
pattern: /[\s\S]*\S[\s\S]*/,
inside: params
},
}
},
// Generic is any line that doesn't start with operators: ;>#@
'generic-text': {
pattern: /(^[ \t]*)[^#@>;\s].*/m,
lookbehind: true,
alias: 'punctuation',
inside: {
// \{ ... \} ... \[ ... \] ... \"
'escaped-char': /\\[{}\[\]"]/,
'expression': {
pattern: expressionDef,
greedy: true,
alias: 'selector'
},
'inline-command': {
pattern: /\[[\t ]*\w+[^\r\n\[\]]*\]/,
greedy: true,
alias: 'function',
inside: {
'command-params': {
pattern: /(^\[[\t ]*\w+\b)[\s\S]+(?=\]$)/,
lookbehind: true,
inside: params
},
'command-param-name': {
pattern: /^(\[[\t ]*)\w+/,
lookbehind: true,
alias: 'name',
},
'start-stop-char': /[\[\]]/,
}
},
}
}
};
Prism.languages.nani = Prism.languages['naniscript'];
/** @typedef {InstanceType<import("./prism-core")["Token"]>} Token */
/**
* This hook is used to validate generic-text tokens for balanced brackets.
* Mark token as bad-line when contains not balanced brackets: {},[]
*/
Prism.hooks.add('after-tokenize', function (env) {
/** @type {(Token | string)[]} */
var tokens = env.tokens;
tokens.forEach(function (token) {
if (typeof token !== "string" && token.type === 'generic-text') {
var content = getTextContent(token);
if (!isBracketsBalanced(content)) {
token.type = 'bad-line';
token.content = content;
}
}
});
});
/**
* @param {string} input
* @returns {boolean}
*/
function isBracketsBalanced(input) {
var brackets = "[]{}";
var stack = [];
for (var i = 0; i < input.length; i++) {
var bracket = input[i];
var bracketsIndex = brackets.indexOf(bracket);
if (bracketsIndex !== -1) {
if (bracketsIndex % 2 === 0) {
stack.push(bracketsIndex + 1);
} else if (stack.pop() !== bracketsIndex) {
return false;
}
}
}
return stack.length === 0;
};
/**
* @param {string | Token | (string | Token)[]} token
* @returns {string}
*/
function getTextContent(token) {
if (typeof token === 'string') {
return token;
} else if (Array.isArray(token)) {
return token.map(getTextContent).join('');
} else {
return getTextContent(token.content);
}
}
})(Prism);

1
components/prism-naniscript.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){var a=/\{[^\r\n\[\]{}]*\}/,n={"quoted-string":{pattern:/"(?:[^"\\]|\\.)*"/,alias:"operator"},"command-param-id":{pattern:/(\s)\w+:/,lookbehind:!0,alias:"property"},"command-param-value":[{pattern:a,alias:"selector"},{pattern:/([\t ])\S+/,lookbehind:!0,greedy:!0,alias:"operator"},{pattern:/\S(?:.*\S)?/,alias:"operator"}]};function t(e){return"string"==typeof e?e:Array.isArray(e)?e.map(t).join(""):t(e.content)}e.languages.naniscript={comment:{pattern:/^([\t ]*);.*/m,lookbehind:!0},define:{pattern:/^>.+/m,alias:"tag",inside:{value:{pattern:/(^>\w+[\t ]+)(?!\s)[^{}\r\n]+/,lookbehind:!0,alias:"operator"},key:{pattern:/(^>)\w+/,lookbehind:!0}}},label:{pattern:/^([\t ]*)#[\t ]*\w+[\t ]*$/m,lookbehind:!0,alias:"regex"},command:{pattern:/^([\t ]*)@\w+(?=[\t ]|$).*/m,lookbehind:!0,alias:"function",inside:{"command-name":/^@\w+/,expression:{pattern:a,greedy:!0,alias:"selector"},"command-params":{pattern:/[\s\S]*\S[\s\S]*/,inside:n}}},"generic-text":{pattern:/(^[ \t]*)[^#@>;\s].*/m,lookbehind:!0,alias:"punctuation",inside:{"escaped-char":/\\[{}\[\]"]/,expression:{pattern:a,greedy:!0,alias:"selector"},"inline-command":{pattern:/\[[\t ]*\w+[^\r\n\[\]]*\]/,greedy:!0,alias:"function",inside:{"command-params":{pattern:/(^\[[\t ]*\w+\b)[\s\S]+(?=\]$)/,lookbehind:!0,inside:n},"command-param-name":{pattern:/^(\[[\t ]*)\w+/,lookbehind:!0,alias:"name"},"start-stop-char":/[\[\]]/}}}}},e.languages.nani=e.languages.naniscript,e.hooks.add("after-tokenize",function(e){e.tokens.forEach(function(e){if("string"!=typeof e&&"generic-text"===e.type){var a=t(e);(function(e){for(var a=[],n=0;n<e.length;n++){var t=e[n],r="[]{}".indexOf(t);if(-1!==r)if(r%2==0)a.push(r+1);else if(a.pop()!==r)return!1}return 0===a.length})(a)||(e.type="bad-line",e.content=a)}})})}(Prism);

View File

@ -0,0 +1,72 @@
<h2>Comments</h2>
<pre><code>;Text of Comment
; Comment with tabs before
</code></pre>
<h2>Define</h2>
<pre><code>
&gt;DefineKey define 12 super usefull lines
</code></pre>
<h2>Label</h2>
<pre><code># Section
#Section without whitespace
# Section with whitespace
# SectionWithTab
</code></pre>
<h2>Command</h2>
<pre><code>
@
@ cmdWithWhiteSpaceBefore
@cmdWithTrailingSemicolon:
@paramlessCmd
@cmdWithNoParamsAndWhitespaceBefore
@cmdWithNoParamsAndTabBefore
@cmdWithNoParamsAndTabAndSpacesBefore
@cmdWithNoParamsWrappedInWhitespaces
@cmdWithNoParamWithTrailingSpace
@cmdWithNoParamWithMultipleTrailingSpaces
@cmdWithNoParamWithTrailingTab
@cmdWithNoParamWithTrailingTabAndSpaces
@cmdWithPositiveIntParam 1
@cmdWithNegativeIntParam -1
@cmdWithPositiveFloatParamAndNoFraction 1.
@cmdWithPositiveFloatParamAndFraction 1.10
@cmdWithPositiveHegativeFloatParamAndNoFraction -1.
@cmdWithPositiveHegativeFloatParamAndFraction -1.10
@cmdWithBoolParamAndPositive true
@cmdWithBoolParamAndNegative false
@cmdWithStringParam hello$co\:mma"d"
@cmdWithQuotedStringNamelessParameter "hello grizzly"
@cmdWithQuotedStringNamelessParameterWithEscapedQuotesInTheValue "hello \"grizzly\""
@set choice="moe"
@command hello.grizzly
@command one,two,three
@command 1,2,3
@command true,false,true
@command hi:grizzly
@command hi:1
@command hi:true
@command 1 in:forest danger:true
@char 1 pos:0.25,-0.75 look:right
</code></pre>
<h2>Generic Text</h2>
<pre><code>Generic text with inlined commands[i] example[command 1 danger:true] more text here [act danger:false true:false]
"Integer: a = {a} malesuada a + b = {a + b}", Random(a, b) = {Random(a, b)}, Random("foo", "bar", "foobar") = {Random("foo", "bar", "foobar")}
UnclosedExpression{ab{cndum dui dolor tincidu{nt [s[fa]sdf [
"Integer: a = {a} malesuada a + b = {a + b}", Random(a, b) = {Random(a, b)}, Random("foo", "bar", "foobar") = {Random("foo", "bar", "foobar")},}
</code></pre>
<h2>Expressions</h2>
<pre><code>{}
{ Abs(a, d) + 12 - 1 / -230.0 + "Lol ipsum" }
Expressions inside a generic text line: Loreim ipsu,{ Abs(a, d) + 12 - 1 / -230.0 + "Lol ipsum" } doler sit amen {¯\_(ツ)_/¯}.
@ExpressionInsteadOfNamelessParameterValue {x > 0}
@ExpressionBlendedWithNamelessParameterValue sdf{x > 0}df
@ExpressionsInsideNamedParameterValueWrappedInQuotes text:"{a} &lt; {b}"
@ExpressionsBlendedWithNamedParameterValue param:32r2f,df{x > 0},d.{Abs(0) + 12.24 > 0}ff
@ExpressionsInsteadOfNamelessParameterAndQuotedParameter {remark} if:remark=="Saying \\"Stop { "the" } car\\" was a mistake."
</code></pre>

View File

@ -187,6 +187,7 @@
"md": "markdown",
"moon": "moonscript",
"n4jsd": "n4js",
"nani": "naniscript",
"objc": "objectivec",
"objectpascal": "pascal",
"px": "pcaxis",

View File

@ -1 +1 @@
!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var l={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:["markup","csharp"],bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup-templating",ejs:["javascript","markup-templating"],etlua:["lua","markup-templating"],erb:["ruby","markup-templating"],fsharp:"clike","firestore-security-rules":"clike",flow:"javascript",ftl:"markup-templating",gml:"clike",glsl:"c",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",hlsl:"c",java:"clike",javadoc:["markup","java","javadoclike"],jolie:"clike",jsdoc:["javascript","javadoclike","typescript"],"js-extras":"javascript",json5:"json",jsonp:"json","js-templates":"javascript",kotlin:"clike",latte:["clike","markup-templating","php"],less:"css",lilypond:"scheme",markdown:"markup","markup-templating":"markup",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"c",parser:"markup",php:["clike","markup-templating"],phpdoc:["php","javadoclike"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:["markup","javascript"],purebasic:"clike",qml:"javascript",qore:"clike",racket:"scheme",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sass:"css",scss:"css",scala:"java","shell-session":"bash",smarty:"markup-templating",solidity:"clike",soy:"markup-templating",sparql:"turtle",sqf:"clike",swift:"clike","t4-cs":["t4-templating","csharp"],"t4-vb":["t4-templating","vbnet"],tap:"yaml",tt2:["clike","markup-templating"],textile:"markup",twig:"markup",typescript:"javascript",vala:"clike",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup","xml-doc":"markup",xquery:"markup"},n={html:"markup",xml:"markup",svg:"markup",mathml:"markup",ssml:"markup",atom:"markup",rss:"markup",js:"javascript",g4:"antlr4",adoc:"asciidoc",shell:"bash",shortcode:"bbcode",rbnf:"bnf",cs:"csharp",dotnet:"csharp",coffee:"coffeescript",conc:"concurnas",jinja2:"django","dns-zone":"dns-zone-file",dockerfile:"docker",eta:"ejs",xlsx:"excel-formula",xls:"excel-formula",gamemakerlanguage:"gml",hs:"haskell",gitignore:"ignore",hgignore:"ignore",npmignore:"ignore",webmanifest:"json",kt:"kotlin",kts:"kotlin",tex:"latex",context:"latex",ly:"lilypond",emacs:"lisp",elisp:"lisp","emacs-lisp":"lisp",md:"markdown",moon:"moonscript",n4jsd:"n4js",objc:"objectivec",objectpascal:"pascal",px:"pcaxis",pcode:"peoplecode",pq:"powerquery",mscript:"powerquery",pbfasm:"purebasic",py:"python",rkt:"racket",rpy:"renpy",robot:"robotframework",rb:"ruby",sol:"solidity",sln:"solution-file",rq:"sparql",t4:"t4-cs",trig:"turtle",ts:"typescript",uscript:"unrealscript",uc:"unrealscript",vb:"visual-basic",vba:"visual-basic",xeoracube:"xeora",yml:"yaml"},p={},e="components/",a=Prism.util.currentScript();if(a){var r=/\bplugins\/autoloader\/prism-autoloader\.(?:min\.)js(?:\?[^\r\n/]*)?$/i,t=/(^|\/)[\w-]+\.(?:min\.)js(?:\?[^\r\n/]*)?$/i,i=a.getAttribute("data-autoloader-path");if(null!=i)e=i.trim().replace(/\/?$/,"/");else{var s=a.src;r.test(s)?e=s.replace(r,"components/"):t.test(s)&&(e=s.replace(t,"$1components/"))}}var o=Prism.plugins.autoloader={languages_path:e,use_minified:!0,loadLanguages:m};Prism.hooks.add("complete",function(e){var a=e.element,r=e.language;if(a&&r&&"none"!==r){var t=function(e){var a=(e.getAttribute("data-dependencies")||"").trim();if(!a){var r=e.parentElement;r&&"pre"===r.tagName.toLowerCase()&&(a=(r.getAttribute("data-dependencies")||"").trim())}return a?a.split(/\s*,\s*/g):[]}(a);t.push(r),t.every(u)||m(t,function(){Prism.highlightElement(a)})}})}function u(e){if(0<=e.indexOf("!"))return!1;if((e=n[e]||e)in Prism.languages)return!0;var a=p[e];return a&&!a.error&&!1===a.loading}function m(e,a,r){"string"==typeof e&&(e=[e]);var t=e.length,i=0,s=!1;function c(){s||++i===t&&a&&a(e)}0!==t?e.forEach(function(e){!function(a,r,t){var i=0<=a.indexOf("!");function e(){var e=p[a];e||(e=p[a]={callbacks:[]}),e.callbacks.push({success:r,error:t}),!i&&u(a)?k(a,"success"):!i&&e.error?k(a,"error"):!i&&e.loading||(e.loading=!0,e.error=!1,function(e,a,r){var t=document.createElement("script");t.src=e,t.async=!0,t.onload=function(){document.body.removeChild(t),a&&a()},t.onerror=function(){document.body.removeChild(t),r&&r()},document.body.appendChild(t)}(function(e){return o.languages_path+"prism-"+e+(o.use_minified?".min":"")+".js"}(a),function(){e.loading=!1,k(a,"success")},function(){e.loading=!1,e.error=!0,k(a,"error")}))}a=a.replace("!",""),a=n[a]||a;var s=l[a];s&&s.length?m(s,e,t):e()}(e,c,function(){s||(s=!0,r&&r(e))})}):a&&setTimeout(a,0)}function k(e,a){if(p[e]){for(var r=p[e].callbacks,t=0,i=r.length;t<i;t++){var s=r[t][a];s&&setTimeout(s,0)}r.length=0}}}();
!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var n={javascript:"clike",actionscript:"javascript",arduino:"cpp",aspnet:["markup","csharp"],bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",django:"markup-templating",ejs:["javascript","markup-templating"],etlua:["lua","markup-templating"],erb:["ruby","markup-templating"],fsharp:"clike","firestore-security-rules":"clike",flow:"javascript",ftl:"markup-templating",gml:"clike",glsl:"c",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup-templating",haxe:"clike",hlsl:"c",java:"clike",javadoc:["markup","java","javadoclike"],jolie:"clike",jsdoc:["javascript","javadoclike","typescript"],"js-extras":"javascript",json5:"json",jsonp:"json","js-templates":"javascript",kotlin:"clike",latte:["clike","markup-templating","php"],less:"css",lilypond:"scheme",markdown:"markup","markup-templating":"markup",n4js:"javascript",nginx:"clike",objectivec:"c",opencl:"c",parser:"markup",php:["clike","markup-templating"],phpdoc:["php","javadoclike"],"php-extras":"php",plsql:"sql",processing:"clike",protobuf:"clike",pug:["markup","javascript"],purebasic:"clike",qml:"javascript",qore:"clike",racket:"scheme",jsx:["markup","javascript"],tsx:["jsx","typescript"],reason:"clike",ruby:"clike",sass:"css",scss:"css",scala:"java","shell-session":"bash",smarty:"markup-templating",solidity:"clike",soy:"markup-templating",sparql:"turtle",sqf:"clike",swift:"clike","t4-cs":["t4-templating","csharp"],"t4-vb":["t4-templating","vbnet"],tap:"yaml",tt2:["clike","markup-templating"],textile:"markup",twig:"markup",typescript:"javascript",vala:"clike",vbnet:"basic",velocity:"markup",wiki:"markup",xeora:"markup","xml-doc":"markup",xquery:"markup"},l={html:"markup",xml:"markup",svg:"markup",mathml:"markup",ssml:"markup",atom:"markup",rss:"markup",js:"javascript",g4:"antlr4",adoc:"asciidoc",shell:"bash",shortcode:"bbcode",rbnf:"bnf",cs:"csharp",dotnet:"csharp",coffee:"coffeescript",conc:"concurnas",jinja2:"django","dns-zone":"dns-zone-file",dockerfile:"docker",eta:"ejs",xlsx:"excel-formula",xls:"excel-formula",gamemakerlanguage:"gml",hs:"haskell",gitignore:"ignore",hgignore:"ignore",npmignore:"ignore",webmanifest:"json",kt:"kotlin",kts:"kotlin",tex:"latex",context:"latex",ly:"lilypond",emacs:"lisp",elisp:"lisp","emacs-lisp":"lisp",md:"markdown",moon:"moonscript",n4jsd:"n4js",nani:"naniscript",objc:"objectivec",objectpascal:"pascal",px:"pcaxis",pcode:"peoplecode",pq:"powerquery",mscript:"powerquery",pbfasm:"purebasic",py:"python",rkt:"racket",rpy:"renpy",robot:"robotframework",rb:"ruby",sol:"solidity",sln:"solution-file",rq:"sparql",t4:"t4-cs",trig:"turtle",ts:"typescript",uscript:"unrealscript",uc:"unrealscript",vb:"visual-basic",vba:"visual-basic",xeoracube:"xeora",yml:"yaml"},p={},e="components/",a=Prism.util.currentScript();if(a){var r=/\bplugins\/autoloader\/prism-autoloader\.(?:min\.)js(?:\?[^\r\n/]*)?$/i,t=/(^|\/)[\w-]+\.(?:min\.)js(?:\?[^\r\n/]*)?$/i,i=a.getAttribute("data-autoloader-path");if(null!=i)e=i.trim().replace(/\/?$/,"/");else{var s=a.src;r.test(s)?e=s.replace(r,"components/"):t.test(s)&&(e=s.replace(t,"$1components/"))}}var o=Prism.plugins.autoloader={languages_path:e,use_minified:!0,loadLanguages:m};Prism.hooks.add("complete",function(e){var a=e.element,r=e.language;if(a&&r&&"none"!==r){var t=function(e){var a=(e.getAttribute("data-dependencies")||"").trim();if(!a){var r=e.parentElement;r&&"pre"===r.tagName.toLowerCase()&&(a=(r.getAttribute("data-dependencies")||"").trim())}return a?a.split(/\s*,\s*/g):[]}(a);t.push(r),t.every(u)||m(t,function(){Prism.highlightElement(a)})}})}function u(e){if(0<=e.indexOf("!"))return!1;if((e=l[e]||e)in Prism.languages)return!0;var a=p[e];return a&&!a.error&&!1===a.loading}function m(e,a,r){"string"==typeof e&&(e=[e]);var t=e.length,i=0,s=!1;function c(){s||++i===t&&a&&a(e)}0!==t?e.forEach(function(e){!function(a,r,t){var i=0<=a.indexOf("!");function e(){var e=p[a];e||(e=p[a]={callbacks:[]}),e.callbacks.push({success:r,error:t}),!i&&u(a)?k(a,"success"):!i&&e.error?k(a,"error"):!i&&e.loading||(e.loading=!0,e.error=!1,function(e,a,r){var t=document.createElement("script");t.src=e,t.async=!0,t.onload=function(){document.body.removeChild(t),a&&a()},t.onerror=function(){document.body.removeChild(t),r&&r()},document.body.appendChild(t)}(function(e){return o.languages_path+"prism-"+e+(o.use_minified?".min":"")+".js"}(a),function(){e.loading=!1,k(a,"success")},function(){e.loading=!1,e.error=!0,k(a,"error")}))}a=a.replace("!",""),a=l[a]||a;var s=n[a];s&&s.length?m(s,e,t):e()}(e,c,function(){s||(s=!0,r&&r(e))})}):a&&setTimeout(a,0)}function k(e,a){if(p[e]){for(var r=p[e].callbacks,t=0,i=r.length;t<i;t++){var s=r[t][a];s&&setTimeout(s,0)}r.length=0}}}();

View File

@ -119,6 +119,8 @@
"n4js": "N4JS",
"n4jsd": "N4JS",
"nand2tetris-hdl": "Nand To Tetris HDL",
"naniscript": "Naninovel Script",
"nani": "Naninovel Script",
"nasm": "NASM",
"neon": "NEON",
"nginx": "nginx",

View File

@ -1 +1 @@
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var r={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",ssml:"SSML",rss:"RSS",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"ABNF",al:"AL",antlr4:"ANTLR4",g4:"ANTLR4",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",aspnet:"ASP.NET (C#)",asm6502:"6502 Assembly",autohotkey:"AutoHotkey",autoit:"AutoIt",basic:"BASIC",bbcode:"BBcode",bnf:"BNF",rbnf:"RBNF",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",cmake:"CMake",coffee:"CoffeeScript",conc:"Concurnas",csp:"Content-Security-Policy","css-extras":"CSS Extras",dax:"DAX",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"EBNF",editorconfig:"EditorConfig",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB","excel-formula":"Excel Formula",xlsx:"Excel Formula",xls:"Excel Formula",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",hlsl:"HLSL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",ignore:".ignore",gitignore:".gitignore",hgignore:".hgignore",npmignore:".npmignore",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras",json:"JSON",webmanifest:"Web App Manifest",json5:"JSON5",jsonp:"JSONP",jsstacktrace:"JS stack trace","js-templates":"JS Templates",kts:"Kotlin Script",kt:"Kotlin",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",llvm:"LLVM IR",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",moon:"MoonScript",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",neon:"NEON",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",objc:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",peoplecode:"PeopleCode",pcode:"PeopleCode",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powerquery:"PowerQuery",pq:"PowerQuery",mscript:"PowerQuery",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",purebasic:"PureBasic",pbfasm:"PureBasic",py:"Python",q:"Q (kdb+ database)",qml:"QML",rkt:"Racket",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rpy:"Ren'py",rest:"reST (reStructuredText)",robotframework:"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)",sol:"Solidity (Ethereum)","solution-file":"Solution file",sln:"Solution file",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",sql:"SQL",iecst:"Structured Text (IEC 61131-3)","t4-templating":"T4 templating","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)",tap:"TAP",tt2:"Template Toolkit 2",toml:"TOML",trig:"TriG",ts:"TypeScript",uscript:"UnrealScript",uc:"UnrealScript",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vba:"VBA",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube","xml-doc":"XML doc (.net)",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML",yang:"YANG"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var t,o=a.getAttribute("data-language")||r[e.language]||((t=e.language)?(t.substring(0,1).toUpperCase()+t.substring(1)).replace(/s(?=cript)/,"S"):t);if(o){var s=document.createElement("span");return s.textContent=o,s}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var r={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",ssml:"SSML",rss:"RSS",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"ABNF",al:"AL",antlr4:"ANTLR4",g4:"ANTLR4",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",aspnet:"ASP.NET (C#)",asm6502:"6502 Assembly",autohotkey:"AutoHotkey",autoit:"AutoIt",basic:"BASIC",bbcode:"BBcode",bnf:"BNF",rbnf:"RBNF",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",cmake:"CMake",coffee:"CoffeeScript",conc:"Concurnas",csp:"Content-Security-Policy","css-extras":"CSS Extras",dax:"DAX",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"EBNF",editorconfig:"EditorConfig",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB","excel-formula":"Excel Formula",xlsx:"Excel Formula",xls:"Excel Formula",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",hlsl:"HLSL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",ignore:".ignore",gitignore:".gitignore",hgignore:".hgignore",npmignore:".npmignore",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras",json:"JSON",webmanifest:"Web App Manifest",json5:"JSON5",jsonp:"JSONP",jsstacktrace:"JS stack trace","js-templates":"JS Templates",kts:"Kotlin Script",kt:"Kotlin",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",llvm:"LLVM IR",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",moon:"MoonScript",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",naniscript:"Naninovel Script",nani:"Naninovel Script",nasm:"NASM",neon:"NEON",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",objc:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",peoplecode:"PeopleCode",pcode:"PeopleCode",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powerquery:"PowerQuery",pq:"PowerQuery",mscript:"PowerQuery",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",purebasic:"PureBasic",pbfasm:"PureBasic",py:"Python",q:"Q (kdb+ database)",qml:"QML",rkt:"Racket",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rpy:"Ren'py",rest:"reST (reStructuredText)",robotframework:"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)",sol:"Solidity (Ethereum)","solution-file":"Solution file",sln:"Solution file",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",sql:"SQL",iecst:"Structured Text (IEC 61131-3)","t4-templating":"T4 templating","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)",tap:"TAP",tt2:"Template Toolkit 2",toml:"TOML",trig:"TriG",ts:"TypeScript",uscript:"UnrealScript",uc:"UnrealScript",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vba:"VBA",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube","xml-doc":"XML doc (.net)",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML",yang:"YANG"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var t,o=a.getAttribute("data-language")||r[e.language]||((t=e.language)?(t.substring(0,1).toUpperCase()+t.substring(1)).replace(/s(?=cript)/,"S"):t);if(o){var s=document.createElement("span");return s.textContent=o,s}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();

View File

@ -0,0 +1,207 @@
@
@ cmdWithWhiteSpaceBefore
@cmdWithTrailingSemicolon:
@paramlessCmd
@cmdWithNoParamsAndWhitespaceBefore
@cmdWithNoParamsAndTabBefore
@cmdWithNoParamsAndTabAndSpacesBefore
@cmdWithNoParamsWrappedInWhitespaces
@cmdWithNoParamWithTrailingSpace
@cmdWithNoParamWithMultipleTrailingSpaces
@cmdWithNoParamWithTrailingTab
@cmdWithNoParamWithTrailingTabAndSpaces
@cmdWithPositiveIntParam 1
@cmdWithNegativeIntParam -1
@cmdWithPositiveFloatParamAndNoFraction 1.
@cmdWithPositiveFloatParamAndFraction 1.10
@cmdWithPositiveHegativeFloatParamAndNoFraction -1.
@cmdWithPositiveHegativeFloatParamAndFraction -1.10
@cmdWithBoolParamAndPositive true
@cmdWithBoolParamAndNegative false
@cmdWithStringParam hello$co\:mma"d"
@cmdWithQuotedStringNamelessParameter "hello grizzly"
@cmdWithQuotedStringNamelessParameterWithEscapedQuotesInTheValue "hello \"grizzly\""
@set choice="moe"
@command hello.grizzly
@command one,two,three
@command 1,2,3
@command true,false,true
@command hi:grizzly
@command hi:1
@command hi:true
@command 1 in:forest danger:true
@char 1 pos:0.25,-0.75 look:right
----------------------------------------------------
[
"@\r\n@ cmdWithWhiteSpaceBefore\r\n@cmdWithTrailingSemicolon:\r\n",
["command", [
["command-name", "@paramlessCmd"]
]],
["command", [
["command-name", "@cmdWithNoParamsAndWhitespaceBefore"]
]],
["command", [
["command-name", "@cmdWithNoParamsAndTabBefore"]
]],
["command", [
["command-name", "@cmdWithNoParamsAndTabAndSpacesBefore"]
]],
["command", [
["command-name", "@cmdWithNoParamsWrappedInWhitespaces"]
]],
["command", [
["command-name", "@cmdWithNoParamWithTrailingSpace"]
]],
["command", [
["command-name", "@cmdWithNoParamWithMultipleTrailingSpaces"]
]],
["command", [
["command-name", "@cmdWithNoParamWithTrailingTab"]
]],
["command", [
["command-name", "@cmdWithNoParamWithTrailingTabAndSpaces"]
]],
["command", [
["command-name", "@cmdWithPositiveIntParam"],
["command-params", [
["command-param-value", "1"]
]]
]],
["command", [
["command-name", "@cmdWithNegativeIntParam"],
["command-params", [
["command-param-value", "-1"]
]]
]],
["command", [
["command-name", "@cmdWithPositiveFloatParamAndNoFraction"],
["command-params", [
["command-param-value", "1."]
]]
]],
["command", [
["command-name", "@cmdWithPositiveFloatParamAndFraction"],
["command-params", [
["command-param-value", "1.10"]
]]
]],
["command", [
["command-name", "@cmdWithPositiveHegativeFloatParamAndNoFraction"],
["command-params", [
["command-param-value", "-1."]
]]
]],
["command", [
["command-name", "@cmdWithPositiveHegativeFloatParamAndFraction"],
["command-params", [
["command-param-value", "-1.10"]
]]
]],
["command", [
["command-name", "@cmdWithBoolParamAndPositive"],
["command-params", [
["command-param-value", "true"]
]]
]],
["command", [
["command-name", "@cmdWithBoolParamAndNegative"],
["command-params", [
["command-param-value", "false"]
]]
]],
["command", [
["command-name", "@cmdWithStringParam"],
["command-params", [
["command-param-value", "hello$co\\:mma\"d\""]
]]
]],
["command", [
["command-name", "@cmdWithQuotedStringNamelessParameter"],
["command-params", [
["quoted-string", "\"hello grizzly\""]
]]
]],
["command", [
["command-name", "@cmdWithQuotedStringNamelessParameterWithEscapedQuotesInTheValue"],
["command-params", [
["quoted-string", "\"hello \\\"grizzly\\\"\""]
]]
]],
["command", [
["command-name", "@set"],
["command-params", [
["command-param-value", "choice=\"moe\""]
]]
]],
["command", [
["command-name", "@command"],
["command-params", [
["command-param-value", "hello.grizzly"]
]]
]],
["command", [
["command-name", "@command"],
["command-params", [
["command-param-value", "one,two,three"]
]]
]],
["command", [
["command-name", "@command"],
["command-params", [
["command-param-value", "1,2,3"]
]]
]],
["command", [
["command-name", "@command"],
["command-params", [
["command-param-value", "true,false,true"]
]]
]],
["command", [
["command-name", "@command"],
["command-params", [
["command-param-id", "hi:"],
["command-param-value", "grizzly"]
]]
]],
["command", [
["command-name", "@command"],
["command-params", [
["command-param-id", "hi:"],
["command-param-value", "1"]
]]
]],
["command", [
["command-name", "@command"],
["command-params", [
["command-param-id", "hi:"],
["command-param-value", "true"]
]]
]],
["command", [
["command-name", "@command"],
["command-params", [
["command-param-value", "1"],
["command-param-id", "in:"],
["command-param-value", "forest"],
["command-param-id", "danger:"],
["command-param-value", "true"]
]]
]],
["command", [
["command-name", "@char"],
["command-params", [
["command-param-value", "1"],
["command-param-id", "pos:"],
["command-param-value", "0.25,-0.75"],
["command-param-id", "look:"],
["command-param-value", "right"]
]]
]]
]
----------------------------------------------------
Command tests.

View File

@ -0,0 +1,17 @@
;
; comment
\:; invalid comment
----------------------------------------------------
[
["comment", ";"],
["comment", "; comment"],
["generic-text", [
"\\:; invalid comment"
]]
]
----------------------------------------------------
Comment tests.

View File

@ -0,0 +1,17 @@
>
>DefineKey define _ + 3h f[29 j] value *
----------------------------------------------------
[
">\r\n",
["define", [
">",
["key", "DefineKey"],
["value", "define _ + 3h f[29 j] value *"]
]]
]
----------------------------------------------------
Define tests.

View File

@ -0,0 +1,91 @@
{}
{ Abs(a, d) + 12 - 1 / -230.0 + "Lol ipsum" }
Expressions inside a generic text line: Loreim ipsu,{ Abs(a, d) + 12 - 1 / -230.0 + "Lol ipsum" } doler sit amen {¯\_(ツ)_/¯}.
@ExpressionInsteadOfNamelessParameterValue {x > 0}
@ExpressionBlendedWithNamelessParameterValue sdf{x > 0}df
@ExpressionsInsideNamedParameterValueWrappedInQuotes text:"{a} < {b}"
@ExpressionsBlendedWithNamedParameterValue param:32r2f,df{x > 0},d.{Abs(0) + 12.24 > 0}ff
@ExpressionsInsteadOfNamelessParameterAndQuotedParameter {remark} if:remark=="Saying \\"Stop { "the" } car\\" was a mistake."
----------------------------------------------------
[
["generic-text", [
["expression", "{}"]
]],
["generic-text", [
["expression", "{ Abs(a, d) + 12 - 1 / -230.0 + \"Lol ipsum\" }"]
]],
["generic-text", [
"Expressions inside a generic text line: Loreim ipsu,",
["expression", "{ Abs(a, d) + 12 - 1 / -230.0 + \"Lol ipsum\" }"],
" doler sit amen ",
["expression", "{¯\\_(ツ)_/¯}"],
"."
]],
["command", [
["command-name", "@ExpressionInsteadOfNamelessParameterValue"],
["expression", "{x > 0}"]
]],
["command", [
["command-name", "@ExpressionBlendedWithNamelessParameterValue"],
["command-params", [
["command-param-value", "sdf"]
]],
["expression", "{x > 0}"],
["command-params", [
["command-param-value", "df"]
]]
]],
["command", [
["command-name", "@ExpressionsInsideNamedParameterValueWrappedInQuotes"],
["command-params", [
["command-param-id", "text:"],
["command-param-value", "\""]
]],
["expression", "{a}"],
["command-params", [
["command-param-value", "<"]
]],
["expression", "{b}"],
["command-params", [
["command-param-value", "\""]
]]
]],
["command", [
["command-name", "@ExpressionsBlendedWithNamedParameterValue"],
["command-params", [
["command-param-id", "param:"],
["command-param-value", "32r2f,df"]
]],
["expression", "{x > 0}"],
["command-params", [
["command-param-value", ",d."]
]],
["expression", "{Abs(0) + 12.24 > 0}"],
["command-params", [
["command-param-value", "ff"]
]]
]],
["command", [
["command-name", "@ExpressionsInsteadOfNamelessParameterAndQuotedParameter"],
["expression", "{remark}"],
["command-params", [
["command-param-id", "if:"],
["command-param-value", "remark=="],
["quoted-string", "\"Saying \\\\\""],
["command-param-value", "Stop"]
]],
["expression", "{ \"the\" }"],
["command-params", [
["command-param-value", "car\\\\\""],
["command-param-value", "was"],
["command-param-value", "a"],
["command-param-value", "mistake.\""]
]]
]]
]
----------------------------------------------------
Expressions tests.

View File

@ -0,0 +1,24 @@
#
# Section1
#Section2
# Section4
# SectionWithMultipleTabsBefore
## Section3
# Section with multiple words
# Section with
# Section with tab
----------------------------------------------------
[
"#\r\n",
["label", "# Section1"],
["label", "#Section2"],
["label", "# Section4"],
["label", "#\t\t\tSectionWithMultipleTabsBefore"],
"\r\n## Section3\r\n# Section with multiple words\r\n\t# Section with\r\n\t# Section with tab"
]
----------------------------------------------------
Label tests.

View File

@ -0,0 +1,97 @@
Generic text with inlined commands[i] example[command 1 danger:true] more text here [act danger:false true:false]
@action1ForTwoLinesWithCommands
@action2ForTwoLinesWithCommands
@commandAndGenericTextOnNewLine
Massa ut elementum.
@commandWithParameterAndGenericTextOnNewLine WideParam
Integer
Escaped braces inside generic text\{abu\}nt @ >ip#s;um< @ \[sdff j9dj\]
UnclosedExpression{ab{cndum dui dolor tincidu{nt [s[fa]sdf [
"Integer: a = {a} malesuada a + b = {a + b}", Random(a, b) = {Random(a, b)}, Random("foo", "bar", "foobar") = {Random("foo", "bar", "foobar")},}
#
>
@
----------------------------------------------------
[
["generic-text", [
"Generic text with inlined commands",
["inline-command", [
["start-stop-char", "["],
["command-param-name", "i"],
["start-stop-char", "]"]
]],
" example",
["inline-command", [
["start-stop-char", "["],
["command-param-name", "command"],
["command-params", [
["command-param-value", "1"],
["command-param-id", "danger:"],
["command-param-value", "true"]
]],
["start-stop-char", "]"]
]],
" more text here ",
["inline-command", [
["start-stop-char", "["],
["command-param-name", "act"],
["command-params", [
["command-param-id", "danger:"],
["command-param-value", "false"],
["command-param-id", "true:"],
["command-param-value", "false"]
]],
["start-stop-char", "]"]
]]
]],
["command", [
["command-name", "@action1ForTwoLinesWithCommands"]
]],
["command", [
["command-name", "@action2ForTwoLinesWithCommands"]
]],
["command", [
["command-name", "@commandAndGenericTextOnNewLine"]
]],
["generic-text", [
"Massa ut elementum."
]],
["command", [
["command-name", "@commandWithParameterAndGenericTextOnNewLine"],
["command-params", [
["command-param-value", "WideParam"]
]]
]],
["generic-text", [
"Integer"
]],
["generic-text", [
"Escaped braces inside generic text",
["escaped-char", "\\{"],
"abu",
["escaped-char", "\\}"],
"nt @ >ip#s;um< @ ",
["escaped-char", "\\["],
"sdff j9dj",
["escaped-char", "\\]"]
]],
["bad-line", "UnclosedExpression{ab{cndum dui dolor tincidu{nt [s[fa]sdf ["],
["bad-line", "\"Integer: a = {a} malesuada a + b = {a + b}\", Random(a, b) = {Random(a, b)}, Random(\"foo\", \"bar\", \"foobar\") = {Random(\"foo\", \"bar\", \"foobar\")},}"],
"\n#\n>\n@"
]
----------------------------------------------------
Mixed tests of Generic Text, Commands, Inline Commands.