Index: lib/src/prism/components/prism-smarty.js |
diff --git a/lib/src/prism/components/prism-smarty.js b/lib/src/prism/components/prism-smarty.js |
index a38049cc9b3e80ef1f6f7239e92c4f3c33c56501..c013796569ac8bc0ff200f8df56fd272de9a6e2f 100644 |
--- a/lib/src/prism/components/prism-smarty.js |
+++ b/lib/src/prism/components/prism-smarty.js |
@@ -18,8 +18,8 @@ |
pattern: /^\{|\}$/i, |
alias: 'punctuation' |
}, |
- 'string': /(["'])(\\?.)*?\1/, |
- 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/, |
+ 'string': /(["'])(?:\\?.)*?\1/, |
+ 'number': /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee][-+]?\d+)?)\b/, |
'variable': [ |
/\$(?!\d)\w+/, |
/#(?!\d)\w+#/, |
@@ -48,12 +48,14 @@ |
pattern: /(=\s*)(?!\d)\w+/, |
lookbehind: true |
}, |
- "punctuation": /=/ |
+ "operator": /=/ |
} |
}, |
- 'punctuation': /[\[\]().,=\|:`]|\->/, |
+ 'punctuation': [ |
+ /[\[\]().,:`]|\->/ |
+ ], |
'operator': [ |
- /[+\-*\/%]|===?|[!<>]=?|&&|\|\|/, |
+ /[+\-*\/%]|==?=?|[!<>]=?|&&|\|\|?/, |
/\bis\s+(?:not\s+)?(?:div|even|odd)(?:\s+by)?\b/, |
/\b(?:eq|neq?|gt|lt|gt?e|lt?e|not|mod|or|and)\b/ |
], |
@@ -115,7 +117,8 @@ |
} |
for (var i = 0, t; t = env.tokenStack[i]; i++) { |
- env.highlightedCode = env.highlightedCode.replace('___SMARTY' + (i + 1) + '___', Prism.highlight(t, env.grammar, 'smarty')); |
+ // The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns |
+ env.highlightedCode = env.highlightedCode.replace('___SMARTY' + (i + 1) + '___', Prism.highlight(t, env.grammar, 'smarty').replace(/\$/g, '$$$$')); |
} |
env.element.innerHTML = env.highlightedCode; |