Monkey: Make comments greedy. Update known failures and tests.
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
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"]
]
----------------------------------------------------