Merge branch 'gh-pages' of https://github.com/LeaVerou/prism Conflicts: components.js
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
diff --git a/components.js b/components.js
index fb7dc47..7bae569 100644
--- a/components.js
+++ b/components.js
@@ -191,14 +191,18 @@ var components = {
"title": "Git",
"owner": "lgiraudel"
},
- "scheme" : {
- "title": "Scheme",
- "owner" : "bacchus123"
- },
+ "scheme" : {
+ "title": "Scheme",
+ "owner" : "bacchus123"
+ },
"nasm": {
"title": "nasm",
"owner": "rbmj"
},
+ "perl": {
+ "title": "Perl",
+ "owner": "Golmote"
+ },
"handlebars": {
"title": "Handlebars",
"owner": "Golmote"
diff --git a/components/prism-perl.js b/components/prism-perl.js
new file mode 100644
index 0000000..6bc1187
--- /dev/null
+++ b/components/prism-perl.js
@@ -0,0 +1,112 @@
+Prism.languages.perl = {
+ 'comment': [
+ {
+ // POD
+ pattern: /((?:^|\n)\s*)=\w+[\s\S]*?=cut.+/g,
+ lookbehind: true
+ },
+ {
+ pattern: /(^|[^\\$])#.*?(\r?\n|$)/g,
+ lookbehind: true
+ }
+ ],
+ // TODO Could be nice to handle Heredoc too.
+ 'string': [
+ // q/.../
+ /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s\{\(\[<])(\\?.)*?\s*\1/g,
+
+ // q a...a
+ /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(\\?.)*?\s*\1/g,
+
+ // q(...)
+ /\b(?:q|qq|qx|qw)\s*\(([^()]|\\.)*\s*\)/g,
+
+ // q{...}
+ /\b(?:q|qq|qx|qw)\s*\{([^{}]|\\.)*\s*\}/g,
+
+ // q[...]
+ /\b(?:q|qq|qx|qw)\s*\[([^[\]]|\\.)*\s*\]/g,
+
+ // q<...>
+ /\b(?:q|qq|qx|qw)\s*<([^<>]|\\.)*\s*>/g,
+
+ // "...", '...', `...`
+ /("|'|`)(\\?.)*?\1/g
+ ],
+ 'regex': [
+ // m/.../
+ /\b(?:m|qr)\s*([^a-zA-Z0-9\s\{\(\[<])(\\?.)*?\s*\1[msixpodualgc]*/g,
+
+ // m a...a
+ /\b(?:m|qr)\s+([a-zA-Z0-9])(\\?.)*?\s*\1[msixpodualgc]*/g,
+
+ // m(...)
+ /\b(?:m|qr)\s*\(([^()]|\\.)*\s*\)[msixpodualgc]*/g,
+
+ // m{...}
+ /\b(?:m|qr)\s*\{([^{}]|\\.)*\s*\}[msixpodualgc]*/g,
+
+ // m[...]
+ /\b(?:m|qr)\s*\[([^[\]]|\\.)*\s*\][msixpodualgc]*/g,
+
+ // m<...>
+ /\b(?:m|qr)\s*<([^<>]|\\.)*\s*>[msixpodualgc]*/g,
+
+ // s/.../.../
+ /\b(?:s|tr|y)\s*([^a-zA-Z0-9\s\{\(\[<])(\\?.)*?\s*\1\s*((?!\1).|\\.)*\s*\1[msixpodualgcer]*/g,
+
+ // s a...a...a
+ /\b(?:s|tr|y)\s+([a-zA-Z0-9])(\\?.)*?\s*\1\s*((?!\1).|\\.)*\s*\1[msixpodualgcer]*/g,
+
+ // s(...)(...)
+ /\b(?:s|tr|y)\s*\(([^()]|\\.)*\s*\)\s*\(\s*([^()]|\\.)*\s*\)[msixpodualgcer]*/g,
+
+ // s{...}{...}
+ /\b(?:s|tr|y)\s*\{([^{}]|\\.)*\s*\}\s*\{\s*([^{}]|\\.)*\s*\}[msixpodualgcer]*/g,
+
+ // s[...][...]
+ /\b(?:s|tr|y)\s*\[([^[\]]|\\.)*\s*\]\s*\[\s*([^[\]]|\\.)*\s*\][msixpodualgcer]*/g,
+
+ // s<...><...>
+ /\b(?:s|tr|y)\s*<([^<>]|\\.)*\s*>\s*<\s*([^<>]|\\.)*\s*>[msixpodualgcer]*/g,
+
+ // /.../
+ /\/(\[.+?]|\\.|[^\/\r\n])*\/[msixpodualgc]*(?=\s*($|[\r\n,.;})&|\-+*=~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/g
+ ],
+
+ // FIXME Not sure about the handling of ::, ', and #
+ 'variable': [
+ // ${^POSTMATCH}
+ /[&*\$@%]\{\^[A-Z]+\}/g,
+ // $^V
+ /[&*\$@%]\^[A-Z_]/g,
+ // ${...}
+ /[&*\$@%]#?(?=\{)/,
+ // $foo
+ /[&*\$@%]#?((::)*'?(?!\d)[\w$]+)+(::)*/ig,
+ // $1
+ /[&*\$@%]\d+/g,
+ // $_, @_, %!
+ /[\$@%][!"#\$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/g
+ ],
+ 'filehandle': {
+ // <>, <FOO>, _
+ pattern: /<(?!=).*>|\b_\b/g,
+ alias: 'symbol'
+ },
+ 'vstring': {
+ // v1.2, 1.2.3
+ pattern: /v\d+(\.\d+)*|\d+(\.\d+){2,}/g,
+ alias: 'string'
+ },
+ 'function': {
+ pattern: /sub [a-z0-9_]+/ig,
+ inside: {
+ keyword: /sub/
+ }
+ },
+ 'keyword': /\b(any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|say|state|sub|switch|undef|unless|until|use|when|while)\b/g,
+ 'number': /(\n|\b)-?(0x[\dA-Fa-f](_?[\dA-Fa-f])*|0b[01](_?[01])*|(\d(_?\d)*)?\.?\d(_?\d)*([Ee]-?\d+)?)\b/g,
+ 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|[-+*=~\/|&]{1,2}|<=?|>=?|\.{1,3}|[!?\\^]|\b(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b/g,
+ 'punctuation': /[{}[\];(),:]/g
+};
diff --git a/components/prism-perl.min.js b/components/prism-perl.min.js
new file mode 100644
index 0000000..a09d2c9
--- /dev/null
+++ b/components/prism-perl.min.js
@@ -0,0 +1 @@
+Prism.languages.perl={comment:[{pattern:/((?:^|\n)\s*)=\w+[\s\S]*?=cut.+/g,lookbehind:!0},{pattern:/(^|[^\\$])#.*?(\r?\n|$)/g,lookbehind:!0}],string:[/\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s\{\(\[<])(\\?.)*?\s*\1/g,/\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(\\?.)*?\s*\1/g,/\b(?:q|qq|qx|qw)\s*\(([^()]|\\.)*\s*\)/g,/\b(?:q|qq|qx|qw)\s*\{([^{}]|\\.)*\s*\}/g,/\b(?:q|qq|qx|qw)\s*\[([^[\]]|\\.)*\s*\]/g,/\b(?:q|qq|qx|qw)\s*<([^<>]|\\.)*\s*>/g,/("|'|`)(\\?.)*?\1/g],regex:[/\b(?:m|qr)\s*([^a-zA-Z0-9\s\{\(\[<])(\\?.)*?\s*\1[msixpodualgc]*/g,/\b(?:m|qr)\s+([a-zA-Z0-9])(\\?.)*?\s*\1[msixpodualgc]*/g,/\b(?:m|qr)\s*\(([^()]|\\.)*\s*\)[msixpodualgc]*/g,/\b(?:m|qr)\s*\{([^{}]|\\.)*\s*\}[msixpodualgc]*/g,/\b(?:m|qr)\s*\[([^[\]]|\\.)*\s*\][msixpodualgc]*/g,/\b(?:m|qr)\s*<([^<>]|\\.)*\s*>[msixpodualgc]*/g,/\b(?:s|tr|y)\s*([^a-zA-Z0-9\s\{\(\[<])(\\?.)*?\s*\1\s*((?!\1).|\\.)*\s*\1[msixpodualgcer]*/g,/\b(?:s|tr|y)\s+([a-zA-Z0-9])(\\?.)*?\s*\1\s*((?!\1).|\\.)*\s*\1[msixpodualgcer]*/g,/\b(?:s|tr|y)\s*\(([^()]|\\.)*\s*\)\s*\(\s*([^()]|\\.)*\s*\)[msixpodualgcer]*/g,/\b(?:s|tr|y)\s*\{([^{}]|\\.)*\s*\}\s*\{\s*([^{}]|\\.)*\s*\}[msixpodualgcer]*/g,/\b(?:s|tr|y)\s*\[([^[\]]|\\.)*\s*\]\s*\[\s*([^[\]]|\\.)*\s*\][msixpodualgcer]*/g,/\b(?:s|tr|y)\s*<([^<>]|\\.)*\s*>\s*<\s*([^<>]|\\.)*\s*>[msixpodualgcer]*/g,/\/(\[.+?]|\\.|[^\/\r\n])*\/[msixpodualgc]*(?=\s*($|[\r\n,.;})&|\-+*=~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/g],variable:[/[&*\$@%]\{\^[A-Z]+\}/g,/[&*\$@%]\^[A-Z_]/g,/[&*\$@%]#?(?=\{)/,/[&*\$@%]#?((::)*'?(?!\d)[\w$]+)+(::)*/gi,/[&*\$@%]\d+/g,/[\$@%][!"#\$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/g],filehandle:{pattern:/<(?!=).*>|\b_\b/g,alias:"symbol"},vstring:{pattern:/v\d+(\.\d+)*|\d+(\.\d+){2,}/g,alias:"string"},"function":{pattern:/sub [a-z0-9_]+/gi,inside:{keyword:/sub/}},keyword:/\b(any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|say|state|sub|switch|undef|unless|until|use|when|while)\b/g,number:/(\n|\b)-?(0x[\dA-Fa-f](_?[\dA-Fa-f])*|0b[01](_?[01])*|(\d(_?\d)*)?\.?\d(_?\d)*([Ee]-?\d+)?)\b/g,operator:/-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|[-+*=~\/|&]{1,2}|<=?|>=?|\.{1,3}|[!?\\^]|\b(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b/g,punctuation:/[{}[\];(),:]/g};
\ No newline at end of file