Skip to content

Commit

Permalink
C-like: Make single-line comments greedy. Fix #1337. Make sure #1340
Browse files Browse the repository at this point in the history
…stays fixed.
  • Loading branch information
Golmote committed Mar 26, 2018
1 parent 294efaa commit 571f2c5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/prism-clike.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Prism.languages.clike = {
},
{
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true
lookbehind: true,
greedy: true
}
],
'string': {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-clike.min.js

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

3 changes: 2 additions & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,8 @@ Prism.languages.clike = {
},
{
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true
lookbehind: true,
greedy: true
}
],
'string': {
Expand Down
11 changes: 11 additions & 0 deletions tests/languages/javascript/issue1337.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// gulp.watch('./src/**/*.js', ['move']);

----------------------------------------------------

[
["comment", "// gulp.watch('./src/**/*.js', ['move']);"]
]

----------------------------------------------------

Checks for multi-line comment inside single-line comment. See #1337
15 changes: 15 additions & 0 deletions tests/languages/javascript/issue1340.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* ([{}])
* // <= double slash comment
* ([{}]) <= punctuation
*/

----------------------------------------------------

[
["comment", "/*\r\n * ([{}])\r\n * // <= double slash comment\r\n * ([{}]) <= punctuation\r\n */"]
]

----------------------------------------------------

Checks for single-line comment inside multi-line comment. See #1340

0 comments on commit 571f2c5

Please sign in to comment.