conference_ia_generative/plugin/highlight/highlight.js

6 lines
866 KiB
JavaScript
Raw Normal View History

2023-01-17 18:36:04 +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";function e(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach((function(a){var n=t[a];"object"!=typeof n||Object.isFrozen(n)||e(n)})),t}var t=e,a=e;t.default=a;class n{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function i(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(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 s=e=>!!e.kind;class o{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=e.kind;e.sublanguage||(t=`${this.classPrefix}${t}`),this.span(t)}closeNode(e){s(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}class l{constructor(){this.rootNode={children:[]},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={kind:e,children:[]};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}addKeyword(e,t){""!==e&&(this.openNode(t),this.addText(e),this.closeNode())}addText(e){""!==e&&this.add(e)}addSublanguage(e,t){const a=e.root;a.kind=t,a.sublanguage=!0,this.add(a)}toHTML(){return new o(this,this.options).value()}finalize(){return!0}}function _(e){return e?"string"==typeof e?e:e.source:null}const d=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;const m="[a-zA-Z]\\w*",u="[a-zA-Z_]\\w*",p="\\b\\d+(\\.\\d+)?",g="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",E="\\b(0b[01]+)",S={begin:"\\\\[\\s\\S]",relevance:0},b={className:"string",begin:"'",end:"'",illegal:"\\n",contains:[S]},T={className:"string",begin:'"',end:'"',illegal:"\\n",contains:[S]},f={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/},C=function(e,t,a={}){const n=r({className:"comment",begin:e,end:t,contains:[]},a);return n.contains.push(f),n.contains.push({className:"doctag",begin:"(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",relevance:0}),n},N=C("//","$"),R=C("/\\*","\\*/"),O=C("#","$"),h={className:"number",begin:p,relevance:0},v={className:"number",begin:g,relevance:0},I={className:"number",begin:E,relevance:0},A={className:"number",begin:p+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},y={begin:/(?=\/[^/\n]*\/)/,contains:[{className:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[S,{begin:/\[/,end:/\]/,relevance:0,contains:[S]}]}]},D={className:"title",begin:m,relevance:0},M={className:"title",begin:u,relevance:0},L={begin:"\\.\\s*[a-zA-Z_]\\w*",relevance:0};var x=Object.freeze({__proto__:null,MATCH_NOTHING_RE:/\b\B/,IDENT_RE:m,UNDERSCORE_IDENT_RE:u,NUMBER_RE:p,C_NUMBER_RE:g,BINARY_NUMBER_RE:E,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\
/*!
* reveal.js plugin that adds syntax highlight support.
*/
const es={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:Jr,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){Jr.highlightElement(e.currentTarget)}),!1)})),"function"==typeof t.beforeHighlight&&t.beforeHighlight(Jr),t.highlightOnLoad&&Array.from(e.getRevealElement().querySelectorAll("pre code")).forEach((e=>{es.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){es.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(Jr.highlightElement(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){Jr.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},a=es.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",es.serializeHighlightSteps([a])),i.classList.add("fragment"),e.parentNode.appendChild(i),es.highlightLines(i),"number"==typeof n?(i.setAttribute("data-fragment-index",n),n+=1):i.removeAttribute("data-fragment-index"),i.addEventListener("visible",es.scrollHighlightedLineIntoView.bind(es,i,t)),i.addEventListener("hidden",es.scrollHighlightedLineIntoView.bind(es,i.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",es.serializeHighlightSteps([a[0]]))}var i="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(i){var r=function(){es.scrollHighlightedLineIntoView(e,t,!0),i.removeEventListener("visible",r)};i.addEventListener("visible",r)}es.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 s=e.scrollTop,o=n.top+(Math.min(n.bottom-n.top,i)-i)/2,l=e.querySelector(".hljs-ln");if(l&&(o+=l.offsetTop-parseInt(r.paddingTop)),o=Math.max(Math.min(o,e.scrollHeight-i),0),!0===a||s===o)e.scrollTop=o;else{if(e.scrollHeight<=i)return;var c=0,_=function(){c=Math.min(c+.02,1),e.scrollTop=s+(o-s)*es.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=es.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