Commit d7b2b43c8556814081950f14ad59d6d464f03b9a

Golmote 2018-03-26T21:00:12

Monkey: Make comments greedy. Update known failures and tests.

diff --git a/components/prism-monkey.js b/components/prism-monkey.js
index d25e576..be3cc78 100644
--- a/components/prism-monkey.js
+++ b/components/prism-monkey.js
@@ -1,8 +1,14 @@
 Prism.languages.monkey = {
 	'string': /"[^"\r\n]*"/,
 	'comment': [
-		/^#Rem\s+[\s\S]*?^#End/im,
-		/'.+/
+		{
+			pattern: /^#Rem\s+[\s\S]*?^#End/im,
+			greedy: true
+		},
+		{
+			pattern: /'.+/,
+			greedy: true
+		}
 	],
 	'preprocessor': {
 		pattern: /(^[ \t]*)#.+/m,
diff --git a/components/prism-monkey.min.js b/components/prism-monkey.min.js
index 2f91ca6..3620df6 100644
--- a/components/prism-monkey.min.js
+++ b/components/prism-monkey.min.js
@@ -1 +1 @@
-Prism.languages.monkey={string:/"[^"\r\n]*"/,comment:[/^#Rem\s+[\s\S]*?^#End/im,/'.+/],preprocessor:{pattern:/(^[ \t]*)#.+/m,lookbehind:!0,alias:"comment"},"function":/\w+(?=\()/,"type-char":{pattern:/(\w)[?%#$]/,lookbehind:!0,alias:"variable"},number:{pattern:/((?:\.\.)?)(?:(?:\b|\B-\.?|\B\.)\d+(?:(?!\.\.)\.\d*)?|\$[\da-f]+)/i,lookbehind:!0},keyword:/\b(?:Void|Strict|Public|Private|Property|Bool|Int|Float|String|Array|Object|Continue|Exit|Import|Extern|New|Self|Super|Try|Catch|Eachin|True|False|Extends|Abstract|Final|Select|Case|Default|Const|Local|Global|Field|Method|Function|Class|End|If|Then|Else|ElseIf|EndIf|While|Wend|Repeat|Until|Forever|For|To|Step|Next|Return|Module|Interface|Implements|Inline|Throw|Null)\b/i,operator:/\.\.|<[=>]?|>=?|:?=|(?:[+\-*\/&~|]|\b(?:Mod|Shl|Shr)\b)=?|\b(?:And|Not|Or)\b/i,punctuation:/[.,:;()\[\]]/};
\ No newline at end of file
+Prism.languages.monkey={string:/"[^"\r\n]*"/,comment:[{pattern:/^#Rem\s+[\s\S]*?^#End/im,greedy:!0},{pattern:/'.+/,greedy:!0}],preprocessor:{pattern:/(^[ \t]*)#.+/m,lookbehind:!0,alias:"comment"},"function":/\w+(?=\()/,"type-char":{pattern:/(\w)[?%#$]/,lookbehind:!0,alias:"variable"},number:{pattern:/((?:\.\.)?)(?:(?:\b|\B-\.?|\B\.)\d+(?:(?!\.\.)\.\d*)?|\$[\da-f]+)/i,lookbehind:!0},keyword:/\b(?:Void|Strict|Public|Private|Property|Bool|Int|Float|String|Array|Object|Continue|Exit|Import|Extern|New|Self|Super|Try|Catch|Eachin|True|False|Extends|Abstract|Final|Select|Case|Default|Const|Local|Global|Field|Method|Function|Class|End|If|Then|Else|ElseIf|EndIf|While|Wend|Repeat|Until|Forever|For|To|Step|Next|Return|Module|Interface|Implements|Inline|Throw|Null)\b/i,operator:/\.\.|<[=>]?|>=?|:?=|(?:[+\-*\/&~|]|\b(?:Mod|Shl|Shr)\b)=?|\b(?:And|Not|Or)\b/i,punctuation:/[.,:;()\[\]]/};
\ No newline at end of file
diff --git a/examples/prism-monkey.html b/examples/prism-monkey.html
index 8112896..6716a9a 100644
--- a/examples/prism-monkey.html
+++ b/examples/prism-monkey.html
@@ -71,17 +71,4 @@ Function Main()
 
     New MyApp
 
-End</code></pre>
-
-<h2>Known failures</h2>
-<p>There are certain edge cases where Prism will fail.
-	There are always such cases in every regex-based syntax highlighter.
-	However, Prism dares to be open and honest about them.
-	If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
-</p>
-
-<h2>Two double quotes inside a comment</h2>
-<pre><code>' This "comment" is broken
-#Rem
-This "comment" is broken
-#End</code></pre>
\ No newline at end of file
+End</code></pre>
\ No newline at end of file
diff --git a/tests/languages/monkey/comment_feature.test b/tests/languages/monkey/comment_feature.test
index da20a31..967d3fe 100644
--- a/tests/languages/monkey/comment_feature.test
+++ b/tests/languages/monkey/comment_feature.test
@@ -2,12 +2,18 @@
 #Rem Foo
 Bar 'Baz
 #End
+' This "is" a comment
+#Rem
+This "is" a comment
+#End
 
 ----------------------------------------------------
 
 [
 	["comment", "' Foobar"],
-	["comment", "#Rem Foo\r\nBar 'Baz\r\n#End"]
+	["comment", "#Rem Foo\r\nBar 'Baz\r\n#End"],
+	["comment", "' This \"is\" a comment"],
+	["comment", "#Rem\r\nThis \"is\" a comment\r\n#End"]
 ]
 
 ----------------------------------------------------