HackMD/public/vendor/highlight-js/highlight.min.js

2 lines
35 KiB
JavaScript
Raw Normal View History

2015-07-01 16:10:20 +00:00
!function(e){"undefined"!=typeof exports?e(exports):(window.hljs=e({}),"function"==typeof define&&define.amd&&define("hljs",[],function(){return window.hljs}))}(function(e){function t(e){return e.replace(/&/gm,"&amp;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;")}function r(e){return e.nodeName.toLowerCase()}function n(e,t){var r=e&&e.exec(t);return r&&0==r.index}function a(e){return/no-?highlight|plain|text/.test(e)}function s(e){var t,r,n,s=e.className+" ";if(s+=e.parentNode?e.parentNode.className:"",r=/\blang(?:uage)?-([\w-]+)\b/.exec(s))return N(r[1])?r[1]:"no-highlight";for(s=s.split(/\s+/),t=0,n=s.length;n>t;t++)if(N(s[t])||a(s[t]))return s[t]}function i(e,t){var r,n={};for(r in e)n[r]=e[r];if(t)for(r in t)n[r]=t[r];return n}function c(e){var t=[];return function n(e,a){for(var s=e.firstChild;s;s=s.nextSibling)3==s.nodeType?a+=s.nodeValue.length:1==s.nodeType&&(t.push({event:"start",offset:a,node:s}),a=n(s,a),r(s).match(/br|hr|img|input/)||t.push({event:"stop",offset:a,node:s}));return a}(e,0),t}function o(e,n,a){function s(){return e.length&&n.length?e[0].offset!=n[0].offset?e[0].offset<n[0].offset?e:n:"start"==n[0].event?e:n:e.length?e:n}function i(e){function n(e){return" "+e.nodeName+'="'+t(e.value)+'"'}u+="<"+r(e)+Array.prototype.map.call(e.attributes,n).join("")+">"}function c(e){u+="</"+r(e)+">"}function o(e){("start"==e.event?i:c)(e.node)}for(var l=0,u="",d=[];e.length||n.length;){var b=s();if(u+=t(a.substr(l,b[0].offset-l)),l=b[0].offset,b==e){d.reverse().forEach(c);do o(b.splice(0,1)[0]),b=s();while(b==e&&b.length&&b[0].offset==l);d.reverse().forEach(i)}else"start"==b[0].event?d.push(b[0].node):d.pop(),o(b.splice(0,1)[0])}return u+t(a.substr(l))}function l(e){function t(e){return e&&e.source||e}function r(r,n){return new RegExp(t(r),"m"+(e.cI?"i":"")+(n?"g":""))}function n(a,s){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var c={},o=function(t,r){e.cI&&(r=r.toLowerCase()),r.split(" ").forEach(function(e){var r=e.split("|");c[r[0]]=[t,r[1]?Number(r[1]):1]})};"string"==typeof a.k?o("keyword",a.k):Object.keys(a.k).forEach(function(e){o(e,a.k[e])}),a.k=c}a.lR=r(a.l||/\b\w+\b/,!0),s&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=r(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=r(a.e)),a.tE=t(a.e)||"",a.eW&&s.tE&&(a.tE+=(a.e?"|":"")+s.tE)),a.i&&(a.iR=r(a.i)),void 0===a.r&&(a.r=1),a.c||(a.c=[]);var l=[];a.c.forEach(function(e){e.v?e.v.forEach(function(t){l.push(i(e,t))}):l.push("self"==e?a:e)}),a.c=l,a.c.forEach(function(e){n(e,a)}),a.starts&&n(a.starts,s);var u=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(t).filter(Boolean);a.t=u.length?r(u.join("|"),!0):{exec:function(){return null}}}}n(e)}function u(e,r,a,s){function i(e,t){for(var r=0;r<t.c.length;r++)if(n(t.c[r].bR,e))return t.c[r]}function c(e,t){if(n(e.eR,t)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?c(e.parent,t):void 0}function o(e,t){return!a&&n(t.iR,e)}function b(e,t){var r=v.cI?t[0].toLowerCase():t[0];return e.k.hasOwnProperty(r)&&e.k[r]}function p(e,t,r,n){var a=n?"":w.classPrefix,s='<span class="'+a,i=r?"":"</span>";return s+=e+'">',s+t+i}function f(){if(!x.k)return t(E);var e="",r=0;x.lR.lastIndex=0;for(var n=x.lR.exec(E);n;){e+=t(E.substr(r,n.index-r));var a=b(x,n);a?(B+=a[1],e+=p(a[0],t(n[0]))):e+=t(n[0]),r=x.lR.lastIndex,n=x.lR.exec(E)}return e+t(E.substr(r))}function g(){if(x.sL&&!y[x.sL])return t(E);var e=x.sL?u(x.sL,E,!0,C[x.sL]):d(E);return x.r>0&&(B+=e.r),"continuous"==x.subLanguageMode&&(C[x.sL]=e.top),p(e.language,e.value,!1,!0)}function m(){return void 0!==x.sL?g():f()}function h(e,r){var n=e.cN?p(e.cN,"",!0):"";e.rB?(M+=n,E=""):e.eB?(M+=t(r)+n,E=""):(M+=n,E=r),x=Object.create(e,{parent:{value:x}})}function _(e,r){if(E+=e,void 0===r)return M+=m(),0;var n=i(r,x);if(n)return M+=m(),h(n,r),n.rB?0:r.length;var a=c(x,r);if(a){var s=x;s.rE||s.eE||(E+=r),M+=m();do x.cN&&(M+="</span>"),B+=x.r,x=x.parent;while(x!=a.parent);return s.eE&&(M+=t(r)),E="",a.starts&&h(a.starts,""),s.rE?0:r.length}if(o(r,x))throw new Error('Illegal lexeme "'+r+'" for mode "'+(x.cN||"
literal:"true false null",built_in:"array bigint binary bit blob boolean char character date dec decimal float int integer interval number numeric real serial smallint varchar varying int8 serial8 text"},c:[{cN:"string",b:"'",e:"'",c:[e.BE,{b:"''"}]},{cN:"string",b:'"',e:'"',c:[e.BE,{b:'""'}]},{cN:"string",b:"`",e:"`",c:[e.BE]},e.CNM,e.CBCM,t]},e.CBCM,t]}}),e});