Skip to content

Commit 211a41c

Browse files
committed
Merge pull request #771 from Golmote/prism-autoit
Add support for AutoIt. Fix #453
2 parents bd3e9ea + 3f38673 commit 211a41c

16 files changed

+370
-2
lines changed

components.js

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ var components = {
8484
"require": "markup",
8585
"owner": "nauzilus"
8686
},
87+
"autoit": {
88+
"title": "AutoIt",
89+
"owner": "Golmote"
90+
},
8791
"autohotkey": {
8892
"title": "AutoHotkey",
8993
"owner": "aviaryan"

components/prism-autoit.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Prism.languages.autoit = {
2+
"comment": [
3+
/;.*/,
4+
{
5+
// The multi-line comments delimiters can actually be commented out with ";"
6+
pattern: /(^\s*)#(?:comments-start|cs)[\s\S]*?^\s*#(?:comments-end|ce)/m,
7+
lookbehind: true
8+
}
9+
],
10+
"url": {
11+
pattern: /(^\s*#include\s+)(?:<[^\r\n>]+>|"[^\r\n"]+")/m,
12+
lookbehind: true
13+
},
14+
"string": {
15+
pattern: /(["'])(?:\1\1|(?!\1)[^\r\n])*\1/,
16+
inside: {
17+
"variable": /([%$@])\w+\1/
18+
}
19+
},
20+
"directive": {
21+
pattern: /(^\s*)#\w+/m,
22+
lookbehind: true,
23+
alias: 'keyword'
24+
},
25+
"function": /\b\w+(?=\()/,
26+
// Variables and macros
27+
"variable": /[$@]\w+/,
28+
"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,
29+
"number": /\b(?:0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i,
30+
"boolean": /\b(?:True|False)\b/i,
31+
"operator": /<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Or|Not)\b/i,
32+
"punctuation": /[\[\]().,:]/
33+
};

components/prism-autoit.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-autoit.html

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<h1>AutoIt</h1>
2+
<p>To use this language, use the class "language-autoit".</p>
3+
4+
<h2>Comments</h2>
5+
<pre><code>; Single-line comment
6+
#comments-start
7+
Multi-line
8+
comment
9+
#comments-end
10+
#cs
11+
Multi-line
12+
comment
13+
#ce
14+
;#comments-start
15+
foo()
16+
;#comments-end</code></pre>
17+
18+
<h2>Strings</h2>
19+
<pre><code>"foo'bar'baz"
20+
"foo""bar""baz"
21+
'foo"bar"baz'
22+
'foo''bar''baz'</code></pre>
23+
24+
<h2>Numbers</h2>
25+
<pre><code>2
26+
4.566
27+
1.5e3
28+
0x4fff</code></pre>
29+
30+
<h2>Booleans</h2>
31+
<pre><code>True
32+
False</code></pre>
33+
34+
<h2>Keywords and variables</h2>
35+
<pre><code>; Display all the numbers for 1 to 10 but skip displaying 7.
36+
For $i = 1 To 10
37+
If $i = 7 Then
38+
ContinueLoop ; Skip displaying the message box when $i is equal to 7.
39+
EndIf
40+
MsgBox($MB_SYSTEMMODAL, "", "The value of $i is: " & $i)
41+
Next</code></pre>
42+
43+
<h2>Known failures</h2>
44+
<p>There are certain edge cases where Prism will fail.
45+
There are always such cases in every regex-based syntax highlighter.
46+
However, Prism dares to be open and honest about them.
47+
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.
48+
</p>
49+
50+
<h3>Comment-like substrings</h3>
51+
<pre><code>"This string ; is broken"</code></pre>
52+
53+
<h3>Nested block comments</h3>
54+
<pre><code>#cs
55+
#cs
56+
foo()
57+
#ce
58+
#ce</code></pre>

plugins/show-language/prism-show-language.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (typeof self === 'undefined' || !self.Prism || !self.document) {
55
}
66

77
// The languages map is built automatically with gulp
8-
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"}/*]*/;
8+
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"}/*]*/;
99
Prism.hooks.add('before-highlight', function(env) {
1010
var pre = env.element.parentNode;
1111
if (!pre || !/pre/i.test(pre.nodeName)) {

plugins/show-language/prism-show-language.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
True
2+
False
3+
4+
----------------------------------------------------
5+
6+
[
7+
["boolean", "True"],
8+
["boolean", "False"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for booleans.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
;
2+
; foo
3+
#comments-start
4+
foobar()
5+
#comments-end
6+
#cs
7+
foobar()
8+
#ce
9+
;#comments-start
10+
foobar()
11+
;#comments-end
12+
;#cs
13+
foobar()
14+
;#ce
15+
16+
----------------------------------------------------
17+
18+
[
19+
["comment", ";"],
20+
["comment", "; foo"],
21+
["comment", "#comments-start\r\n\tfoobar()\r\n#comments-end"],
22+
["comment", "#cs\r\n\tfoobar()\r\n#ce"],
23+
["comment", ";#comments-start"],
24+
["function", "foobar"], ["punctuation", "("], ["punctuation", ")"],
25+
["comment", ";#comments-end"],
26+
["comment", ";#cs"],
27+
["function", "foobar"], ["punctuation", "("], ["punctuation", ")"],
28+
["comment", ";#ce"]
29+
]
30+
31+
----------------------------------------------------
32+
33+
Checks for comments.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#NoTrayIcon
2+
#OnAutoItStartRegister "Example"
3+
4+
----------------------------------------------------
5+
6+
[
7+
["directive", "#NoTrayIcon"],
8+
["directive", "#OnAutoItStartRegister"], ["string", ["\"Example\""]]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for directives.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
foo()
2+
foo_bar()
3+
foo_bar_42()
4+
5+
----------------------------------------------------
6+
7+
[
8+
["function", "foo"], ["punctuation", "("], ["punctuation", ")"],
9+
["function", "foo_bar"], ["punctuation", "("], ["punctuation", ")"],
10+
["function", "foo_bar_42"], ["punctuation", "("], ["punctuation", ")"]
11+
]
12+
13+
----------------------------------------------------
14+
15+
Checks for functions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
Case
2+
Const
3+
ContinueCase
4+
ContinueLoop
5+
Default
6+
Dim
7+
Do
8+
Else
9+
ElseIf
10+
EndFunc
11+
EndIf
12+
EndSelect
13+
EndSwitch
14+
EndWith
15+
Enum
16+
Exit
17+
ExitLoop
18+
For
19+
Func
20+
Global
21+
If
22+
In
23+
Local
24+
Next
25+
Null
26+
ReDim
27+
Select
28+
Static
29+
Step
30+
Switch
31+
Then
32+
To
33+
Until
34+
Volatile
35+
WEnd
36+
While
37+
With
38+
39+
----------------------------------------------------
40+
41+
[
42+
["keyword", "Case"],
43+
["keyword", "Const"],
44+
["keyword", "ContinueCase"],
45+
["keyword", "ContinueLoop"],
46+
["keyword", "Default"],
47+
["keyword", "Dim"],
48+
["keyword", "Do"],
49+
["keyword", "Else"],
50+
["keyword", "ElseIf"],
51+
["keyword", "EndFunc"],
52+
["keyword", "EndIf"],
53+
["keyword", "EndSelect"],
54+
["keyword", "EndSwitch"],
55+
["keyword", "EndWith"],
56+
["keyword", "Enum"],
57+
["keyword", "Exit"],
58+
["keyword", "ExitLoop"],
59+
["keyword", "For"],
60+
["keyword", "Func"],
61+
["keyword", "Global"],
62+
["keyword", "If"],
63+
["keyword", "In"],
64+
["keyword", "Local"],
65+
["keyword", "Next"],
66+
["keyword", "Null"],
67+
["keyword", "ReDim"],
68+
["keyword", "Select"],
69+
["keyword", "Static"],
70+
["keyword", "Step"],
71+
["keyword", "Switch"],
72+
["keyword", "Then"],
73+
["keyword", "To"],
74+
["keyword", "Until"],
75+
["keyword", "Volatile"],
76+
["keyword", "WEnd"],
77+
["keyword", "While"],
78+
["keyword", "With"]
79+
]
80+
81+
----------------------------------------------------
82+
83+
Checks for keywords.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
42
2+
3.14159
3+
4e8
4+
3.5E-9
5+
0.7e+12
6+
0xBadFace
7+
8+
----------------------------------------------------
9+
10+
[
11+
["number", "42"],
12+
["number", "3.14159"],
13+
["number", "4e8"],
14+
["number", "3.5E-9"],
15+
["number", "0.7e+12"],
16+
["number", "0xBadFace"]
17+
]
18+
19+
----------------------------------------------------
20+
21+
Checks for numbers.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
< <= <>
2+
> >=
3+
+ += - -=
4+
* *= / /=
5+
& &=
6+
? ^
7+
And Or Not
8+
9+
----------------------------------------------------
10+
11+
[
12+
["operator", "<"], ["operator", "<="], ["operator", "<>"],
13+
["operator", ">"], ["operator", ">="],
14+
["operator", "+"], ["operator", "+="], ["operator", "-"], ["operator", "-="],
15+
["operator", "*"], ["operator", "*="], ["operator", "/"], ["operator", "/="],
16+
["operator", "&"], ["operator", "&="],
17+
["operator", "?"], ["operator", "^"],
18+
["operator", "And"], ["operator", "Or"], ["operator", "Not"]
19+
]
20+
21+
----------------------------------------------------
22+
23+
Checks for operators.
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
""
2+
"foo""bar"
3+
"foo %foo% bar $bar$ baz @baz@"
4+
''
5+
'foo''bar'
6+
'foo %foo% bar $bar$ baz @baz@'
7+
8+
----------------------------------------------------
9+
10+
[
11+
["string", ["\"\""]],
12+
["string", ["\"foo\"\"bar\""]],
13+
["string", [
14+
"\"foo ",
15+
["variable", "%foo%"],
16+
" bar ",
17+
["variable", "$bar$"],
18+
" baz ",
19+
["variable", "@baz@"],
20+
"\""
21+
]],
22+
["string", ["''"]],
23+
["string", ["'foo''bar'"]],
24+
["string", [
25+
"'foo ",
26+
["variable", "%foo%"],
27+
" bar ",
28+
["variable", "$bar$"],
29+
" baz ",
30+
["variable", "@baz@"],
31+
"'"
32+
]]
33+
]
34+
35+
----------------------------------------------------
36+
37+
Checks for strings and interpolation.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <foo.au3>
2+
#include "foo.au3"
3+
4+
----------------------------------------------------
5+
6+
[
7+
["directive", "#include"],
8+
["url", "<foo.au3>"],
9+
["directive", "#include"],
10+
["url", "\"foo.au3\""]
11+
]
12+
13+
----------------------------------------------------
14+
15+
Checks for files in includes.

0 commit comments

Comments
 (0)