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

Unified Diff: lib/src/prism/components/prism-latex.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-keyman.min.js ('k') | lib/src/prism/components/prism-latex.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-latex.js
diff --git a/lib/src/prism/components/prism-latex.js b/lib/src/prism/components/prism-latex.js
index faeec076d744d63acefa3ffc7ffec8c1b6977dea..d736eadf4f1ad8ea9e9a54b95c7ac3d0a6597838 100644
--- a/lib/src/prism/components/prism-latex.js
+++ b/lib/src/prism/components/prism-latex.js
@@ -1,6 +1,61 @@
-Prism.languages.latex = {
- 'comment': /%.*?(\r?\n|$)$/m,
- 'string': /(\$)(\\?.)*?\1/,
- 'punctuation': /[{}]/,
- 'selector': /\\[a-z;,:\.]*/i
-};
+(function(Prism) {
+ var funcPattern = /\\([^a-z()[\]]|[a-z\*]+)/i,
+ insideEqu = {
+ 'equation-command': {
+ pattern: funcPattern,
+ alias: 'regex'
+ }
+ };
+
+ Prism.languages.latex = {
+ 'comment': /%.*/m,
+ // the verbatim environment prints whitespace to the document
+ 'cdata': {
+ pattern: /(\\begin\{((?:verbatim|lstlisting)\*?)\})([\w\W]*?)(?=\\end\{\2\})/,
+ lookbehind: true
+ },
+ /*
+ * equations can be between $ $ or \( \) or \[ \]
+ * (all are multiline)
+ */
+ 'equation': [
+ {
+ pattern: /\$(?:\\?[\w\W])*?\$|\\\((?:\\?[\w\W])*?\\\)|\\\[(?:\\?[\w\W])*?\\\]/,
+ inside: insideEqu,
+ alias: 'string'
+ },
+ {
+ pattern: /(\\begin\{((?:equation|math|eqnarray|align|multline|gather)\*?)\})([\w\W]*?)(?=\\end\{\2\})/,
+ lookbehind: true,
+ inside: insideEqu,
+ alias: 'string'
+ }
+ ],
+ /*
+ * arguments which are keywords or references are highlighted
+ * as keywords
+ */
+ 'keyword': {
+ pattern: /(\\(?:begin|end|ref|cite|label|usepackage|documentclass)(?:\[[^\]]+\])?\{)[^}]+(?=\})/,
+ lookbehind: true
+ },
+ 'url': {
+ pattern: /(\\url\{)[^}]+(?=\})/,
+ lookbehind: true
+ },
+ /*
+ * section or chapter headlines are highlighted as bold so that
+ * they stand out more
+ */
+ 'headline': {
+ pattern: /(\\(?:part|chapter|section|subsection|frametitle|subsubsection|paragraph|subparagraph|subsubparagraph|subsubsubparagraph)\*?(?:\[[^\]]+\])?\{)[^}]+(?=\}(?:\[[^\]]+\])?)/,
+ lookbehind: true,
+ alias: 'class-name'
+ },
+ 'function': {
+ pattern: funcPattern,
+ alias: 'selector'
+ },
+ 'punctuation': /[[\]{}&]/
+ };
+})(Prism);
« no previous file with comments | « lib/src/prism/components/prism-keyman.min.js ('k') | lib/src/prism/components/prism-latex.min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698