diff --git a/components/prism-clike.js b/components/prism-clike.js index c0b8ff53f4..a0644da15d 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -1,12 +1,13 @@ Prism.languages.clike = { 'comment': [ { - pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, + pattern: /(^|[^\\:])\/\/.*/, lookbehind: true }, { - pattern: /(^|[^\\:])\/\/.*/, - lookbehind: true + pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, + lookbehind: true, + greedy: true } ], 'string': { diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index 540e2c7370..903b83063d 100644 --- a/components/prism-clike.min.js +++ b/components/prism-clike.min.js @@ -1 +1 @@ -Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(?:true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.clike={comment:[{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0},{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(?:true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file diff --git a/prism.js b/prism.js index 929cfcef1e..49481c7233 100644 --- a/prism.js +++ b/prism.js @@ -669,12 +669,13 @@ if (Prism.languages.markup) { Prism.languages.clike = { 'comment': [ { - pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, + pattern: /(^|[^\\:])\/\/.*/, lookbehind: true }, { - pattern: /(^|[^\\:])\/\/.*/, - lookbehind: true + pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, + lookbehind: true, + greedy: true } ], 'string': {