diff options
-rw-r--r-- | pelicanconf.py | 11 | ||||
-rw-r--r-- | themes/elenq/static/css/prism.css | 111 | ||||
-rw-r--r-- | themes/elenq/static/css/style.css | 26 | ||||
-rw-r--r-- | themes/elenq/static/js/prism.js | 1329 | ||||
-rw-r--r-- | themes/elenq/templates/base.html | 3 |
5 files changed, 1462 insertions, 18 deletions
diff --git a/pelicanconf.py b/pelicanconf.py index 8efbade..e0998c0 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -60,12 +60,17 @@ MENUITEMS = [("Home" , "/index.html"), ("Series", "/tags.html")] # Markdown extras MARKDOWN = { 'extension_configs': { + 'markdown.extensions.footnotes': {}, + 'markdown.extensions.tables': {}, 'markdown.extensions.codehilite': { 'css_class': 'highlight', - 'noclasses': True, + 'use_pygments': False, + # Pygments breaks the semantics of the HTML inserting `span` + # elements in a `pre` instead of a `pre` with `code` inside. + # The theme uses optional JS for this (prismjs.com), this way + # semantics are mantained. + # See also: https://github.com/getpelican/pelican/issues/2569 }, - 'markdown.extensions.footnotes': {}, - 'markdown.extensions.tables': {}, # optionally, more extensions, # e.g. markdown.extensions.meta }, diff --git a/themes/elenq/static/css/prism.css b/themes/elenq/static/css/prism.css new file mode 100644 index 0000000..cc87b8d --- /dev/null +++ b/themes/elenq/static/css/prism.css @@ -0,0 +1,111 @@ +/* PrismJS 1.16.0 +https://prismjs.com/download.html#themes=prism&languages=bash+clojure+latex+lisp+lua+makefile+perl+sql+python+scheme+yaml */ +/** + * prism.js default theme for JavaScript, CSS and HTML + * Based on dabblet (http://dabblet.com) + * @author Lea Verou + * + * Edited by Ekaitz Zarraga to make it fit in ElenQ Technology style. + */ + +code[class*="language-"], +pre[class*="language-"] { + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; + + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; +} + +@media print { + code[class*="language-"], + pre[class*="language-"] { + text-shadow: none; + } +} + +/* Code blocks */ +pre[class*="language-"] { + overflow: auto; +} + +:not(pre) > code[class*="language-"], +pre[class*="language-"] { + background: #f5f2f0; +} + +.token.comment, +.token.prolog, +.token.doctype, +.token.cdata { + color: slategray; +} + +.token.punctuation { + color: #999; +} + +.namespace { + opacity: .7; +} + +.token.property, +.token.tag, +.token.boolean, +.token.number, +.token.constant, +.token.symbol, +.token.deleted { + color: #905; +} + +.token.selector, +.token.attr-name, +.token.string, +.token.char, +.token.builtin, +.token.inserted { + color: #690; +} + +.token.operator, +.token.entity, +.token.url, +.language-css .token.string, +.style .token.string { + color: #9a6e3a; + background: hsla(0, 0%, 100%, .5); +} + +.token.atrule, +.token.attr-value, +.token.keyword { + color: #07a; +} + +.token.function, +.token.class-name { + color: #DD4A68; +} + +.token.regex, +.token.important, +.token.variable { + color: #e90; +} + +.token.important, +.token.bold { + font-weight: bold; +} +.token.italic { + font-style: italic; +} + +.token.entity { + cursor: help; +} + diff --git a/themes/elenq/static/css/style.css b/themes/elenq/static/css/style.css index c8efd73..3b52122 100644 --- a/themes/elenq/static/css/style.css +++ b/themes/elenq/static/css/style.css @@ -96,7 +96,7 @@ hr.short{ z-index: 99; border-top: 1px solid #eee; border-bottom: 1px solid #eee; - margin-bottom: 3ex; + margin-bottom: 6.5rem; } .navbar { width: 100%; @@ -125,22 +125,9 @@ hr.short{ } -/* Large devices everything inline and the header floating fixed on top +/* Large devices everything inline and the header floating */ @media (min-width: 801px) { - .mainheader{ - position: fixed; - height: 6.5rem; - } - - /* Push content down, because the header is floating over it */ - .content:before{ - display: block; - content: " "; - height: 10rem; - visibility: hidden; - } - .link-right { margin-left: 15px; margin-right: 0px; @@ -348,3 +335,12 @@ li{ font-style: normal; } } + + +/* Code rendering + */ +pre > code { + overflow: auto; + border: none; + border-radius: 0; +} diff --git a/themes/elenq/static/js/prism.js b/themes/elenq/static/js/prism.js new file mode 100644 index 0000000..c7c897f --- /dev/null +++ b/themes/elenq/static/js/prism.js @@ -0,0 +1,1329 @@ +/* PrismJS 1.16.0 +https://prismjs.com/download.html#themes=prism&languages=bash+clojure+latex+lisp+lua+makefile+perl+sql+python+scheme+yaml */ +var _self = (typeof window !== 'undefined') + ? window // if in browser + : ( + (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) + ? self // if in worker + : {} // if in node js + ); + +/** + * Prism: Lightweight, robust, elegant syntax highlighting + * MIT license http://www.opensource.org/licenses/mit-license.php/ + * @author Lea Verou http://lea.verou.me + */ + +var Prism = (function (_self){ + +// Private helper vars +var lang = /\blang(?:uage)?-([\w-]+)\b/i; +var uniqueId = 0; + +var _ = { + manual: _self.Prism && _self.Prism.manual, + disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, + util: { + encode: function (tokens) { + if (tokens instanceof Token) { + return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias); + } else if (Array.isArray(tokens)) { + return tokens.map(_.util.encode); + } else { + return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' '); + } + }, + + type: function (o) { + return Object.prototype.toString.call(o).slice(8, -1); + }, + + objId: function (obj) { + if (!obj['__id']) { + Object.defineProperty(obj, '__id', { value: ++uniqueId }); + } + return obj['__id']; + }, + + // Deep clone a language definition (e.g. to extend it) + clone: function deepClone(o, visited) { + var clone, id, type = _.util.type(o); + visited = visited || {}; + + switch (type) { + case 'Object': + id = _.util.objId(o); + if (visited[id]) { + return visited[id]; + } + clone = {}; + visited[id] = clone; + + for (var key in o) { + if (o.hasOwnProperty(key)) { + clone[key] = deepClone(o[key], visited); + } + } + + return clone; + + case 'Array': + id = _.util.objId(o); + if (visited[id]) { + return visited[id]; + } + clone = []; + visited[id] = clone; + + o.forEach(function (v, i) { + clone[i] = deepClone(v, visited); + }); + + return clone; + + default: + return o; + } + } + }, + + languages: { + extend: function (id, redef) { + var lang = _.util.clone(_.languages[id]); + + for (var key in redef) { + lang[key] = redef[key]; + } + + return lang; + }, + + /** + * Insert a token before another token in a language literal + * As this needs to recreate the object (we cannot actually insert before keys in object literals), + * we cannot just provide an object, we need an object and a key. + * @param inside The key (or language id) of the parent + * @param before The key to insert before. + * @param insert Object with the key/value pairs to insert + * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted. + */ + insertBefore: function (inside, before, insert, root) { + root = root || _.languages; + var grammar = root[inside]; + var ret = {}; + + for (var token in grammar) { + if (grammar.hasOwnProperty(token)) { + + if (token == before) { + for (var newToken in insert) { + if (insert.hasOwnProperty(newToken)) { + ret[newToken] = insert[newToken]; + } + } + } + + // Do not insert token which also occur in insert. See #1525 + if (!insert.hasOwnProperty(token)) { + ret[token] = grammar[token]; + } + } + } + + var old = root[inside]; + root[inside] = ret; + + // Update references in other language definitions + _.languages.DFS(_.languages, function(key, value) { + if (value === old && key != inside) { + this[key] = ret; + } + }); + + return ret; + }, + + // Traverse a language definition with Depth First Search + DFS: function DFS(o, callback, type, visited) { + visited = visited || {}; + + var objId = _.util.objId; + + for (var i in o) { + if (o.hasOwnProperty(i)) { + callback.call(o, i, o[i], type || i); + + var property = o[i], + propertyType = _.util.type(property); + + if (propertyType === 'Object' && !visited[objId(property)]) { + visited[objId(property)] = true; + DFS(property, callback, null, visited); + } + else if (propertyType === 'Array' && !visited[objId(property)]) { + visited[objId(property)] = true; + DFS(property, callback, i, visited); + } + } + } + } + }, + plugins: {}, + + highlightAll: function(async, callback) { + _.highlightAllUnder(document, async, callback); + }, + + highlightAllUnder: function(container, async, callback) { + var env = { + callback: callback, + selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code' + }; + + _.hooks.run("before-highlightall", env); + + var elements = env.elements || container.querySelectorAll(env.selector); + + for (var i=0, element; element = elements[i++];) { + _.highlightElement(element, async === true, env.callback); + } + }, + + highlightElement: function(element, async, callback) { + // Find language + var language = 'none', grammar, parent = element; + + while (parent && !lang.test(parent.className)) { + parent = parent.parentNode; + } + + if (parent) { + language = (parent.className.match(lang) || [,'none'])[1].toLowerCase(); + grammar = _.languages[language]; + } + + // Set language on the element, if not present + element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; + + if (element.parentNode) { + // Set language on the parent, for styling + parent = element.parentNode; + + if (/pre/i.test(parent.nodeName)) { + parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; + } + } + + var code = element.textContent; + + var env = { + element: element, + language: language, + grammar: grammar, + code: code + }; + + var insertHighlightedCode = function (highlightedCode) { + env.highlightedCode = highlightedCode; + + _.hooks.run('before-insert', env); + + env.element.innerHTML = env.highlightedCode; + + _.hooks.run('after-highlight', env); + _.hooks.run('complete', env); + callback && callback.call(env.element); + } + + _.hooks.run('before-sanity-check', env); + + if (!env.code) { + _.hooks.run('complete', env); + return; + } + + _.hooks.run('before-highlight', env); + + if (!env.grammar) { + insertHighlightedCode(_.util.encode(env.code)); + return; + } + + if (async && _self.Worker) { + var worker = new Worker(_.filename); + + worker.onmessage = function(evt) { + insertHighlightedCode(evt.data); + }; + + worker.postMessage(JSON.stringify({ + language: env.language, + code: env.code, + immediateClose: true + })); + } + else { + insertHighlightedCode(_.highlight(env.code, env.grammar, env.language)); + } + }, + + highlight: function (text, grammar, language) { + var env = { + code: text, + grammar: grammar, + language: language + }; + _.hooks.run('before-tokenize', env); + env.tokens = _.tokenize(env.code, env.grammar); + _.hooks.run('after-tokenize', env); + return Token.stringify(_.util.encode(env.tokens), env.language); + }, + + matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) { + for (var token in grammar) { + if(!grammar.hasOwnProperty(token) || !grammar[token]) { + continue; + } + + if (token == target) { + return; + } + + var patterns = grammar[token]; + patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns]; + + for (var j = 0; j < patterns.length; ++j) { + var pattern = patterns[j], + inside = pattern.inside, + lookbehind = !!pattern.lookbehind, + greedy = !!pattern.greedy, + lookbehindLength = 0, + alias = pattern.alias; + + if (greedy && !pattern.pattern.global) { + // Without the global flag, lastIndex won't work + var flags = pattern.pattern.toString().match(/[imuy]*$/)[0]; + pattern.pattern = RegExp(pattern.pattern.source, flags + "g"); + } + + pattern = pattern.pattern || pattern; + + // Don’t cache length as it changes during the loop + for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) { + + var str = strarr[i]; + + if (strarr.length > text.length) { + // Something went terribly wrong, ABORT, ABORT! + return; + } + + if (str instanceof Token) { + continue; + } + + if (greedy && i != strarr.length - 1) { + pattern.lastIndex = pos; + var match = pattern.exec(text); + if (!match) { + break; + } + + var from = match.index + (lookbehind ? match[1].length : 0), + to = match.index + match[0].length, + k = i, + p = pos; + + for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) { + p += strarr[k].length; + // Move the index i to the element in strarr that is closest to from + if (from >= p) { + ++i; + pos = p; + } + } + + // If strarr[i] is a Token, then the match starts inside another Token, which is invalid + if (strarr[i] instanceof Token) { + continue; + } + + // Number of tokens to delete and replace with the new match + delNum = k - i; + str = text.slice(pos, p); + match.index -= pos; + } else { + pattern.lastIndex = 0; + + var match = pattern.exec(str), + delNum = 1; + } + + if (!match) { + if (oneshot) { + break; + } + + continue; + } + + if(lookbehind) { + lookbehindLength = match[1] ? match[1].length : 0; + } + + var from = match.index + lookbehindLength, + match = match[0].slice(lookbehindLength), + to = from + match.length, + before = str.slice(0, from), + after = str.slice(to); + + var args = [i, delNum]; + + if (before) { + ++i; + pos += before.length; + args.push(before); + } + + var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy); + + args.push(wrapped); + + if (after) { + args.push(after); + } + + Array.prototype.splice.apply(strarr, args); + + if (delNum != 1) + _.matchGrammar(text, strarr, grammar, i, pos, true, token); + + if (oneshot) + break; + } + } + } + }, + + tokenize: function(text, grammar) { + var strarr = [text]; + + var rest = grammar.rest; + + if (rest) { + for (var token in rest) { + grammar[token] = rest[token]; + } + + delete grammar.rest; + } + + _.matchGrammar(text, strarr, grammar, 0, 0, false); + + return strarr; + }, + + hooks: { + all: {}, + + add: function (name, callback) { + var hooks = _.hooks.all; + + hooks[name] = hooks[name] || []; + + hooks[name].push(callback); + }, + + run: function (name, env) { + var callbacks = _.hooks.all[name]; + + if (!callbacks || !callbacks.length) { + return; + } + + for (var i=0, callback; callback = callbacks[i++];) { + callback(env); + } + } + }, + + Token: Token +}; + +_self.Prism = _; + +function Token(type, content, alias, matchedStr, greedy) { + this.type = type; + this.content = content; + this.alias = alias; + // Copy of the full string this token was created from + this.length = (matchedStr || "").length|0; + this.greedy = !!greedy; +} + +Token.stringify = function(o, language) { + if (typeof o == 'string') { + return o; + } + + if (Array.isArray(o)) { + return o.map(function(element) { + return Token.stringify(element, language); + }).join(''); + } + + var env = { + type: o.type, + content: Token.stringify(o.content, language), + tag: 'span', + classes: ['token', o.type], + attributes: {}, + language: language + }; + + if (o.alias) { + var aliases = Array.isArray(o.alias) ? o.alias : [o.alias]; + Array.prototype.push.apply(env.classes, aliases); + } + + _.hooks.run('wrap', env); + + var attributes = Object.keys(env.attributes).map(function(name) { + return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"'; + }).join(' '); + + return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>'; +}; + +if (!_self.document) { + if (!_self.addEventListener) { + // in Node.js + return _; + } + + if (!_.disableWorkerMessageHandler) { + // In worker + _self.addEventListener('message', function (evt) { + var message = JSON.parse(evt.data), + lang = message.language, + code = message.code, + immediateClose = message.immediateClose; + + _self.postMessage(_.highlight(code, _.languages[lang], lang)); + if (immediateClose) { + _self.close(); + } + }, false); + } + + return _; +} + +//Get current script and highlight +var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop(); + +if (script) { + _.filename = script.src; + + if (!_.manual && !script.hasAttribute('data-manual')) { + if(document.readyState !== "loading") { + if (window.requestAnimationFrame) { + window.requestAnimationFrame(_.highlightAll); + } else { + window.setTimeout(_.highlightAll, 16); + } + } + else { + document.addEventListener('DOMContentLoaded', _.highlightAll); + } + } +} + +return _; + +})(_self); + +if (typeof module !== 'undefined' && module.exports) { + module.exports = Prism; +} + +// hack for components to work correctly in node.js +if (typeof global !== 'undefined') { + global.Prism = Prism; +} +; +(function(Prism) { + var insideString = { + variable: [ + // Arithmetic Environment + { + pattern: /\$?\(\([\s\S]+?\)\)/, + inside: { + // If there is a $ sign at the beginning highlight $(( and )) as variable + variable: [{ + pattern: /(^\$\(\([\s\S]+)\)\)/, + lookbehind: true + }, + /^\$\(\(/ + ], + number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/, + // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic + operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/, + // If there is no $ sign at the beginning highlight (( and )) as punctuation + punctuation: /\(\(?|\)\)?|,|;/ + } + }, + // Command Substitution + { + pattern: /\$\([^)]+\)|`[^`]+`/, + greedy: true, + inside: { + variable: /^\$\(|^`|\)$|`$/ + } + }, + /\$(?:[\w#?*!@]+|\{[^}]+\})/i + ] + }; + + Prism.languages.bash = { + 'shebang': { + pattern: /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/, + alias: 'important' + }, + 'comment': { + pattern: /(^|[^"{\\])#.*/, + lookbehind: true + }, + 'string': [ + //Support for Here-Documents https://en.wikipedia.org/wiki/Here_document + { + pattern: /((?:^|[^<])<<\s*)["']?(\w+?)["']?\s*\r?\n(?:[\s\S])*?\r?\n\2/, + lookbehind: true, + greedy: true, + inside: insideString + }, + { + pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/, + greedy: true, + inside: insideString + } + ], + 'variable': insideString.variable, + // Originally based on http://ss64.com/bash/ + 'function': { + pattern: /(^|[\s;|&])(?:add|alias|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|hash|head|help|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logout|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tail|tar|tee|test|time|timeout|times|top|touch|tr|traceroute|trap|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zip|zypper)(?=$|[\s;|&])/, + lookbehind: true + }, + 'keyword': { + pattern: /(^|[\s;|&])(?:let|:|\.|if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)(?=$|[\s;|&])/, + lookbehind: true + }, + 'boolean': { + pattern: /(^|[\s;|&])(?:true|false)(?=$|[\s;|&])/, + lookbehind: true + }, + 'operator': /&&?|\|\|?|==?|!=?|<<<?|>>|<=?|>=?|=~/, + 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];]/ + }; + + var inside = insideString.variable[1].inside; + inside.string = Prism.languages.bash.string; + inside['function'] = Prism.languages.bash['function']; + inside.keyword = Prism.languages.bash.keyword; + inside['boolean'] = Prism.languages.bash['boolean']; + inside.operator = Prism.languages.bash.operator; + inside.punctuation = Prism.languages.bash.punctuation; + + Prism.languages.shell = Prism.languages.bash; +})(Prism); + +// Copied from https://github.com/jeluard/prism-clojure +Prism.languages.clojure = { + comment: /;+.*/, + string: /"(?:\\.|[^\\"\r\n])*"/, + operator: /(?:::|[:|'])\b[a-z][\w*+!?-]*\b/i, //used for symbols and keywords + keyword: { + pattern: /([^\w+*'?-])(?:def|if|do|let|\.\.|quote|var|->>|->|fn|loop|recur|throw|try|monitor-enter|\.|new|set!|def\-|defn|defn\-|defmacro|defmulti|defmethod|defstruct|defonce|declare|definline|definterface|defprotocol|==|defrecord|>=|deftype|<=|defproject|ns|\*|\+|\-|\/|<|=|>|accessor|agent|agent-errors|aget|alength|all-ns|alter|and|append-child|apply|array-map|aset|aset-boolean|aset-byte|aset-char|aset-double|aset-float|aset-int|aset-long|aset-short|assert|assoc|await|await-for|bean|binding|bit-and|bit-not|bit-or|bit-shift-left|bit-shift-right|bit-xor|boolean|branch\?|butlast|byte|cast|char|children|class|clear-agent-errors|comment|commute|comp|comparator|complement|concat|conj|cons|constantly|cond|if-not|construct-proxy|contains\?|count|create-ns|create-struct|cycle|dec|deref|difference|disj|dissoc|distinct|doall|doc|dorun|doseq|dosync|dotimes|doto|double|down|drop|drop-while|edit|end\?|ensure|eval|every\?|false\?|ffirst|file-seq|filter|find|find-doc|find-ns|find-var|first|float|flush|for|fnseq|frest|gensym|get-proxy-class|get|hash-map|hash-set|identical\?|identity|if-let|import|in-ns|inc|index|insert-child|insert-left|insert-right|inspect-table|inspect-tree|instance\?|int|interleave|intersection|into|into-array|iterate|join|key|keys|keyword|keyword\?|last|lazy-cat|lazy-cons|left|lefts|line-seq|list\*|list|load|load-file|locking|long|loop|macroexpand|macroexpand-1|make-array|make-node|map|map-invert|map\?|mapcat|max|max-key|memfn|merge|merge-with|meta|min|min-key|name|namespace|neg\?|new|newline|next|nil\?|node|not|not-any\?|not-every\?|not=|ns-imports|ns-interns|ns-map|ns-name|ns-publics|ns-refers|ns-resolve|ns-unmap|nth|nthrest|or|parse|partial|path|peek|pop|pos\?|pr|pr-str|print|print-str|println|println-str|prn|prn-str|project|proxy|proxy-mappings|quot|rand|rand-int|range|re-find|re-groups|re-matcher|re-matches|re-pattern|re-seq|read|read-line|reduce|ref|ref-set|refer|rem|remove|remove-method|remove-ns|rename|rename-keys|repeat|replace|replicate|resolve|rest|resultset-seq|reverse|rfirst|right|rights|root|rrest|rseq|second|select|select-keys|send|send-off|seq|seq-zip|seq\?|set|short|slurp|some|sort|sort-by|sorted-map|sorted-map-by|sorted-set|special-symbol\?|split-at|split-with|str|string\?|struct|struct-map|subs|subvec|symbol|symbol\?|sync|take|take-nth|take-while|test|time|to-array|to-array-2d|tree-seq|true\?|union|up|update-proxy|val|vals|var-get|var-set|var\?|vector|vector-zip|vector\?|when|when-first|when-let|when-not|with-local-vars|with-meta|with-open|with-out-str|xml-seq|xml-zip|zero\?|zipmap|zipper)(?=[^\w+*'?-])/, + lookbehind: true + }, + boolean: /\b(?:true|false|nil)\b/, + number: /\b[0-9A-Fa-f]+\b/, + punctuation: /[{}\[\](),]/ +}; + +(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)\*?)\})[\s\S]*?(?=\\end\{\2\})/, + lookbehind: true + }, + /* + * equations can be between $ $ or \( \) or \[ \] + * (all are multiline) + */ + 'equation': [ + { + pattern: /\$(?:\\[\s\S]|[^\\$])*\$|\\\([\s\S]*?\\\)|\\\[[\s\S]*?\\\]/, + inside: insideEqu, + alias: 'string' + }, + { + pattern: /(\\begin\{((?:equation|math|eqnarray|align|multline|gather)\*?)\})[\s\S]*?(?=\\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); + +(function (Prism) { + // Functions to construct regular expressions + // simple form + // e.g. (interactive ... or (interactive) + function simple_form(name) { + return RegExp('(\\()' + name + '(?=[\\s\\)])'); + } + // booleans and numbers + function primitive(pattern) { + return RegExp('([\\s([])' + pattern + '(?=[\\s)])'); + } + + // Patterns in regular expressions + + // Symbol name. See https://www.gnu.org/software/emacs/manual/html_node/elisp/Symbol-Type.html + // & and : are excluded as they are usually used for special purposes + var symbol = '[-+*/_~!@$%^=<>{}\\w]+'; + // symbol starting with & used in function arguments + var marker = '&' + symbol; + // Open parenthesis for look-behind + var par = '(\\()'; + var endpar = '(?=\\))'; + // End the pattern with look-ahead space + var space = '(?=\\s)'; + + var language = { + // Three or four semicolons are considered a heading. + // See https://www.gnu.org/software/emacs/manual/html_node/elisp/Comment-Tips.html + heading: { + pattern: /;;;.*/, + alias: ['comment', 'title'] + }, + comment: /;.*/, + string: { + pattern: /"(?:[^"\\]|\\.)*"/, + greedy: true, + inside: { + argument: /[-A-Z]+(?=[.,\s])/, + symbol: RegExp('`' + symbol + "'") + } + }, + 'quoted-symbol': { + pattern: RegExp("#?'" + symbol), + alias: ['variable', 'symbol'] + }, + 'lisp-property': { + pattern: RegExp(':' + symbol), + alias: 'property' + }, + splice: { + pattern: RegExp(',@?' + symbol), + alias: ['symbol', 'variable'] + }, + keyword: [ + { + pattern: RegExp( + par + + '(?:(?:lexical-)?let\\*?|(?:cl-)?letf|if|when|while|unless|cons|cl-loop|and|or|not|cond|setq|error|message|null|require|provide|use-package)' + + space + ), + lookbehind: true + }, + { + pattern: RegExp( + par + '(?:for|do|collect|return|finally|append|concat|in|by)' + space + ), + lookbehind: true + }, + ], + declare: { + pattern: simple_form('declare'), + lookbehind: true, + alias: 'keyword' + }, + interactive: { + pattern: simple_form('interactive'), + lookbehind: true, + alias: 'keyword' + }, + boolean: { + pattern: primitive('(?:t|nil)'), + lookbehind: true + }, + number: { + pattern: primitive('[-+]?\\d+(?:\\.\\d*)?'), + lookbehind: true + }, + defvar: { + pattern: RegExp(par + 'def(?:var|const|custom|group)\\s+' + symbol), + lookbehind: true, + inside: { + keyword: /^def[a-z]+/, + variable: RegExp(symbol) + } + }, + defun: { + pattern: RegExp( + par + + '(?:cl-)?(?:defun\\*?|defmacro)\\s+' + + symbol + + '\\s+\\([\\s\\S]*?\\)' + ), + lookbehind: true, + inside: { + keyword: /^(?:cl-)?def\S+/, + // See below, this property needs to be defined later so that it can + // reference the language object. + arguments: null, + function: { + pattern: RegExp('(^\\s)' + symbol), + lookbehind: true + }, + punctuation: /[()]/ + } + }, + lambda: { + pattern: RegExp(par + 'lambda\\s+\\((?:&?' + symbol + '\\s*)*\\)'), + lookbehind: true, + inside: { + keyword: /^lambda/, + // See below, this property needs to be defined later so that it can + // reference the language object. + arguments: null, + punctuation: /[()]/ + } + }, + car: { + pattern: RegExp(par + symbol), + lookbehind: true + }, + punctuation: [ + // open paren, brackets, and close paren + /(['`,]?\(|[)\[\]])/, + // cons + { + pattern: /(\s)\.(?=\s)/, + lookbehind: true + }, + ] + }; + + var arg = { + 'lisp-marker': RegExp(marker), + rest: { + argument: { + pattern: RegExp(symbol), + alias: 'variable' + }, + varform: { + pattern: RegExp(par + symbol + '\\s+\\S[\\s\\S]*' + endpar), + lookbehind: true, + inside: { + string: language.string, + boolean: language.boolean, + number: language.number, + symbol: language.symbol, + punctuation: /[()]/ + } + } + } + }; + + var forms = '\\S+(?:\\s+\\S+)*'; + + var arglist = { + pattern: RegExp(par + '[\\s\\S]*' + endpar), + lookbehind: true, + inside: { + 'rest-vars': { + pattern: RegExp('&(?:rest|body)\\s+' + forms), + inside: arg + }, + 'other-marker-vars': { + pattern: RegExp('&(?:optional|aux)\\s+' + forms), + inside: arg + }, + keys: { + pattern: RegExp('&key\\s+' + forms + '(?:\\s+&allow-other-keys)?'), + inside: arg + }, + argument: { + pattern: RegExp(symbol), + alias: 'variable' + }, + punctuation: /[()]/ + } + }; + + language['lambda'].inside.arguments = arglist; + language['defun'].inside.arguments = Prism.util.clone(arglist); + language['defun'].inside.arguments.inside.sublist = arglist; + + Prism.languages.lisp = language; + Prism.languages.elisp = language; + Prism.languages.emacs = language; + Prism.languages['emacs-lisp'] = language; +}(Prism)); + +Prism.languages.lua = { + 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m, + // \z may be used to skip the following space + 'string': { + pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/, + greedy: true + }, + 'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i, + 'keyword': /\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/, + 'function': /(?!\d)\w+(?=\s*(?:[({]))/, + 'operator': [ + /[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/, + { + // Match ".." but don't break "..." + pattern: /(^|[^.])\.\.(?!\.)/, + lookbehind: true + } + ], + 'punctuation': /[\[\](){},;]|\.+|:+/ +}; +Prism.languages.makefile = { + 'comment': { + pattern: /(^|[^\\])#(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/, + lookbehind: true + }, + 'string': { + pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + greedy: true + }, + + // Built-in target names + 'builtin': /\.[A-Z][^:#=\s]+(?=\s*:(?!=))/, + + // Targets + 'symbol': { + pattern: /^[^:=\r\n]+(?=\s*:(?!=))/m, + inside: { + 'variable': /\$+(?:[^(){}:#=\s]+|(?=[({]))/ + } + }, + 'variable': /\$+(?:[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/, + + 'keyword': [ + // Directives + /-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/, + // Functions + { + pattern: /(\()(?:addsuffix|abspath|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:s|list)?)(?=[ \t])/, + lookbehind: true + } + ], + 'operator': /(?:::|[?:+!])?=|[|@]/, + 'punctuation': /[:;(){}]/ +}; +Prism.languages.perl = { + 'comment': [ + { + // POD + pattern: /(^\s*)=\w+[\s\S]*?=cut.*/m, + lookbehind: true + }, + { + pattern: /(^|[^\\$])#.*/, + lookbehind: true + } + ], + // TODO Could be nice to handle Heredoc too. + 'string': [ + // q/.../ + { + pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/, + greedy: true + }, + + // q a...a + { + pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/, + greedy: true + }, + + // q(...) + { + pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/, + greedy: true + }, + + // q{...} + { + pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/, + greedy: true + }, + + // q[...] + { + pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/, + greedy: true + }, + + // q<...> + { + pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/, + greedy: true + }, + + // "...", `...` + { + pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/, + greedy: true + }, + + // '...' + // FIXME Multi-line single-quoted strings are not supported as they would break variables containing ' + { + pattern: /'(?:[^'\\\r\n]|\\.)*'/, + greedy: true + } + ], + 'regex': [ + // m/.../ + { + pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/, + greedy: true + }, + + // m a...a + { + pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/, + greedy: true + }, + + // m(...) + { + pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/, + greedy: true + }, + + // m{...} + { + pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/, + greedy: true + }, + + // m[...] + { + pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/, + greedy: true + }, + + // m<...> + { + pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/, + greedy: true + }, + + // The lookbehinds prevent -s from breaking + // FIXME We don't handle change of separator like s(...)[...] + // s/.../.../ + { + pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/, + lookbehind: true, + greedy: true + }, + + // s a...a...a + { + pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/, + lookbehind: true, + greedy: true + }, + + // s(...)(...) + { + pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/, + lookbehind: true, + greedy: true + }, + + // s{...}{...} + { + pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/, + lookbehind: true, + greedy: true + }, + + // s[...][...] + { + pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/, + lookbehind: true, + greedy: true + }, + + // s<...><...> + { + pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/, + lookbehind: true, + greedy: true + }, + + // /.../ + // The look-ahead tries to prevent two divisions on + // the same line from being highlighted as regex. + // This does not support multi-line regex. + { + pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/, + greedy: true + } + ], + + // FIXME Not sure about the handling of ::, ', and # + 'variable': [ + // ${^POSTMATCH} + /[&*$@%]\{\^[A-Z]+\}/, + // $^V + /[&*$@%]\^[A-Z_]/, + // ${...} + /[&*$@%]#?(?=\{)/, + // $foo + /[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+)+(?:::)*/i, + // $1 + /[&*$@%]\d+/, + // $_, @_, %! + // The negative lookahead prevents from breaking the %= operator + /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/ + ], + 'filehandle': { + // <>, <FOO>, _ + pattern: /<(?![<=])\S*>|\b_\b/, + alias: 'symbol' + }, + 'vstring': { + // v1.2, 1.2.3 + pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/, + alias: 'string' + }, + 'function': { + pattern: /sub [a-z0-9_]+/i, + inside: { + keyword: /sub/ + } + }, + 'keyword': /\b(?:any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|say|state|sub|switch|undef|unless|until|use|when|while)\b/, + 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/, + 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/, + 'punctuation': /[{}[\];(),:]/ +}; + +Prism.languages.sql = { + 'comment': { + pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/, + lookbehind: true + }, + 'variable': [ + { + pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/, + greedy: true + }, + /@[\w.$]+/ + ], + 'string': { + pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/, + greedy: true, + lookbehind: true + }, + 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too? + 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i, + 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i, + 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i, + 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i, + 'punctuation': /[;[\]()`,.]/ +}; + +Prism.languages.python = { + 'comment': { + pattern: /(^|[^\\])#.*/, + lookbehind: true + }, + 'string-interpolation': { + pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i, + greedy: true, + inside: { + 'interpolation': { + // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}" + pattern: /((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/, + lookbehind: true, + inside: { + 'format-spec': { + pattern: /(:)[^:(){}]+(?=}$)/, + lookbehind: true + }, + 'conversion-option': { + pattern: /![sra](?=[:}]$)/, + alias: 'punctuation' + }, + rest: null + } + }, + 'string': /[\s\S]+/ + } + }, + 'triple-quoted-string': { + pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i, + greedy: true, + alias: 'string' + }, + 'string': { + pattern: /(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i, + greedy: true + }, + 'function': { + pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g, + lookbehind: true + }, + 'class-name': { + pattern: /(\bclass\s+)\w+/i, + lookbehind: true + }, + 'decorator': { + pattern: /(^\s*)@\w+(?:\.\w+)*/i, + lookbehind: true, + alias: ['annotation', 'punctuation'], + inside: { + 'punctuation': /\./ + } + }, + 'keyword': /\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/, + 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/, + 'boolean': /\b(?:True|False|None)\b/, + 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i, + 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/, + 'punctuation': /[{}[\];(),.:]/ +}; + +Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python; + +Prism.languages.py = Prism.languages.python; +Prism.languages.scheme = { + 'comment': /;.*/, + 'string': { + pattern: /"(?:[^"\\]|\\.)*"|'[^()#'\s]+/, + greedy: true + }, + 'character': { + pattern: /#\\(?:[ux][a-fA-F\d]+|[a-zA-Z]+|\S)/, + alias: 'string' + }, + 'keyword': { + pattern: /(\()(?:define(?:-syntax|-library|-values)?|(?:case-)?lambda|let(?:\*|rec)?(?:-values)?|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-rules)(?=[()\s])/, + lookbehind: true + }, + 'builtin': { + pattern: /(\()(?:(?:cons|car|cdr|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?)(?=[()\s])/, + lookbehind: true + }, + 'number': { + pattern: /([\s()])[-+]?\d*\.?\d+(?:\s*[-+]\s*\d*\.?\d+i)?\b/, + lookbehind: true + }, + 'boolean': /#[tf]/, + 'operator': { + pattern: /(\()(?:[-+*%\/]|[<>]=?|=>?)(?=\s|$)/, + lookbehind: true + }, + 'function': { + pattern: /(\()[^()'\s]+(?=[()\s)]|$)/, + lookbehind: true + }, + 'punctuation': /[()']/ +}; + +Prism.languages.yaml = { + 'scalar': { + pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/, + lookbehind: true, + alias: 'string' + }, + 'comment': /#.*/, + 'key': { + pattern: /(\s*(?:^|[:\-,[{\r\n?])[ \t]*(?:![^\s]+)?[ \t]*)[^\r\n{[\]},#\s]+?(?=\s*:\s)/, + lookbehind: true, + alias: 'atrule' + }, + 'directive': { + pattern: /(^[ \t]*)%.+/m, + lookbehind: true, + alias: 'important' + }, + 'datetime': { + pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?)?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?)(?=[ \t]*(?:$|,|]|}))/m, + lookbehind: true, + alias: 'number' + }, + 'boolean': { + pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:true|false)[ \t]*(?=$|,|]|})/im, + lookbehind: true, + alias: 'important' + }, + 'null': { + pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:null|~)[ \t]*(?=$|,|]|})/im, + lookbehind: true, + alias: 'important' + }, + 'string': { + pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)("|')(?:(?!\2)[^\\\r\n]|\\.)*\2(?=[ \t]*(?:$|,|]|}|\s*#))/m, + lookbehind: true, + greedy: true + }, + 'number': { + pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im, + lookbehind: true + }, + 'tag': /![^\s]+/, + 'important': /[&*][\w]+/, + 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./ +}; + +Prism.languages.yml = Prism.languages.yaml; diff --git a/themes/elenq/templates/base.html b/themes/elenq/templates/base.html index 7d64a88..ba621d7 100644 --- a/themes/elenq/templates/base.html +++ b/themes/elenq/templates/base.html @@ -35,6 +35,9 @@ <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/css/skeleton.css"> <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/css/style.css"> <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/css/fonts.css"> + <link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/css/prism.css"> + + <script type="text/javascript" async src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/js/prism.js"></script> </head> <body id="index" class="home"> |