Move the Bash language into a function environment Moving the Bash language definition into a function environment allows for local variables, which are necessary for future changes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
diff --git a/components/prism-bash.js b/components/prism-bash.js
index 5b6486d..8fdbde9 100644
--- a/components/prism-bash.js
+++ b/components/prism-bash.js
@@ -1,31 +1,33 @@
-Prism.languages.bash = Prism.languages.extend('clike', {
- 'comment': {
- pattern: /(^|[^"{\\])#.*/,
- lookbehind: true
- },
- 'string': {
- //allow multiline string
- pattern: /("|')(\\?[\s\S])*?\1/,
- inside: {
- //'property' class reused for bash variables
- 'property': /\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/
- }
- },
- // Redefined to prevent highlighting of numbers in filenames
- 'number': {
- pattern: /([^\w\.])-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,
- lookbehind: true
- },
- // Originally based on http://ss64.com/bash/
- 'function': /\b(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)\b/,
- 'keyword': /\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/
-});
+(function(Prism) {
+ Prism.languages.bash = Prism.languages.extend('clike', {
+ 'comment': {
+ pattern: /(^|[^"{\\])#.*/,
+ lookbehind: true
+ },
+ 'string': {
+ //allow multiline string
+ pattern: /("|')(\\?[\s\S])*?\1/,
+ inside: {
+ //'property' class reused for bash variables
+ 'property': /\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/
+ }
+ },
+ // Redefined to prevent highlighting of numbers in filenames
+ 'number': {
+ pattern: /([^\w\.])-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,
+ lookbehind: true
+ },
+ // Originally based on http://ss64.com/bash/
+ 'function': /\b(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)\b/,
+ 'keyword': /\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/
+ });
-Prism.languages.insertBefore('bash', 'keyword', {
- //'property' class reused for bash variables
- 'property': /\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/
-});
-Prism.languages.insertBefore('bash', 'comment', {
- //shebang must be before comment, 'important' class from css reused
- 'important': /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/
-});
+ Prism.languages.insertBefore('bash', 'keyword', {
+ //'property' class reused for bash variables
+ 'property': /\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/
+ });
+ Prism.languages.insertBefore('bash', 'comment', {
+ //shebang must be before comment, 'important' class from css reused
+ 'important': /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/
+ });
+})(Prism);
\ No newline at end of file