Skip to content

Commit

Permalink
C-like: Made all comments greedy (#2680)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Dec 30, 2020
1 parent cdb24ab commit 0a3932f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion components/prism-clike.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Prism.languages.clike = {
'comment': [
{
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true
lookbehind: true,
greedy: true
},
{
pattern: /(^|[^\\:])\/\/.*/,
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.

8 changes: 6 additions & 2 deletions components/prism-coffeescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ Prism.languages.insertBefore('coffeescript', 'string', {
pattern: /^`|`$/,
alias: 'punctuation'
},
rest: Prism.languages.javascript
'script': {
pattern: /[\s\S]+/,
alias: 'language-javascript',
inside: Prism.languages.javascript
}
}
},

Expand Down Expand Up @@ -89,4 +93,4 @@ Prism.languages.insertBefore('coffeescript', 'keyword', {
delete Prism.languages.coffeescript['template-string'];

Prism.languages.coffee = Prism.languages.coffeescript;
}(Prism));
}(Prism));
2 changes: 1 addition & 1 deletion components/prism-coffeescript.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 @@ -1432,7 +1432,8 @@ Prism.languages.clike = {
'comment': [
{
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true
lookbehind: true,
greedy: true
},
{
pattern: /(^|[^\\:])\/\/.*/,
Expand Down
16 changes: 10 additions & 6 deletions tests/languages/coffeescript/inline-javascript_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ JS here */`
[
["inline-javascript", [
["delimiter", "`"],
["comment", "/* JS here */"],
["script", [
["comment", "/* JS here */"]
]],
["delimiter", "`"]
]],
["inline-javascript", [
["delimiter", "`"],
["comment", "/*\r\nJS here */"],
["delimiter", "`"]
]]
["delimiter", "`"],
["script", [
["comment", "/*\r\nJS here */"]
]],
["delimiter", "`"]
]]
]

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

Checks for inline JavaScript.
Checks for inline JavaScript.

0 comments on commit 0a3932f

Please sign in to comment.