Skip to content

Commit ea8a0f4

Browse files
Added support for AWK (#3374)
1 parent 7bda2bf commit ea8a0f4

18 files changed

+244
-3
lines changed

components.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@
175175
"alias": "avdl",
176176
"owner": "RunDevelopment"
177177
},
178+
"awk": {
179+
"title": "AWK",
180+
"alias": "gawk",
181+
"aliasTitles": {
182+
"gawk": "GAWK"
183+
},
184+
"owner": "RunDevelopment"
185+
},
178186
"bash": {
179187
"title": "Bash",
180188
"alias": "shell",

components/prism-awk.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Prism.languages.awk = {
2+
'hashbang': {
3+
pattern: /^#!.*/,
4+
greedy: true,
5+
alias: 'comment'
6+
},
7+
'comment': {
8+
pattern: /#.*/,
9+
greedy: true
10+
},
11+
'string': {
12+
pattern: /(^|[^\\])"(?:[^\\"\r\n]|\\.)*"/,
13+
lookbehind: true,
14+
greedy: true
15+
},
16+
'regex': {
17+
pattern: /((?:^|[^\w\s)])\s*)\/(?:[^\/\\\r\n]|\\.)*\//,
18+
lookbehind: true,
19+
greedy: true
20+
},
21+
22+
'variable': /\$\w+/,
23+
'keyword': /\b(?:BEGIN|BEGINFILE|END|ENDFILE|break|case|continue|default|delete|do|else|exit|for|function|getline|if|in|next|nextfile|printf?|return|switch|while)\b|@(?:include|load)\b/,
24+
25+
'function': /\b[a-z_]\w*(?=\s*\()/i,
26+
'number': /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[a-fA-F0-9]+)\b/,
27+
28+
'operator': /--|\+\+|!?~|>&|>>|<<|(?:\*\*|[<>!=+\-*/%^])=?|&&|\|[|&]|[?:]/,
29+
'punctuation': /[()[\]{},;]/
30+
};
31+
32+
Prism.languages.gawk = Prism.languages.awk;

components/prism-awk.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-awk.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h2>Full example</h2>
2+
<pre><code># Source: awklang.org
3+
BEGIN { ascetion = bsection = 0 }
4+
$2 ~ /^[aA][0-9]+/ { asection++ }
5+
$2 ~ /^[bB][0-9]+/ { bsection++ }
6+
END { print asection, bsection }
7+
</code></pre>

plugins/autoloader/prism-autoloader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
"adoc": "asciidoc",
180180
"avs": "avisynth",
181181
"avdl": "avro-idl",
182+
"gawk": "awk",
182183
"shell": "bash",
183184
"shortcode": "bbcode",
184185
"rbnf": "bnf",

plugins/autoloader/prism-autoloader.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
"avs": "AviSynth",
5050
"avro-idl": "Avro IDL",
5151
"avdl": "Avro IDL",
52+
"awk": "AWK",
53+
"gawk": "GAWK",
5254
"basic": "BASIC",
5355
"bbcode": "BBcode",
5456
"bnf": "BNF",

0 commit comments

Comments
 (0)