Skip to content

Commit

Permalink
Added support for AWK (#3374)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Mar 14, 2022
1 parent 7bda2bf commit ea8a0f4
Show file tree
Hide file tree
Showing 18 changed files with 244 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@
"alias": "avdl",
"owner": "RunDevelopment"
},
"awk": {
"title": "AWK",
"alias": "gawk",
"aliasTitles": {
"gawk": "GAWK"
},
"owner": "RunDevelopment"
},
"bash": {
"title": "Bash",
"alias": "shell",
Expand Down
32 changes: 32 additions & 0 deletions components/prism-awk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Prism.languages.awk = {
'hashbang': {
pattern: /^#!.*/,
greedy: true,
alias: 'comment'
},
'comment': {
pattern: /#.*/,
greedy: true
},
'string': {
pattern: /(^|[^\\])"(?:[^\\"\r\n]|\\.)*"/,
lookbehind: true,
greedy: true
},
'regex': {
pattern: /((?:^|[^\w\s)])\s*)\/(?:[^\/\\\r\n]|\\.)*\//,
lookbehind: true,
greedy: true
},

'variable': /\$\w+/,
'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/,

'function': /\b[a-z_]\w*(?=\s*\()/i,
'number': /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[a-fA-F0-9]+)\b/,

'operator': /--|\+\+|!?~|>&|>>|<<|(?:\*\*|[<>!=+\-*/%^])=?|&&|\|[|&]|[?:]/,
'punctuation': /[()[\]{},;]/
};

Prism.languages.gawk = Prism.languages.awk;
1 change: 1 addition & 0 deletions components/prism-awk.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions examples/prism-awk.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h2>Full example</h2>
<pre><code># Source: awklang.org
BEGIN { ascetion = bsection = 0 }
$2 ~ /^[aA][0-9]+/ { asection++ }
$2 ~ /^[bB][0-9]+/ { bsection++ }
END { print asection, bsection }
</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
"adoc": "asciidoc",
"avs": "avisynth",
"avdl": "avro-idl",
"gawk": "awk",
"shell": "bash",
"shortcode": "bbcode",
"rbnf": "bnf",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"avs": "AviSynth",
"avro-idl": "Avro IDL",
"avdl": "Avro IDL",
"awk": "AWK",
"gawk": "GAWK",
"basic": "BASIC",
"bbcode": "BBcode",
"bnf": "BNF",
Expand Down
Loading

0 comments on commit ea8a0f4

Please sign in to comment.