travel_report_east_africa/plugin/highlight/highlight.esm.js

6 lines
918 KiB
JavaScript
Raw Normal View History

2024-01-21 15:15:34 +01:00
function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((a=>{const n=e[a],i=typeof n;"object"!==i&&"function"!==i||Object.isFrozen(n)||t(n)})),e}class a{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function i(e,...t){const a=Object.create(null);for(const t in e)a[t]=e[t];return t.forEach((function(e){for(const t in e)a[t]=e[t]})),a}const r=e=>!!e.scope;class o{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=n(e)}openNode(e){if(!r(e))return;const t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const a=e.split(".");return[`${t}${a.shift()}`,...a.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){r(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}const s=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class l{constructor(){this.rootNode=s(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const t=s({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{l._collapse(e)})))}}class c extends l{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){const a=e.root;t&&(a.scope=`language:${t}`),this.add(a)}toHTML(){return new o(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function _(e){return e?"string"==typeof e?e:e.source:null}function d(e){return u("(?=",e,")")}function m(e){return u("(?:",e,")*")}function p(e){return u("(?:",e,")?")}function u(...e){return e.map((e=>_(e))).join("")}function g(...e){const t=function(e){const t=e[e.length-1];return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}(e);return"("+(t.capture?"":"?:")+e.map((e=>_(e))).join("|")+")"}function E(e){return new RegExp(e.toString()+"|").exec("").length-1}const S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function b(e,{joinWith:t}){let a=0;return e.map((e=>{a+=1;const t=a;let n=_(e),i="";for(;n.length>0;){const e=S.exec(n);if(!e){i+=n;break}i+=n.substring(0,e.index),n=n.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?i+="\\"+String(Number(e[1])+t):(i+=e[0],"("===e[0]&&a++)}return i})).map((e=>`(${e})`)).join(t)}const T="[a-zA-Z]\\w*",C="[a-zA-Z_]\\w*",f="\\b\\d+(\\.\\d+)?",R="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",N="\\b(0b[01]+)",O={begin:"\\\\[\\s\\S]",relevance:0},h={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[O]},v={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[O]},I=function(e,t,a={}){const n=i({scope:"comment",begin:e,end:t,contains:[]},a);n.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const r=g("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-
/*!
* reveal.js plugin that adds syntax highlight support.
*/
const Rs={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:fs,init:function(e){let t=e.getConfig().highlight||{};t.highlightOnLoad="boolean"!=typeof t.highlightOnLoad||t.highlightOnLoad,t.escapeHTML="boolean"!=typeof t.escapeHTML||t.escapeHTML,Array.from(e.getRevealElement().querySelectorAll("pre code")).forEach((e=>{e.parentNode.classList.add("code-wrapper");let 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"),i=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(i)})).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){fs.highlightElement(e.currentTarget)}),!1)})),"function"==typeof t.beforeHighlight&&t.beforeHighlight(fs),t.highlightOnLoad&&Array.from(e.getRevealElement().querySelectorAll("pre code")).forEach((e=>{Rs.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){Rs.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(fs.highlightElement(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){fs.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},a=Rs.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 i=e.cloneNode(!0);i.setAttribute("data-line-numbers",Rs.serializeHighlightSteps([a])),i.classList.add("fragment"),e.parentNode.appendChild(i),Rs.highlightLines(i),"number"==typeof n?(i.setAttribute("data-fragment-index",n),n+=1):i.removeAttribute("data-fragment-index"),i.addEventListener("visible",Rs.scrollHighlightedLineIntoView.bind(Rs,i,t)),i.addEventListener("hidden",Rs.scrollHighlightedLineIntoView.bind(Rs,i.previousElementSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",Rs.serializeHighlightSteps([a[0]]))}var i="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(i){var r=function(){Rs.scrollHighlightedLineIntoView(e,t,!0),i.removeEventListener("visible",r)};i.addEventListener("visible",r)}Rs.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),i=e.offsetHeight,r=getComputedStyle(e);i-=parseInt(r.paddingTop)+parseInt(r.paddingBottom);var o=e.scrollTop,s=n.top+(Math.min(n.bottom-n.top,i)-i)/2,l=e.querySelector(".hljs-ln");if(l&&(s+=l.offsetTop-parseInt(r.paddingTop)),s=Math.max(Math.min(s,e.scrollHeight-i),0),!0===a||o===s)e.scrollTop=s;else{if(e.scrollHeight<=i)return;var c=0,_=function(){c=Math.min(c+.02,1),e.scrollTop=o+(s-o)*Rs.easeInOutQuart(c),c<1&&(t.animationFrameID=requestAnimationFrame(_))};_()}},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=Rs.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