fossasia-22-renode/plugin/highlight/highlight.js

6 lines
807 KiB
JavaScript
Raw Normal View History

2020-08-19 08:33:36 +00:00
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).RevealHighlight=t()}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e,t,a){return e(a={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&a.path)}},a.exports),a.exports}var a=function(e){return e&&e.Math==Math&&e},n=a("object"==typeof globalThis&&globalThis)||a("object"==typeof window&&window)||a("object"==typeof self&&self)||a("object"==typeof e&&e)||Function("return this")(),r=function(e){try{return!!e()}catch(e){return!0}},i=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),o={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,l={f:s&&!o.call({1:2},1)?function(e){var t=s(this,e);return!!t&&t.enumerable}:o},_=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},c={}.toString,d=function(e){return c.call(e).slice(8,-1)},u="".split,m=r((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==d(e)?u.call(e,""):Object(e)}:Object,p=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},E=function(e){return m(p(e))},g=function(e){return"object"==typeof e?null!==e:"function"==typeof e},S=function(e,t){if(!g(e))return e;var a,n;if(t&&"function"==typeof(a=e.toString)&&!g(n=a.call(e)))return n;if("function"==typeof(a=e.valueOf)&&!g(n=a.call(e)))return n;if(!t&&"function"==typeof(a=e.toString)&&!g(n=a.call(e)))return n;throw TypeError("Can't convert object to primitive value")},T={}.hasOwnProperty,b=function(e,t){return T.call(e,t)},f=n.document,C=g(f)&&g(f.createElement),R=function(e){return C?f.createElement(e):{}},N=!i&&!r((function(){return 7!=Object.defineProperty(R("div"),"a",{get:function(){return 7}}).a})),O=Object.getOwnPropertyDescriptor,v={f:i?O:function(e,t){if(e=E(e),t=S(t,!0),N)try{return O(e,t)}catch(e){}if(b(e,t))return _(!l.f.call(e,t),e[t])}},I=function(e){if(!g(e))throw TypeError(String(e)+" is not an object");return e},h=Object.defineProperty,A={f:i?h:function(e,t,a){if(I(e),t=S(t,!0),I(a),N)try{return h(e,t,a)}catch(e){}if("get"in a||"set"in a)throw TypeError("Accessors not supported");return"value"in a&&(e[t]=a.value),e}},y=i?function(e,t,a){return A.f(e,t,_(1,a))}:function(e,t,a){return e[t]=a,e},D=function(e,t){try{y(n,e,t)}catch(a){n[e]=t}return t},M="__core-js_shared__",L=n[M]||D(M,{}),x=Function.toString;"function"!=typeof L.inspectSource&&(L.inspectSource=function(e){return x.call(e)});var w,P,k,U=L.inspectSource,F=n.WeakMap,B="function"==typeof F&&/native code/.test(U(F)),G=t((function(e){(e.exports=function(e,t){return L[e]||(L[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),Y=0,H=Math.random(),V=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++Y+H).toString(36)},q=G("keys"),z=function(e){return q[e]||(q[e]=V(e))},W={},Q=n.WeakMap;if(B){var $=new Q,K=$.get,j=$.has,X=$.set;w=function(e,t){return X.call($,e,t),t},P=function(e){return K.call($,e)||{}},k=function(e){return j.call($,e)}}else{var Z=z("state");W[Z]=!0,w=function(e,t){return y(e,Z,t),t},P=function(e){return b(e,Z)?e[Z]:{}},k=function(e){return b(e,Z)}}var J={set:w,get:P,has:k,enforce:function(e){return k(e)?P(e):w(e,{})},getterFor:function(e){return function(t){var a;if(!g(t)||(a=P(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return a}}},ee=t((function(e){var t=J.get,a=J.enforce,r=String(String).split("String");(e.exports=function(e,t,i,o){var s=!!o&&!!o.unsafe,l=!!o&&!!o.enumerable,_=!!o&&!!o.noTargetGet;"function"==typeof i&&("string"!=typeof t||b(i,"name")||y(i,"name",t),a(i).source=r.join("string"==typeof t?t:"")),e!==n?(s?!_&&e[t]&&(l=!0):delete e[t],l?e[t]=i:y(e,t,i)):
/*!
2020-05-26 07:46:50 +00:00
* reveal.js plugin that adds syntax highlight support.
*/
2020-08-19 08:33:36 +00:00
var Ll={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:Ml,init:function(e){var t=e.getConfig().highlight||{};t.highlightOnLoad="boolean"!=typeof t.highlightOnLoad||t.highlightOnLoad,t.escapeHTML="boolean"!=typeof t.escapeHTML||t.escapeHTML,[].slice.call(e.getRevealElement().querySelectorAll("pre code")).forEach((function(e){var a=e.querySelector('script[type="text/template"]');a&&(e.textContent=a.innerHTML),e.hasAttribute("data-trim")&&"function"==typeof e.innerHTML.trim&&(e.innerHTML=function(e){function t(e){return e.replace(/^[\s\uFEFF\xA0]+/g,"")}function a(e){for(var t=e.split("\n"),a=0;a<t.length&&""===t[a].trim();a++)t.splice(a--,1);for(a=t.length-1;a>=0&&""===t[a].trim();a--)t.splice(a,1);return t.join("\n")}return function(e){var n=a(e.innerHTML).split("\n"),r=n.reduce((function(e,a){return a.length>0&&t(a).length>0&&e>a.length-t(a).length?a.length-t(a).length:e}),Number.POSITIVE_INFINITY);return n.map((function(e,t){return e.slice(r)})).join("\n")}(e)}(e)),t.escapeHTML&&!e.hasAttribute("data-noescape")&&(e.innerHTML=e.innerHTML.replace(/</g,"&lt;").replace(/>/g,"&gt;")),e.addEventListener("focusout",(function(e){Ml.highlightBlock(e.currentTarget)}),!1),t.highlightOnLoad&&Ll.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){Ll.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(Ml.highlightBlock(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){Ml.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},a=Ll.deserializeHighlightSteps(e.getAttribute("data-line-numbers"));if(a.length>1){var n=parseInt(e.getAttribute("data-fragment-index"),10);("number"!=typeof n||isNaN(n))&&(n=null),a.slice(1).forEach((function(a){var r=e.cloneNode(!0);r.setAttribute("data-line-numbers",Ll.serializeHighlightSteps([a])),r.classList.add("fragment"),e.parentNode.appendChild(r),Ll.highlightLines(r),"number"==typeof n?(r.setAttribute("data-fragment-index",n),n+=1):r.removeAttribute("data-fragment-index"),r.addEventListener("visible",Ll.scrollHighlightedLineIntoView.bind(Ll,r,t)),r.addEventListener("hidden",Ll.scrollHighlightedLineIntoView.bind(Ll,r.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",Ll.serializeHighlightSteps([a[0]]))}var r="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(r){r.addEventListener("visible",(function a(){Ll.scrollHighlightedLineIntoView(e,t,!0),r.removeEventListener("visible",a)}))}Ll.highlightLines(e)}},scrollHighlightedLineIntoView:function(e,t,a){cancelAnimationFrame(t.animationFrameID),t.currentBlock&&(e.scrollTop=t.currentBlock.scrollTop),t.currentBlock=e;var n=this.getHighlightedLineBounds(e),r=e.offsetHeight,i=getComputedStyle(e);r-=parseInt(i.paddingTop)+parseInt(i.paddingBottom);var o=e.scrollTop,s=n.top+(Math.min(n.bottom-n.top,r)-r)/2,l=e.querySelector(".hljs-ln");if(l&&(s+=l.offsetTop-parseInt(i.paddingTop)),s=Math.max(Math.min(s,e.scrollHeight-r),0),!0===a||o===s)e.scrollTop=s;else{if(e.scrollHeight<=r)return;var _=0;!function a(){_=Math.min(_+.02,1),e.scrollTop=o+(s-o)*Ll.easeInOutQuart(_),_<1&&(t.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 a=t[0],n=t[t.length-1];return{top:a.offsetTop,bottom:n.offsetTop+n.offsetHeight}},highlightLines:function(e,t){var a=Ll.deserializeHighlightSteps(t||e.getAttribute("data-line-numbers"));a.length&&a[0].forEach((function(t){var a=[];"number"==typeof t.end?a=[].slice.call(e.querySelectorAll("table tr:nth-child(n+"+t.start+"):nth-child(-n+"+t.end+")")):"number"==typeof t.start&&(a=[].slice.call(e.querySelectorAll("table tr:nth-child("+t.start+")"))),a.length&&(a.forEach((function(e){e.classList.add("highlight-line")})),e.classList.add("has-highlights"))}))},deserializeHighl