diff --git a/components.js b/components.js index 44001f23aa..26ba89ff19 100644 --- a/components.js +++ b/components.js @@ -84,6 +84,10 @@ var components = { "require": "markup", "owner": "nauzilus" }, + "autoit": { + "title": "AutoIt", + "owner": "Golmote" + }, "autohotkey": { "title": "AutoHotkey", "owner": "aviaryan" diff --git a/components/prism-autoit.js b/components/prism-autoit.js new file mode 100644 index 0000000000..0322d95643 --- /dev/null +++ b/components/prism-autoit.js @@ -0,0 +1,33 @@ +Prism.languages.autoit = { + "comment": [ + /;.*/, + { + // The multi-line comments delimiters can actually be commented out with ";" + pattern: /(^\s*)#(?:comments-start|cs)[\s\S]*?^\s*#(?:comments-end|ce)/m, + lookbehind: true + } + ], + "url": { + pattern: /(^\s*#include\s+)(?:<[^\r\n>]+>|"[^\r\n"]+")/m, + lookbehind: true + }, + "string": { + pattern: /(["'])(?:\1\1|(?!\1)[^\r\n])*\1/, + inside: { + "variable": /([%$@])\w+\1/ + } + }, + "directive": { + pattern: /(^\s*)#\w+/m, + lookbehind: true, + alias: 'keyword' + }, + "function": /\b\w+(?=\()/, + // Variables and macros + "variable": /[$@]\w+/, + "keyword": /\b(?:Case|Const|Continue(?:Case|Loop)|Default|Dim|Do|Else(?:If)?|End(?:Func|If|Select|Switch|With)|Enum|Exit(?:Loop)?|For|Func|Global|If|In|Local|Next|Null|ReDim|Select|Static|Step|Switch|Then|To|Until|Volatile|WEnd|While|With)\b/i, + "number": /\b(?:0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i, + "boolean": /\b(?:True|False)\b/i, + "operator": /<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Or|Not)\b/i, + "punctuation": /[\[\]().,:]/ +}; \ No newline at end of file diff --git a/components/prism-autoit.min.js b/components/prism-autoit.min.js new file mode 100644 index 0000000000..49b79864a9 --- /dev/null +++ b/components/prism-autoit.min.js @@ -0,0 +1 @@ +Prism.languages.autoit={comment:[/;.*/,{pattern:/(^\s*)#(?:comments-start|cs)[\s\S]*?^\s*#(?:comments-end|ce)/m,lookbehind:!0}],url:{pattern:/(^\s*#include\s+)(?:<[^\r\n>]+>|"[^\r\n"]+")/m,lookbehind:!0},string:{pattern:/(["'])(?:\1\1|(?!\1)[^\r\n])*\1/,inside:{variable:/([%$@])\w+\1/}},directive:{pattern:/(^\s*)#\w+/m,lookbehind:!0,alias:"keyword"},"function":/\b\w+(?=\()/,variable:/[$@]\w+/,keyword:/\b(?:Case|Const|Continue(?:Case|Loop)|Default|Dim|Do|Else(?:If)?|End(?:Func|If|Select|Switch|With)|Enum|Exit(?:Loop)?|For|Func|Global|If|In|Local|Next|Null|ReDim|Select|Static|Step|Switch|Then|To|Until|Volatile|WEnd|While|With)\b/i,number:/\b(?:0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i,"boolean":/\b(?:True|False)\b/i,operator:/<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Or|Not)\b/i,punctuation:/[\[\]().,:]/}; \ No newline at end of file diff --git a/examples/prism-autoit.html b/examples/prism-autoit.html new file mode 100644 index 0000000000..b8df3cb1ee --- /dev/null +++ b/examples/prism-autoit.html @@ -0,0 +1,58 @@ +

AutoIt

+

To use this language, use the class "language-autoit".

+ +

Comments

+
; Single-line comment
+#comments-start
+	Multi-line
+	comment
+#comments-end
+#cs
+	Multi-line
+	comment
+#ce
+;#comments-start
+	foo()
+;#comments-end
+ +

Strings

+
"foo'bar'baz"
+"foo""bar""baz"
+'foo"bar"baz'
+'foo''bar''baz'
+ +

Numbers

+
2
+4.566
+1.5e3
+0x4fff
+ +

Booleans

+
True
+False
+ +

Keywords and variables

+
; Display all the numbers for 1 to 10 but skip displaying  7.
+For $i = 1 To 10
+    If $i = 7 Then
+        ContinueLoop ; Skip displaying the message box when $i is equal to 7.
+    EndIf
+    MsgBox($MB_SYSTEMMODAL, "", "The value of $i is: " & $i)
+Next
+ +

Known failures

+

There are certain edge cases where Prism will fail. + There are always such cases in every regex-based syntax highlighter. + However, Prism dares to be open and honest about them. + If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug. +

+ +

Comment-like substrings

+
"This string ; is broken"
+ +

Nested block comments

+
#cs
+	#cs
+		foo()
+	#ce
+#ce
\ No newline at end of file diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js index 852f9aa2bf..09f62981ed 100644 --- a/plugins/show-language/prism-show-language.js +++ b/plugins/show-language/prism-show-language.js @@ -5,7 +5,7 @@ if (typeof self === 'undefined' || !self.Prism || !self.document) { } // The languages map is built automatically with gulp -var Languages = /*languages_placeholder[*/{"css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","http":"HTTP","inform7":"Inform 7","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","wiki":"Wiki markup","yaml":"YAML"}/*]*/; +var Languages = /*languages_placeholder[*/{"css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","http":"HTTP","inform7":"Inform 7","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","wiki":"Wiki markup","yaml":"YAML"}/*]*/; Prism.hooks.add('before-highlight', function(env) { var pre = env.element.parentNode; if (!pre || !/pre/i.test(pre.nodeName)) { diff --git a/plugins/show-language/prism-show-language.min.js b/plugins/show-language/prism-show-language.min.js index 9cf75c11dc..90ef27ee51 100644 --- a/plugins/show-language/prism-show-language.min.js +++ b/plugins/show-language/prism-show-language.min.js @@ -1 +1 @@ -!function(){if("undefined"!=typeof self&&self.Prism&&self.document){var e={css:"CSS",clike:"C-like",javascript:"JavaScript",abap:"ABAP",actionscript:"ActionScript",apacheconf:"Apache Configuration",apl:"APL",applescript:"AppleScript",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",basic:"BASIC",csharp:"C#",cpp:"C++",coffeescript:"CoffeeScript","css-extras":"CSS Extras",fsharp:"F#",glsl:"GLSL",http:"HTTP",inform7:"Inform 7",latex:"LaTeX",lolcode:"LOLCODE",matlab:"MATLAB",mel:"MEL",nasm:"NASM",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",php:"PHP","php-extras":"PHP Extras",powershell:"PowerShell",jsx:"React JSX",rest:"reST (reStructuredText)",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)",sql:"SQL",typescript:"TypeScript",vhdl:"VHDL",wiki:"Wiki markup",yaml:"YAML"};Prism.hooks.add("before-highlight",function(a){var s=a.element.parentNode;if(s&&/pre/i.test(s.nodeName)){var t=e[a.language]||a.language.substring(0,1).toUpperCase()+a.language.substring(1);s.setAttribute("data-language",t)}})}}(); \ No newline at end of file +!function(){if("undefined"!=typeof self&&self.Prism&&self.document){var e={css:"CSS",clike:"C-like",javascript:"JavaScript",abap:"ABAP",actionscript:"ActionScript",apacheconf:"Apache Configuration",apl:"APL",applescript:"AppleScript",aspnet:"ASP.NET (C#)",autoit:"AutoIt",autohotkey:"AutoHotkey",basic:"BASIC",csharp:"C#",cpp:"C++",coffeescript:"CoffeeScript","css-extras":"CSS Extras",fsharp:"F#",glsl:"GLSL",http:"HTTP",inform7:"Inform 7",latex:"LaTeX",lolcode:"LOLCODE",matlab:"MATLAB",mel:"MEL",nasm:"NASM",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",php:"PHP","php-extras":"PHP Extras",powershell:"PowerShell",jsx:"React JSX",rest:"reST (reStructuredText)",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)",sql:"SQL",typescript:"TypeScript",vhdl:"VHDL",wiki:"Wiki markup",yaml:"YAML"};Prism.hooks.add("before-highlight",function(a){var t=a.element.parentNode;if(t&&/pre/i.test(t.nodeName)){var s=e[a.language]||a.language.substring(0,1).toUpperCase()+a.language.substring(1);t.setAttribute("data-language",s)}})}}(); \ No newline at end of file diff --git a/tests/languages/autoit/boolean_feature.test b/tests/languages/autoit/boolean_feature.test new file mode 100644 index 0000000000..5750be06cf --- /dev/null +++ b/tests/languages/autoit/boolean_feature.test @@ -0,0 +1,13 @@ +True +False + +---------------------------------------------------- + +[ + ["boolean", "True"], + ["boolean", "False"] +] + +---------------------------------------------------- + +Checks for booleans. \ No newline at end of file diff --git a/tests/languages/autoit/comment_feature.test b/tests/languages/autoit/comment_feature.test new file mode 100644 index 0000000000..d88708f344 --- /dev/null +++ b/tests/languages/autoit/comment_feature.test @@ -0,0 +1,33 @@ +; +; foo +#comments-start + foobar() +#comments-end +#cs + foobar() +#ce +;#comments-start + foobar() +;#comments-end +;#cs + foobar() +;#ce + +---------------------------------------------------- + +[ + ["comment", ";"], + ["comment", "; foo"], + ["comment", "#comments-start\r\n\tfoobar()\r\n#comments-end"], + ["comment", "#cs\r\n\tfoobar()\r\n#ce"], + ["comment", ";#comments-start"], + ["function", "foobar"], ["punctuation", "("], ["punctuation", ")"], + ["comment", ";#comments-end"], + ["comment", ";#cs"], + ["function", "foobar"], ["punctuation", "("], ["punctuation", ")"], + ["comment", ";#ce"] +] + +---------------------------------------------------- + +Checks for comments. \ No newline at end of file diff --git a/tests/languages/autoit/directive_feature.test b/tests/languages/autoit/directive_feature.test new file mode 100644 index 0000000000..9219f700a0 --- /dev/null +++ b/tests/languages/autoit/directive_feature.test @@ -0,0 +1,13 @@ +#NoTrayIcon +#OnAutoItStartRegister "Example" + +---------------------------------------------------- + +[ + ["directive", "#NoTrayIcon"], + ["directive", "#OnAutoItStartRegister"], ["string", ["\"Example\""]] +] + +---------------------------------------------------- + +Checks for directives. \ No newline at end of file diff --git a/tests/languages/autoit/function_feature.test b/tests/languages/autoit/function_feature.test new file mode 100644 index 0000000000..13c82ddad2 --- /dev/null +++ b/tests/languages/autoit/function_feature.test @@ -0,0 +1,15 @@ +foo() +foo_bar() +foo_bar_42() + +---------------------------------------------------- + +[ + ["function", "foo"], ["punctuation", "("], ["punctuation", ")"], + ["function", "foo_bar"], ["punctuation", "("], ["punctuation", ")"], + ["function", "foo_bar_42"], ["punctuation", "("], ["punctuation", ")"] +] + +---------------------------------------------------- + +Checks for functions. \ No newline at end of file diff --git a/tests/languages/autoit/keyword_feature.test b/tests/languages/autoit/keyword_feature.test new file mode 100644 index 0000000000..2db276cb77 --- /dev/null +++ b/tests/languages/autoit/keyword_feature.test @@ -0,0 +1,83 @@ +Case +Const +ContinueCase +ContinueLoop +Default +Dim +Do +Else +ElseIf +EndFunc +EndIf +EndSelect +EndSwitch +EndWith +Enum +Exit +ExitLoop +For +Func +Global +If +In +Local +Next +Null +ReDim +Select +Static +Step +Switch +Then +To +Until +Volatile +WEnd +While +With + +---------------------------------------------------- + +[ + ["keyword", "Case"], + ["keyword", "Const"], + ["keyword", "ContinueCase"], + ["keyword", "ContinueLoop"], + ["keyword", "Default"], + ["keyword", "Dim"], + ["keyword", "Do"], + ["keyword", "Else"], + ["keyword", "ElseIf"], + ["keyword", "EndFunc"], + ["keyword", "EndIf"], + ["keyword", "EndSelect"], + ["keyword", "EndSwitch"], + ["keyword", "EndWith"], + ["keyword", "Enum"], + ["keyword", "Exit"], + ["keyword", "ExitLoop"], + ["keyword", "For"], + ["keyword", "Func"], + ["keyword", "Global"], + ["keyword", "If"], + ["keyword", "In"], + ["keyword", "Local"], + ["keyword", "Next"], + ["keyword", "Null"], + ["keyword", "ReDim"], + ["keyword", "Select"], + ["keyword", "Static"], + ["keyword", "Step"], + ["keyword", "Switch"], + ["keyword", "Then"], + ["keyword", "To"], + ["keyword", "Until"], + ["keyword", "Volatile"], + ["keyword", "WEnd"], + ["keyword", "While"], + ["keyword", "With"] +] + +---------------------------------------------------- + +Checks for keywords. \ No newline at end of file diff --git a/tests/languages/autoit/number_feature.test b/tests/languages/autoit/number_feature.test new file mode 100644 index 0000000000..5c6ac5bcaa --- /dev/null +++ b/tests/languages/autoit/number_feature.test @@ -0,0 +1,21 @@ +42 +3.14159 +4e8 +3.5E-9 +0.7e+12 +0xBadFace + +---------------------------------------------------- + +[ + ["number", "42"], + ["number", "3.14159"], + ["number", "4e8"], + ["number", "3.5E-9"], + ["number", "0.7e+12"], + ["number", "0xBadFace"] +] + +---------------------------------------------------- + +Checks for numbers. \ No newline at end of file diff --git a/tests/languages/autoit/operator_feature.test b/tests/languages/autoit/operator_feature.test new file mode 100644 index 0000000000..65f4ce4d1f --- /dev/null +++ b/tests/languages/autoit/operator_feature.test @@ -0,0 +1,23 @@ +< <= <> +> >= ++ += - -= +* *= / /= +& &= +? ^ +And Or Not + +---------------------------------------------------- + +[ + ["operator", "<"], ["operator", "<="], ["operator", "<>"], + ["operator", ">"], ["operator", ">="], + ["operator", "+"], ["operator", "+="], ["operator", "-"], ["operator", "-="], + ["operator", "*"], ["operator", "*="], ["operator", "/"], ["operator", "/="], + ["operator", "&"], ["operator", "&="], + ["operator", "?"], ["operator", "^"], + ["operator", "And"], ["operator", "Or"], ["operator", "Not"] +] + +---------------------------------------------------- + +Checks for operators. \ No newline at end of file diff --git a/tests/languages/autoit/string_feature.test b/tests/languages/autoit/string_feature.test new file mode 100644 index 0000000000..5ae4bb70fd --- /dev/null +++ b/tests/languages/autoit/string_feature.test @@ -0,0 +1,37 @@ +"" +"foo""bar" +"foo %foo% bar $bar$ baz @baz@" +'' +'foo''bar' +'foo %foo% bar $bar$ baz @baz@' + +---------------------------------------------------- + +[ + ["string", ["\"\""]], + ["string", ["\"foo\"\"bar\""]], + ["string", [ + "\"foo ", + ["variable", "%foo%"], + " bar ", + ["variable", "$bar$"], + " baz ", + ["variable", "@baz@"], + "\"" + ]], + ["string", ["''"]], + ["string", ["'foo''bar'"]], + ["string", [ + "'foo ", + ["variable", "%foo%"], + " bar ", + ["variable", "$bar$"], + " baz ", + ["variable", "@baz@"], + "'" + ]] +] + +---------------------------------------------------- + +Checks for strings and interpolation. \ No newline at end of file diff --git a/tests/languages/autoit/url_feature.test b/tests/languages/autoit/url_feature.test new file mode 100644 index 0000000000..1f6d3cd496 --- /dev/null +++ b/tests/languages/autoit/url_feature.test @@ -0,0 +1,15 @@ +#include +#include "foo.au3" + +---------------------------------------------------- + +[ + ["directive", "#include"], + ["url", ""], + ["directive", "#include"], + ["url", "\"foo.au3\""] +] + +---------------------------------------------------- + +Checks for files in includes. \ No newline at end of file diff --git a/tests/languages/autoit/variable_feature.test b/tests/languages/autoit/variable_feature.test new file mode 100644 index 0000000000..e36ffe327a --- /dev/null +++ b/tests/languages/autoit/variable_feature.test @@ -0,0 +1,19 @@ +$foo +$foo_bar_42 +@ComputerName +@CPUArch +@TAB + +---------------------------------------------------- + +[ + ["variable", "$foo"], + ["variable", "$foo_bar_42"], + ["variable", "@ComputerName"], + ["variable", "@CPUArch"], + ["variable", "@TAB"] +] + +---------------------------------------------------- + +Checks for variables and macros. \ No newline at end of file