forked from circlecloud/tera
1
0
Fork 0
tera/src/HTML/JS/highlight.js

1 line
11 KiB
JavaScript
Raw Normal View History

!function(e) { var n = "object" == typeof window && window || "object" == typeof self && self; "undefined" != typeof exports ? e(exports) : n && (n.hljs = e({}), "function" == typeof define && define.amd && define([], function() { return n.hljs })) }(function(r) { var g = [], c = Object.keys, b = {}, o = {}, n = /^(no-?highlight|plain|text)$/i, l = /\blang(?:uage)?-([\w-]+)\b/i, t = /((^(<[^>]+>|\t|)+|(?:\n)))/gm, h = "</span>", R = { classPrefix: "hljs-", tabReplace: null, useBR: !1, languages: void 0 }; function _(e) { return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") } function f(e) { return e.nodeName.toLowerCase() } function N(e, n) { var t = e && e.exec(n); return t && 0 === t.index } function u(e) { return n.test(e) } function d(e) { var n, t = {}, a = Array.prototype.slice.call(arguments, 1); for (n in e) t[n] = e[n]; return a.forEach(function(e) { for (n in e) t[n] = e[n] }), t } function E(e) { var r = []; return function e(n, t) { for (var a = n.firstChild; a; a = a.nextSibling)3 === a.nodeType ? t += a.nodeValue.length : 1 === a.nodeType && (r.push({ event: "start", offset: t, node: a }), t = e(a, t), f(a).match(/br|hr|img|input/) || r.push({ event: "stop", offset: t, node: a })); return t }(e, 0), r } function w(s) { function o(e) { return e && e.source || e } function l(e, n) { return new RegExp(o(e), "m" + (s.case_insensitive ? "i" : "") + (n ? "g" : "")) } !function n(t, e) { if (!t.compiled) { if (t.compiled = !0, t.keywords = t.keywords || t.beginKeywords, t.keywords) { function a(t, e) { s.case_insensitive && (e = e.toLowerCase()), e.split(" ").forEach(function(e) { var n = e.split("|"); r[n[0]] = [t, n[1] ? Number(n[1]) : 1] }) } var r = {}; "string" == typeof t.keywords ? a("keyword", t.keywords) : c(t.keywords).forEach(function(e) { a(e, t.keywords[e]) }), t.keywords = r } t.lexemesRe = l(t.lexemes || /\w+/, !0), e && (t.beginKeywords && (t.begin = "\\b(" + t.beginKeywords.split(" ").join("|") + ")\\b"), t.begin || (t.begin = /\B|\b/), t.beginRe = l(t.begin), t.endSameAsBegin && (t.end = t.begin), t.end || t.endsWithParent || (t.end = /\B|\b/), t.end && (t.endRe = l(t.end)), t.terminator_end = o(t.end) || "", t.endsWithParent && e.terminator_end && (t.terminator_end += (t.end ? "|" : "") + e.terminator_end)), t.illegal && (t.illegalRe = l(t.illegal)), null == t.relevance && (t.relevance = 1), t.contains || (t.contains = []), t.contains = Array.prototype.concat.apply([], t.contains.map(function(e) { return function(n) { return n.variants && !n.cached_variants && (n.cached_variants = n.variants.map(function(e) { return d(n, { variants: null }, e) })), n.cached_variants || n.endsWithParent && [d(n)] || [n] }("self" === e ? t : e) })), t.contains.forEach(function(e) { n(e, t) }), t.starts && n(t.starts, e); var i = t.contains.map(function(e) { return e.beginKeywords ? "\\.?(" + e.begin + ")\\.?" : e.begin }).concat([t.terminator_end, t.illegal]).map(o).filter(Boolean); t.terminators = i.length ? l(i.join("|"), !0) : { exec: function() { return null } } } }(s) } function M(e, n, i, t) { function o(e, n, t, a) { var r = '<span class="' + (a ? "" : R.classPrefix); return (r += e + '">') + n + (t ? "" : h) } function s() { f += null != u.subLanguage ? function() { var e = "string" == typeof u.subLanguage; if (e && !b[u.subLanguage]) return _(d); var n = e ? M(u.subLanguage, d, !0, g[u.subLanguage]) : x(d, u.subLanguage.length ? u.subLanguage : void 0); return 0 < u.relevance && (E += n.relevance), e && (g[u.subLanguage] = n.top), o(n.language, n.value, !1, !0) }() : function() { var e, n, t, a, r, i, s; if (!u.keywords) return _(d); for (a = "", n = 0, u.lexemesRe.lastIndex = 0, t = u.lexemesRe.exec(d); t;)a += _(d.substring(n, t.index)), r = u, i = t, void 0, s = c.case_insensitive ? i[0].toLowerCase() : i[0], (e = r.keywords.hasOwnProperty(s) && r.keywords[s]) ? (E += e[1], a += o(e[0], _(t[0]))) : a += _(t[0]), n = u.lexemesRe.lastIndex, t = u.lexemesRe.exec(d); return a + _(d.substr(n)) }(), d = "" } function l(e) { f += e.className ? o(e.className, "", !0) : "", u = Object.cr