From 3426ed163d3b95cf7d0a856291a730b6b5eaea66 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 9 Sep 2017 11:47:23 +0200 Subject: [PATCH] C-like: Add support for unclosed block comments. Close #828 --- components/prism-clike.js | 2 +- components/prism-clike.min.js | 2 +- prism.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-clike.js b/components/prism-clike.js index 9843e2c635..e68a3f471c 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -1,7 +1,7 @@ Prism.languages.clike = { 'comment': [ { - pattern: /(^|[^\\])\/\*[\s\S]*?\*\//, + pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: true }, { diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index eba228c92e..f262555fb6 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+\())[a-z0-9_\.\\]+/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:/(^|[^\\])\/\*[\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+\())[a-z0-9_\.\\]+/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 26d6a622b5..21f593d612 100644 --- a/prism.js +++ b/prism.js @@ -657,7 +657,7 @@ if (Prism.languages.markup) { Prism.languages.clike = { 'comment': [ { - pattern: /(^|[^\\])\/\*[\s\S]*?\*\//, + pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: true }, {