Erlang: Fixed quoted functions and quoted atoms. Fixed variables pattern so that it does not break atoms. Fixed operator <=.
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
diff --git a/components/prism-erlang.js b/components/prism-erlang.js
index deea6aa..5baa9d7 100644
--- a/components/prism-erlang.js
+++ b/components/prism-erlang.js
@@ -2,11 +2,11 @@ Prism.languages.erlang = {
'comment': /%.+/,
'string': /"(?:\\?.)*?"/,
'quoted-function': {
- pattern: /'[^']+'(?=\()/,
+ pattern: /'(?:\\.|[^'\\])+'(?=\()/,
alias: 'function'
},
'quoted-atom': {
- pattern: /'[^']+'/,
+ pattern: /'(?:\\.|[^'\\])+'/,
alias: 'atom'
},
'boolean': /\b(?:true|false)\b/,
@@ -17,15 +17,21 @@ Prism.languages.erlang = {
/(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/
],
'function': /\b[a-z][\w@]*(?=\()/,
- 'variable': /(?:\b|\?)[A-Z_][\w@]*/,
+ 'variable': {
+ // Look-behind is used to prevent wrong highlighting of atoms containing "@"
+ pattern: /(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,
+ lookbehind: true
+ },
'operator': [
- /[=\/>:]=|>=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,
+ /[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,
{
- pattern: /(^|(?!<).)<(?!<)/,
+ // We don't want to match <<
+ pattern: /(^|[^<])<(?!<)/,
lookbehind: true
},
{
- pattern: /(^|(?!>).)>(?!>)/,
+ // We don't want to match >>
+ pattern: /(^|[^>])>(?!>)/,
lookbehind: true
}
],
diff --git a/components/prism-erlang.min.js b/components/prism-erlang.min.js
index 6a072b6..613f0f9 100644
--- a/components/prism-erlang.min.js
+++ b/components/prism-erlang.min.js
@@ -1 +1 @@
-Prism.languages.erlang={comment:/%.+/,string:/"(?:\\?.)*?"/,"quoted-function":{pattern:/'[^']+'(?=\()/,alias:"function"},"quoted-atom":{pattern:/'[^']+'/,alias:"atom"},"boolean":/\b(?:true|false)\b/,keyword:/\b(?:fun|when|case|of|end|if|receive|after|try|catch)\b/,number:[/\$\\?./,/\d+#[a-z0-9]+/i,/(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/],"function":/\b[a-z][\w@]*(?=\()/,variable:/(?:\b|\?)[A-Z_][\w@]*/,operator:[/[=\/>:]=|>=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,{pattern:/(^|(?!<).)<(?!<)/,lookbehind:!0},{pattern:/(^|(?!>).)>(?!>)/,lookbehind:!0}],atom:/\b[a-z][\w@]*/,punctuation:/[()[\]{}:;,.#|]|<<|>>/};
\ No newline at end of file
+Prism.languages.erlang={comment:/%.+/,string:/"(?:\\?.)*?"/,"quoted-function":{pattern:/'(?:\\.|[^'\\])+'(?=\()/,alias:"function"},"quoted-atom":{pattern:/'(?:\\.|[^'\\])+'/,alias:"atom"},"boolean":/\b(?:true|false)\b/,keyword:/\b(?:fun|when|case|of|end|if|receive|after|try|catch)\b/,number:[/\$\\?./,/\d+#[a-z0-9]+/i,/(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/],"function":/\b[a-z][\w@]*(?=\()/,variable:{pattern:/(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,lookbehind:!0},operator:[/[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,{pattern:/(^|[^<])<(?!<)/,lookbehind:!0},{pattern:/(^|[^>])>(?!>)/,lookbehind:!0}],atom:/\b[a-z][\w@]*/,punctuation:/[()[\]{}:;,.#|]|<<|>>/};
\ No newline at end of file