Skip to content

Commit

Permalink
Monkey: Make comments greedy. Update known failures and tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Mar 26, 2018
1 parent e93d61f commit d7b2b43
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
10 changes: 8 additions & 2 deletions components/prism-monkey.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-monkey.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions examples/prism-monkey.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,4 @@ <h2>Full example</h2>

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>
End</code></pre>
8 changes: 7 additions & 1 deletion tests/languages/monkey/comment_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
]

----------------------------------------------------
Expand Down

0 comments on commit d7b2b43

Please sign in to comment.