Skip to content

Commit

Permalink
Apply the new greedy flag to a few languages
Browse files Browse the repository at this point in the history
This patch applies the new greedy flag to a few languages and
adds the corresponding test cases.
  • Loading branch information
zeitgeist87 committed Apr 30, 2016
1 parent 9cbf9d7 commit 964450e
Show file tree
Hide file tree
Showing 27 changed files with 127 additions and 25 deletions.
2 changes: 2 additions & 0 deletions components/prism-bash.js
Expand Up @@ -44,10 +44,12 @@
{
pattern: /((?:^|[^<])<<\s*)(?:"|')?(\w+?)(?:"|')?\s*\r?\n(?:[\s\S])*?\r?\n\2/g,
lookbehind: true,
greedy: true,
inside: insideString
},
{
pattern: /(["'])(?:\\\\|\\?[^\\])*?\1/g,
greedy: true,
inside: insideString
}
],
Expand Down
2 changes: 1 addition & 1 deletion components/prism-bash.min.js

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

8 changes: 7 additions & 1 deletion components/prism-coffeescript.js
Expand Up @@ -12,11 +12,15 @@ Prism.languages.coffeescript = Prism.languages.extend('javascript', {
'string': [

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

{
// Strings are multiline
pattern: /"(?:\\?[^\\])*?"/,
greedy: true,
inside: {
'interpolation': interpolation
}
Expand Down Expand Up @@ -62,10 +66,12 @@ Prism.languages.insertBefore('coffeescript', 'string', {
'multiline-string': [
{
pattern: /'''[\s\S]*?'''/,
greedy: true,
alias: 'string'
},
{
pattern: /"""[\s\S]*?"""/,
greedy: true,
alias: 'string',
inside: {
interpolation: interpolation
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.

11 changes: 10 additions & 1 deletion components/prism-groovy.js
@@ -1,6 +1,15 @@
Prism.languages.groovy = Prism.languages.extend('clike', {
'keyword': /\b(as|def|in|abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|native|new|package|private|protected|public|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|trait|transient|try|void|volatile|while)\b/,
'string': /("""|''')[\W\w]*?\1|("|'|\/)(?:\\?.)*?\2|(\$\/)(\$\/\$|[\W\w])*?\/\$/,
'string': [
{
pattern: /("""|''')[\W\w]*?\1|(\$\/)(\$\/\$|[\W\w])*?\/\$/,
greedy: true
},
{
pattern: /("|'|\/)(?:\\?.)*?\1/,
greedy: true
},
],
'number': /\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]+)?(?:e[+-]?[\d]+)?)[glidf]?\b/i,
'operator': {
pattern: /(^|[^.])(~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.{1,2}(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-groovy.min.js

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

5 changes: 4 additions & 1 deletion components/prism-haskell.js
Expand Up @@ -4,7 +4,10 @@ Prism.languages.haskell= {
lookbehind: true
},
'char': /'([^\\']|\\([abfnrtv\\"'&]|\^[A-Z@[\]\^_]|NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|\d+|o[0-7]+|x[0-9a-fA-F]+))'/,
'string': /"([^\\"]|\\([abfnrtv\\"'&]|\^[A-Z@[\]\^_]|NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|\d+|o[0-7]+|x[0-9a-fA-F]+)|\\\s+\\)*"/,
'string': {
pattern: /"([^\\"]|\\([abfnrtv\\"'&]|\^[A-Z@[\]\^_]|NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|\d+|o[0-7]+|x[0-9a-fA-F]+)|\\\s+\\)*"/,
greedy: true
},
'keyword' : /\b(case|class|data|deriving|do|else|if|in|infixl|infixr|instance|let|module|newtype|of|primitive|then|type|where)\b/,
'import_statement' : {
// The imported or hidden names are not included in this import
Expand Down
2 changes: 1 addition & 1 deletion components/prism-haskell.min.js

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

0 comments on commit 964450e

Please sign in to comment.