Twig: Prevent "other" pattern from matching blank strings
diff --git a/components/prism-twig.js b/components/prism-twig.js
index b2fc48f..7a8bacc 100644
--- a/components/prism-twig.js
+++ b/components/prism-twig.js
@@ -40,7 +40,8 @@ Prism.languages.twig = {
// The rest can be parsed as HTML
'other': {
- pattern: /[\s\S]*/,
+ // We want non-blank matches
+ pattern: /\S(?:[\s\S]*\S)?/,
inside: Prism.languages.markup
}
};
diff --git a/components/prism-twig.min.js b/components/prism-twig.min.js
index db8f500..0cea17f 100644
--- a/components/prism-twig.min.js
+++ b/components/prism-twig.min.js
@@ -1 +1 @@
-Prism.languages.twig={comment:/\{#[\s\S]*?#\}/,tag:{pattern:/(\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\})/,inside:{ld:{pattern:/^(\{\{\-?|\{%\-?\s*\w+)/,inside:{punctuation:/^(\{\{|\{%)\-?/,keyword:/\w+/}},rd:{pattern:/\-?(%\}|\}\})$/,inside:{punctuation:/.*/}},string:{pattern:/("|')(\\?.)*?\1/,inside:{punctuation:/^('|")|('|")$/}},keyword:/\b(if)\b/,"boolean":/\b(true|false|null)\b/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/==|=|!=|<|>|>=|<=|\+|\-|~|\*|\/|\/\/|%|\*\*|\|/,"space-operator":{pattern:/(\s)(\b(not|b\-and|b\-xor|b\-or|and|or|in|matches|starts with|ends with|is)\b|\?|:|\?:)(?=\s)/,lookbehind:!0,inside:{operator:/.*/}},property:/\b[a-zA-Z_][a-zA-Z0-9_]*\b/,punctuation:/\(|\)|\[\]|\[|\]|\{|\}|:|\.|,/}},other:{pattern:/[\s\S]*/,inside:Prism.languages.markup}};
\ No newline at end of file
+Prism.languages.twig={comment:/\{#[\s\S]*?#\}/,tag:{pattern:/(\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\})/,inside:{ld:{pattern:/^(\{\{\-?|\{%\-?\s*\w+)/,inside:{punctuation:/^(\{\{|\{%)\-?/,keyword:/\w+/}},rd:{pattern:/\-?(%\}|\}\})$/,inside:{punctuation:/.*/}},string:{pattern:/("|')(\\?.)*?\1/,inside:{punctuation:/^('|")|('|")$/}},keyword:/\b(if)\b/,"boolean":/\b(true|false|null)\b/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/==|=|!=|<|>|>=|<=|\+|\-|~|\*|\/|\/\/|%|\*\*|\|/,"space-operator":{pattern:/(\s)(\b(not|b\-and|b\-xor|b\-or|and|or|in|matches|starts with|ends with|is)\b|\?|:|\?:)(?=\s)/,lookbehind:!0,inside:{operator:/.*/}},property:/\b[a-zA-Z_][a-zA-Z0-9_]*\b/,punctuation:/\(|\)|\[\]|\[|\]|\{|\}|:|\.|,/}},other:{pattern:/\S(?:[\s\S]*\S)?/,inside:Prism.languages.markup}};
\ No newline at end of file