Skip to content

Commit

Permalink
CoffeeScript: Regexp optimisation + don't use captures if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Oct 22, 2017
1 parent 5895978 commit 918e0ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions components/prism-coffeescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ Prism.languages.coffeescript = Prism.languages.extend('javascript', {

// Strings are multiline
{
pattern: /'(?:\\?[^\\])*?'/,
pattern: /'(?:\\[\s\S]|[^\\'])*'/,
greedy: true
},

{
// Strings are multiline
pattern: /"(?:\\?[^\\])*?"/,
pattern: /"(?:\\[\s\S]|[^\\"])*"/,
greedy: true,
inside: {
'interpolation': interpolation
}
}
],
'keyword': /\b(and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
'keyword': /\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
'class-member': {
pattern: /@(?!\d)\w+/,
alias: 'variable'
Expand All @@ -52,7 +52,7 @@ Prism.languages.insertBefore('coffeescript', 'comment', {

Prism.languages.insertBefore('coffeescript', 'string', {
'inline-javascript': {
pattern: /`(?:\\?[\s\S])*?`/,
pattern: /`(?:\\[\s\S]|[^\\`])*`/,
inside: {
'delimiter': {
pattern: /^`|`$/,
Expand Down
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.

0 comments on commit 918e0ff

Please sign in to comment.