-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
(function (Prism) { | ||
var variable = /%%?[~:\w]+%?|!\S+!/; | ||
var parameter = { | ||
pattern: /\/[a-z?]+(?=[ :]|$):?|-[a-z]\b|--[a-z-]+\b/im, | ||
alias: 'attr-name', | ||
inside: { | ||
'punctuation': /:/ | ||
} | ||
}; | ||
var string = /"[^"]*"/; | ||
var number = /(?:\b|-)\d+\b/; | ||
|
||
Prism.languages.batch = { | ||
'comment': [ | ||
/^::.*/m, | ||
{ | ||
pattern: /((?:^|[&(])[ \t]*)rem\b(?:[^^&)\r\n]|\^(?:\r\n|[\s\S]))*/im, | ||
lookbehind: true | ||
} | ||
], | ||
'label': { | ||
pattern: /^:.*/m, | ||
alias: 'property' | ||
}, | ||
'command': [ | ||
{ | ||
// FOR command | ||
pattern: /((?:^|[&(])[ \t]*)for(?: ?\/[a-z?](?:[ :](?:"[^"]*"|\S+))?)* \S+ in \([^)]+\) do/im, | ||
lookbehind: true, | ||
inside: { | ||
'keyword': /^for\b|\b(?:in|do)\b/i, | ||
'string': string, | ||
'parameter': parameter, | ||
'variable': variable, | ||
'number': number, | ||
'punctuation': /[()',]/ | ||
} | ||
}, | ||
{ | ||
// IF command | ||
pattern: /((?:^|[&(])[ \t]*)if(?: ?\/[a-z?](?:[ :](?:"[^"]*"|\S+))?)* (?:not )?(?:cmdextversion \d+|defined \w+|errorlevel \d+|exist \S+|(?:"[^"]*"|\S+)?(?:==| (?:equ|neq|lss|leq|gtr|geq) )(?:"[^"]*"|\S+))/im, | ||
lookbehind: true, | ||
inside: { | ||
'keyword': /^if\b|\b(?:not|cmdextversion|defined|errorlevel|exist)\b/i, | ||
'string': string, | ||
'parameter': parameter, | ||
'variable': variable, | ||
'number': number, | ||
'operator': /\^|==|\b(?:equ|neq|lss|leq|gtr|geq)\b/i | ||
} | ||
}, | ||
{ | ||
// ELSE command | ||
pattern: /((?:^|[&()])[ \t]*)else\b/im, | ||
lookbehind: true, | ||
inside: { | ||
'keyword': /^else\b/i | ||
} | ||
}, | ||
{ | ||
// SET command | ||
pattern: /((?:^|[&(])[ \t]*)set(?: ?\/[a-z](?:[ :](?:"[^"]*"|\S+))?)* (?:[^^&)\r\n]|\^(?:\r\n|[\s\S]))*/im, | ||
lookbehind: true, | ||
inside: { | ||
'keyword': /^set\b/i, | ||
'string': string, | ||
'parameter': parameter, | ||
'variable': [ | ||
variable, | ||
/\w+(?=(?:[*\/%+\-&^|]|<<|>>)?=)/ | ||
], | ||
'number': number, | ||
'operator': /[*\/%+\-&^|]=?|<<=?|>>=?|[!~_=]/, | ||
'punctuation': /[()',]/ | ||
} | ||
}, | ||
{ | ||
// Other commands | ||
pattern: /((?:^|[&(])[ \t]*@?)\w+\b(?:[^^&)\r\n]|\^(?:\r\n|[\s\S]))*/im, | ||
lookbehind: true, | ||
inside: { | ||
'keyword': /^\w+\b/i, | ||
'string': string, | ||
'parameter': parameter, | ||
'label': { | ||
pattern: /(^\s*):\S+/m, | ||
lookbehind: true, | ||
alias: 'property' | ||
}, | ||
'variable': variable, | ||
'number': number, | ||
'operator': /\^/ | ||
} | ||
} | ||
], | ||
'operator': /[&@]/, | ||
'punctuation': /[()']/ | ||
}; | ||
}(Prism)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<h1>Batch</h1> | ||
<p>To use this language, use the class "language-batch".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>:: | ||
:: Foo bar | ||
REM This is a comment too | ||
REM Multi-line ^ | ||
comment</code></pre> | ||
|
||
<h2>Labels</h2> | ||
<pre><code>:foobar | ||
GOTO :EOF</code></pre> | ||
|
||
<h2>Commands</h2> | ||
<pre><code>@ECHO OFF | ||
FOR /l %%a in (5,-1,1) do (TITLE %title% -- closing in %%as) | ||
SET title=%~n0 | ||
if /i "%InstSize:~0,1%"=="M" set maxcnt=3 | ||
ping -n 2 -w 1 127.0.0.1</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
FOR /l %%a in (5,-1,1) do (TITLE %title% -- closing in %%as) | ||
SET title=%~n0 | ||
echo.Hello World | ||
@ECHO OFF | ||
if not defined ProgressFormat set "ProgressFormat=[PPPP]" | ||
EXIT /b | ||
set /a ProgressCnt+=1 | ||
IF "%~1" NEQ "" (SET %~1=%new%) ELSE (echo.%new%) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["command", [ | ||
["keyword", "FOR"], | ||
["parameter", ["/l"]], | ||
["variable", "%%a"], | ||
["keyword", "in"], | ||
["punctuation", "("], | ||
["number", "5"], ["punctuation", ","], | ||
["number", "-1"], ["punctuation", ","], | ||
["number", "1"], ["punctuation", ")"], | ||
["keyword", "do"] | ||
]], | ||
["punctuation", "("], | ||
["command", [ | ||
["keyword", "TITLE"], | ||
["variable", "%title%"], | ||
" -- closing in ", | ||
["variable", "%%as"] | ||
]], | ||
["punctuation", ")"], | ||
|
||
["command", [ | ||
["keyword", "SET"], | ||
["variable", "title"], | ||
["operator", "="], | ||
["variable", "%~n0"] | ||
]], | ||
|
||
["command", [ | ||
["keyword", "echo"], | ||
".Hello World" | ||
]], | ||
|
||
["operator", "@"], | ||
["command", [ | ||
["keyword", "ECHO"], | ||
" OFF" | ||
]], | ||
|
||
["command", [ | ||
["keyword", "if"], | ||
["keyword", "not"], | ||
["keyword", "defined"], | ||
" ProgressFormat" | ||
]], | ||
["command", [ | ||
["keyword", "set"], | ||
["string", "\"ProgressFormat=[PPPP]\""] | ||
]], | ||
|
||
["command", [ | ||
["keyword", "EXIT"], | ||
["parameter", ["/b"]] | ||
]], | ||
|
||
["command", [ | ||
["keyword", "set"], | ||
["parameter", ["/a"]], | ||
["variable", "ProgressCnt"], | ||
["operator", "+="], | ||
["number", "1"] | ||
]], | ||
|
||
["command", [ | ||
["keyword", "IF"], | ||
["string", "\"%~1\""], | ||
["operator", "NEQ"], | ||
["string", "\"\""] | ||
]], | ||
["punctuation", "("], | ||
["command", [ | ||
["keyword", "SET"], | ||
["variable", "%~1"], | ||
["operator", "="], | ||
["variable", "%new%"] | ||
]], | ||
["punctuation", ")"], | ||
["command", [ | ||
["keyword", "ELSE"] | ||
]], | ||
["punctuation", "("], | ||
["command", [ | ||
["keyword", "echo"], | ||
".", | ||
["variable", "%new%"] | ||
]], | ||
["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for commands. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
:: | ||
:: Foobar | ||
REM Foobar | ||
rem foo^ | ||
bar | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "::"], | ||
["comment", ":: Foobar"], | ||
["comment", "REM Foobar"], | ||
["comment", "rem foo^\r\nbar"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
:foo | ||
:Foo_Bar | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["label", ":foo"], | ||
["label", ":Foo_Bar"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for labels. |