fa23-si/dist/plugin/highlight.js

7 lines
721 KiB
JavaScript
Raw Normal View History

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).RevealHighlight=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}
/*! highlight.js v9.18.0 | BSD3 License | git.io/hljslicense */!function(t){var r="object"==("undefined"==typeof window?"undefined":e(window))&&window||"object"==("undefined"==typeof self?"undefined":e(self))&&self;"undefined"==typeof exports||exports.nodeType?r&&(r.hljs=t({}),"function"==typeof define&&define.amd&&define([],(function(){return r.hljs}))):t(exports)}((function(t){var r=[],a=Object.keys,i={},n={},o=!0,s=/^(no-?highlight|plain|text)$/i,l=/\blang(?:uage)?-([\w-]+)\b/i,c=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,_={case_insensitive:"cI",lexemes:"l",contains:"c",keywords:"k",subLanguage:"sL",className:"cN",begin:"b",beginKeywords:"bK",end:"e",endsWithParent:"eW",illegal:"i",excludeBegin:"eB",excludeEnd:"eE",returnBegin:"rB",returnEnd:"rE",variants:"v",IDENT_RE:"IR",UNDERSCORE_IDENT_RE:"UIR",NUMBER_RE:"NR",C_NUMBER_RE:"CNR",BINARY_NUMBER_RE:"BNR",RE_STARTERS_RE:"RSR",BACKSLASH_ESCAPE:"BE",APOS_STRING_MODE:"ASM",QUOTE_STRING_MODE:"QSM",PHRASAL_WORDS_MODE:"PWM",C_LINE_COMMENT_MODE:"CLCM",C_BLOCK_COMMENT_MODE:"CBCM",HASH_COMMENT_MODE:"HCM",NUMBER_MODE:"NM",C_NUMBER_MODE:"CNM",BINARY_NUMBER_MODE:"BNM",CSS_NUMBER_MODE:"CSSNM",REGEXP_MODE:"RM",TITLE_MODE:"TM",UNDERSCORE_TITLE_MODE:"UTM",COMMENT:"C",beginRe:"bR",endRe:"eR",illegalRe:"iR",lexemesRe:"lR",terminators:"t",terminator_end:"tE"},d="</span>",p="Could not find the language '{}', did you forget to load/include a language module?",u={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},m="of and for in not or if then".split(" ");function S(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function E(e){return e.nodeName.toLowerCase()}function g(e){return s.test(e)}function b(e){var t,r={},a=Array.prototype.slice.call(arguments,1);for(t in e)r[t]=e[t];return a.forEach((function(e){for(t in e)r[t]=e[t]})),r}function T(e){var t=[];return function e(r,a){for(var i=r.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(t.push({event:"start",offset:a,node:i}),a=e(i,a),E(i).match(/br|hr|img|input/)||t.push({event:"stop",offset:a,node:i}));return a}(e,0),t}function C(e,t,a){var i=0,n="",o=[];function s(){return e.length&&t.length?e[0].offset!==t[0].offset?e[0].offset<t[0].offset?e:t:"start"===t[0].event?e:t:e.length?e:t}function l(e){n+="<"+E(e)+r.map.call(e.attributes,(function(e){return" "+e.nodeName+'="'+S(e.value).replace(/"/g,"&quot;")+'"'})).join("")+">"}function c(e){n+="</"+E(e)+">"}function _(e){("start"===e.event?l:c)(e.node)}for(;e.length||t.length;){var d=s();if(n+=S(a.substring(i,d[0].offset)),i=d[0].offset,d===e){for(o.reverse().forEach(c);_(d.splice(0,1)[0]),(d=s())===e&&d.length&&d[0].offset===i;);o.reverse().forEach(l)}else"start"===d[0].event?o.push(d[0].node):o.pop(),_(d.splice(0,1)[0])}return n+S(a.substr(i))}function f(e){if(_&&!e.langApiRestored){if(Object.isFrozen(e))return;for(var t in e.langApiRestored=!0,_)e[t]&&(e[_[t]]=e[t]);(e.c||[]).concat(e.v||[]).forEach(f)}}function R(e){function t(e){return e&&e.source||e}function r(r,a){return new RegExp(t(r),"m"+(e.cI?"i":"")+(a?"g":""))}if(e.c&&-1!=e.c.indexOf("self")){if(!o)throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");e.c=e.c.filter((function(e){return"self"!=e}))}!function i(n,o){n.compiled||(n.compiled=!0,n.k=n.k||n.bK,n.k&&(n.k=function(e,t){var r={};return"string"==typeof e?i("keyword",e):a(e).forEach((function(t){i(t,e[t])})),r;function i(e,a){t&&(a=a.toLowerCase()),a.split(" ").forEach((function(t){var a,i,n=t.split("|");r[n[0]]=[e,(a=n[0],(i=n[1])?Number(i):function(e){return-1!=m.indexOf(e.toLowerCase())}(a)?0:1)]}))}}(n.k,e.cI)),n.lR=r(n.l||/\w+/,!0),o&&(n.bK&&(n.b="\\b("+n.bK.split(" ").join("|")+")\\b"),n.b||(n.b=/\B|\b/),n.bR=r(n.b),n.endSameAsBegin&&(n.e=n.b),n.e||n.eW||(n.e=/\B|\b/),n.e&&(n.eR=r(n.e)),n.tE=t(n.e)||"",n.eW&&o.tE&&(n.tE+=(n.e?"|":"")+o.tE)),n.i&&(n.iR=r(n.i)),null==n.relevance&&(n.relevance=1),n.c||(n.c=[]),n.c=Array.prototype.concat.apply([],n.c.map((function(e){return function(e){return e.v&&!e.cached_variants&&(e.cached_variants=e.v.map((function(t){
/*!
* reveal.js plugin that adds syntax highlight support.
*/
var t={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",init:function(e){var r=e.getConfig().highlight||{};r.highlightOnLoad="boolean"!=typeof r.highlightOnLoad||r.highlightOnLoad,r.escapeHTML="boolean"!=typeof r.escapeHTML||r.escapeHTML,[].slice.call(e.getRevealElement().querySelectorAll("pre code")).forEach((function(e){e.hasAttribute("data-trim")&&"function"==typeof e.innerHTML.trim&&(e.innerHTML=function(e){function t(e){return e.replace(/^[\s\uFEFF\xA0]+/g,"")}return function(e){var r=function(e){for(var t=e.split("\n"),r=0;r<t.length&&""===t[r].trim();r++)t.splice(r--,1);for(r=t.length-1;r>=0&&""===t[r].trim();r--)t.splice(r,1);return t.join("\n")}(e.innerHTML).split("\n"),a=r.reduce((function(e,r){return r.length>0&&t(r).length>0&&e>r.length-t(r).length?r.length-t(r).length:e}),Number.POSITIVE_INFINITY);return r.map((function(e,t){return e.slice(a)})).join("\n")}(e)}(e)),r.escapeHTML&&!e.hasAttribute("data-noescape")&&(e.innerHTML=e.innerHTML.replace(/</g,"&lt;").replace(/>/g,"&gt;")),e.addEventListener("focusout",(function(e){hljs.highlightBlock(e.currentTarget)}),!1),r.highlightOnLoad&&t.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){t.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(hljs.highlightBlock(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){hljs.lineNumbersBlock(e,{singleLine:!0});var r={currentBlock:e},a=t.deserializeHighlightSteps(e.getAttribute("data-line-numbers"));if(a.length>1){var i=parseInt(e.getAttribute("data-fragment-index"),10);("number"!=typeof i||isNaN(i))&&(i=null),a.slice(1).forEach((function(a){var n=e.cloneNode(!0);n.setAttribute("data-line-numbers",t.serializeHighlightSteps([a])),n.classList.add("fragment"),e.parentNode.appendChild(n),t.highlightLines(n),"number"==typeof i?(n.setAttribute("data-fragment-index",i),i+=1):n.removeAttribute("data-fragment-index"),n.addEventListener("visible",t.scrollHighlightedLineIntoView.bind(t,n,r)),n.addEventListener("hidden",t.scrollHighlightedLineIntoView.bind(t,n.previousSibling,r))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",t.serializeHighlightSteps([a[0]]))}var n="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(n){n.addEventListener("visible",(function a(){t.scrollHighlightedLineIntoView(e,r,!0),n.removeEventListener("visible",a)}))}t.highlightLines(e)}},scrollHighlightedLineIntoView:function(e,r,a){cancelAnimationFrame(r.animationFrameID),r.currentBlock&&(e.scrollTop=r.currentBlock.scrollTop),r.currentBlock=e;var i=this.getHighlightedLineBounds(e),n=e.offsetHeight,o=getComputedStyle(e);n-=parseInt(o.paddingTop)+parseInt(o.paddingBottom);var s=e.scrollTop,l=i.top+(Math.min(i.bottom-i.top,n)-n)/2,c=e.querySelector(".hljs-ln");if(c&&(l+=c.offsetTop-parseInt(o.paddingTop)),l=Math.max(Math.min(l,e.scrollHeight-n),0),!0===a||s===l)e.scrollTop=l;else{if(e.scrollHeight<=n)return;var _=0;!function a(){_=Math.min(_+.02,1),e.scrollTop=s+(l-s)*t.easeInOutQuart(_),_<1&&(r.animationFrameID=requestAnimationFrame(a))}()}},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},getHighlightedLineBounds:function(e){var t=e.querySelectorAll(".highlight-line");if(0===t.length)return{top:0,bottom:0};var r=t[0],a=t[t.length-1];return{top:r.offsetTop,bottom:a.offsetTop+a.offsetHeight}},highlightLines:function(e,r){var a=t.deserializeHighlightSteps(r||e.getAttribute("data-line-numbers"));a.length&&a[0].forEach((function(t){var r=[];"number"==typeof t.end?r=[].slice.call(e.querySelectorAll("table tr:nth-child(n+"+t.start+"):nth-child(-n+"+t.end+")")):"number"==typeof t.start&&(r=[].slice.call(e.querySelectorAll("table tr:nth-child("+t.start+")"))),r.length&&(r.forEach((function(e){e.classList.add("highlight-line")})),e.classList.add("has-highlights"))}))},deserializeHighlightSteps:function(e){return(e=(e=e.replace(/\s/g,"")).split(t.HIGHLIGHT_STEP_DELIMITER)).map((function(e