Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: lib/src/prism/components/prism-smarty.js

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/prism/components/prism-smalltalk.min.js ('k') | lib/src/prism/components/prism-smarty.min.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « lib/src/prism/components/prism-smalltalk.min.js ('k') | lib/src/prism/components/prism-smarty.min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698