From 5e231609ddfe91f0874f8ec1dd61f1b02abc534e Mon Sep 17 00:00:00 2001 From: Ekaitz Zárraga Date: Thu, 30 May 2019 20:54:57 +0200 Subject: add prism for clike languages --- themes/elenq/static/js/prism.js | 54 +++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'themes/elenq/static') diff --git a/themes/elenq/static/js/prism.js b/themes/elenq/static/js/prism.js index c7c897f..b28c749 100644 --- a/themes/elenq/static/js/prism.js +++ b/themes/elenq/static/js/prism.js @@ -1,5 +1,5 @@ /* PrismJS 1.16.0 -https://prismjs.com/download.html#themes=prism&languages=bash+clojure+latex+lisp+lua+makefile+perl+sql+python+scheme+yaml */ +https://prismjs.com/download.html#themes=prism&languages=clike+bash+clojure+latex+lisp+lua+makefile+perl+sql+python+scheme+yaml */ var _self = (typeof window !== 'undefined') ? window // if in browser : ( @@ -552,6 +552,37 @@ if (typeof global !== 'undefined') { global.Prism = Prism; } ; +Prism.languages.clike = { + 'comment': [ + { + pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, + lookbehind: true + }, + { + pattern: /(^|[^\\:])\/\/.*/, + lookbehind: true, + greedy: true + } + ], + 'string': { + pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + greedy: true + }, + 'class-name': { + pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i, + lookbehind: true, + 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': /\w+(?=\()/, + 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, + 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, + 'punctuation': /[{}[\];(),.:]/ +}; + (function(Prism) { var insideString = { variable: [ @@ -651,19 +682,19 @@ Prism.languages.clojure = { punctuation: /[{}\[\](),]/ }; -(function(Prism) { - var funcPattern = /\\(?:[^a-z()[\]]|[a-z*]+)/i, - insideEqu = { - 'equation-command': { - pattern: funcPattern, - alias: 'regex' - } - }; +(function (Prism) { + var funcPattern = /\\(?:[^a-z()[\]]|[a-z*]+)/i; + var insideEqu = { + 'equation-command': { + pattern: funcPattern, + alias: 'regex' + } + }; Prism.languages.latex = { 'comment': /%.*/m, // the verbatim environment prints whitespace to the document - 'cdata': { + 'cdata': { pattern: /(\\begin\{((?:verbatim|lstlisting)\*?)\})[\s\S]*?(?=\\end\{\2\})/, lookbehind: true }, @@ -711,6 +742,9 @@ Prism.languages.clojure = { }, 'punctuation': /[[\]{}&]/ }; + + Prism.languages.tex = Prism.languages.latex; + Prism.languages.context = Prism.languages.latex; })(Prism); (function (Prism) { -- cgit v1.2.3