Commit fa286aa57f04c2e88370b9b717e5ea6d35c70334

Golmote 2015-07-17T08:39:15

Erlang: Fixed quoted functions and quoted atoms. Fixed variables pattern so that it does not break atoms. Fixed operator <=.

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