mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-30 06:16:54 +01:00
1 line
99 KiB
JavaScript
1 line
99 KiB
JavaScript
|
var hljs=function(){"use strict";var l,c,o;function p(a){Object.freeze(a);var b="function"==typeof a;return Object.getOwnPropertyNames(a).forEach(function(c){!Object.hasOwnProperty.call(a,c)||null===a[c]||"object"!=typeof a[c]&&"function"!=typeof a[c]||b&&("caller"===c||"callee"===c||"arguments"===c)||Object.isFrozen(a[c])||p(a[c])}),a}class n{constructor(a){void 0===a.data&&(a.data={}),this.data=a.data}ignoreMatch(){this.ignore=!0}}function b(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function a(b,...c){var a={};for(const c in b)a[c]=b[c];return c.forEach(function(b){for(const c in b)a[c]=b[c]}),a}function h(a){return a.nodeName.toLowerCase()}l=Object.freeze({__proto__:null,escapeHTML:b,inherit:a,nodeStream:function(b){var a=[];return function d(e,c){for(var b=e.firstChild;b;b=b.nextSibling)3===b.nodeType?c+=b.nodeValue.length:1===b.nodeType&&(a.push({event:"start",offset:c,node:b}),c=d(b,c),h(b).match(/br|hr|img|input/)||a.push({event:"stop",offset:c,node:b}));return c}(b,0),a},mergeStreams:function(c,d,i){var e=0,g="",f=[],a;function j(){return c.length&&d.length?c[0].offset!==d[0].offset?c[0].offset<d[0].offset?c:d:"start"===d[0].event?c:d:c.length?c:d}function k(a){g+="<"+h(a)+[].map.call(a.attributes,function(a){return" "+a.nodeName+'="'+b(a.value)+'"'}).join("")+">"}function l(a){g+="</"+h(a)+">"}function m(a){("start"===a.event?k:l)(a.node)}for(;c.length||d.length;)if(a=j(),g+=b(i.substring(e,a[0].offset)),e=a[0].offset,a===c){f.reverse().forEach(l);do m(a.splice(0,1)[0]),a=j();while(a===c&&a.length&&a[0].offset===e)f.reverse().forEach(k)}else"start"===a[0].event?f.push(a[0].node):f.pop(),m(a.splice(0,1)[0]);return g+b(i.substr(e))}});const C="</span>",j=a=>!!a.kind;class B{constructor(a,b){this.buffer="",this.classPrefix=b.classPrefix,a.walk(this)}addText(a){this.buffer+=b(a)}openNode(a){if(!j(a))return;let b=a.kind;a.sublanguage||(b=`${this.classPrefix}${b}`),this.span(b)}closeNode(a){j(a)&&(this.buffer+=C)}value(){return this.buffer}span(a){this.buffer+=`<span class="${a}">`}}class r{constructor(){this.rootNode={children:[]},this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(a){this.top.children.push(a)}openNode(b){const a={kind:b,children:[]};this.add(a),this.stack.push(a)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(a){return this.constructor._walk(a,this.rootNode)}static _walk(b,a){return"string"==typeof a?b.addText(a):a.children&&(b.openNode(a),a.children.forEach(a=>this._walk(b,a)),b.closeNode(a)),b}static _collapse(a){"string"!=typeof a&&a.children&&(a.children.every(a=>"string"==typeof a)?a.children=[a.children.join("")]:a.children.forEach(a=>{r._collapse(a)}))}}class A extends r{constructor(a){super(),this.options=a}addKeyword(a,b){""!==a&&(this.openNode(b),this.addText(a),this.closeNode())}addText(a){""!==a&&this.add(a)}addSublanguage(b,c){const a=b.root;a.kind=c,a.sublanguage=!0,this.add(a)}toHTML(){return new B(this,this.options).value()}finalize(){return!0}}function e(a){return a?"string"==typeof a?a:a.source:null}const m="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",d={begin:"\\\\[\\s\\S]",relevance:0},w={className:"string",begin:"'",end:"'",illegal:"\\n",contains:[d]},E={className:"string",begin:'"',end:'"',illegal:"\\n",contains:[d]},q={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},f=function(c,d,e={}){var b=a({className:"comment",begin:c,end:d,contains:[]},e);return b.contains.push(q),b.contains.push({className:"doctag",begin:"(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",relevance:0}),b},v=f("//","$"),t=f("/\\*","\\*/"),u=f("#","$");c=Object.freeze({__proto__:null,IDENT_RE:"[a-zA-Z]\\w*",UNDERSCORE_IDENT_RE:"[a-zA-Z_]\\w*",NUMBER_RE:"\\b\\d+(\\.\\d+)?",C_NUMBER_RE:m,BINARY_NUMBER_RE:"\\b(0b[01]+)",RE_STARTERS_RE:"!|!=|!
|