/
githubmirror
/
reveal.js
Обзор
Документация
Войти
/
githubmirror
/
reveal.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
dist/plugin/highlight.js
17 строк
899 KB
Hakim El Hattab
6.0.1, update build to maintain dts output paths
11 апр 2026, 10:16
11 апр 2026, 10:16
52c6c8b
Код
Авторство
О чём код?
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.RevealHighlight=t())})(th … [Строка слишком длинная. Вы можете скачать файл] https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};z(`before:highlight`,a);let o=a.result?a.result:v(a.language,a.code,n);return o.code=a.code,z(`after:highlight`,o),o}function v(e,n,i,a){let c=Object.create(null);function u(e,t){return e.keywords[t]}function d(){if(!A.keywords){M.addText(P);return}let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(P),n=``;for(;t;){n+=P.substring(e,t.index);let r=D.case_insensitive?t[0].toLowerCase():t[0],i=u(A,r);if(i){let[e,a]=i;if(M.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=De&&(F+=a),e.startsWith(`_`))n+=t[0];else{let n=D.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(P)}n+=P.substring(e),M.addText(n)}function f(){if(P===``)return;let e=null;if(typeof A.subLanguage==`string`){if(!t[A.subLanguage]){M.addText(P);return}e=v(A.subLanguage,P,!0,j[A.subLanguage]),j[A.subLanguage]=e._top}else e=S(P,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(F+=e.relevance),M.__addSublanguage(e._emitter,e.language)}function p(){A.subLanguage==null?d():f(),P=``}function m(e,t){e!==``&&(M.startScope(t),M.addText(e),M.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=D.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(P=i,d(),P=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&M.openNode(D.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(P,D.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),P=``):e.beginScope._multi&&(h(e.beginScope,t),P=``)),A=Object.create(e,{parent:{value:A}}),A}function _(e,t,n){let i=x(e.endRe,n);if(i){if(e[`on:end`]){let n=new r(e);e[`on:end`](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return _(e.parent,t,n)}function y(e){return A.matcher.regexIndex===0?(P+=e[0],1):(R=!0,0)}function b(e){let t=e[0],n=e.rule,i=new r(n),a=[n.__beforeBegin,n[`on:begin`]];for(let n of a)if(n&&(n(e,i),i.isMatchIgnored))return y(t);return n.skip?P+=t:(n.excludeBegin&&(P+=t),p(),!n.returnBegin&&!n.excludeBegin&&(P=t)),g(n,e),n.returnBegin?0:t.length}function C(e){let t=e[0],r=n.substring(e.index),i=_(A,e,r);if(!i)return Ee;let a=A;A.endScope&&A.endScope._wrap?(p(),m(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),h(A.endScope,e)):a.skip?P+=t:(a.returnEnd||a.excludeEnd||(P+=t),p(),a.excludeEnd&&(P=t));do A.scope&&M.closeNode(),!A.skip&&!A.subLanguage&&(F+=A.relevance),A=A.parent;while(A!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function w(){let e=[];for(let t=A;t!==D;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>M.openNode(e))}let T={};function E(t,r){let a=r&&r[0];if(P+=t,a==null)return p(),0;if(T.type===`begin`&&r.type===`end`&&T.index===r.index&&a===``){if(P+=n.slice(r.index,r.index+1),!o){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=T.rule,t}return 1}if(T=r,r.type===`begin`)return b(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(A.scope||`<unnamed>`)+`"`);throw e.mode=A,e}else if(r.type===`end`){let e=C(r);if(e!==Ee)return e}if(r.type===`illegal`&&a===``)return P+=` `,1;if(L>1e5&&L>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return P+=a,a.length}let D=N(e);if(!D)throw J(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);l … [Строка слишком длинная. Вы можете скачать файл] `},u]}}t.exports=o})),Ze=o(((e,t)=>{function n(e){let t=`[a-zA-Z_][\\w.]*`,n=`<\\?(lasso(script)?|=)`,r=`\\]|\\?>`,i={$pattern:t+`|&[lg]t;`,literal:`true false none minimal full all void and or not bw … [Строка слишком длинная. Вы можете скачать файл] ]`,m={scope:`string`,variants:[u,l,d,f]},h={scope:`number`,variants:[{begin:`\\b0[bB][01]+(?:_[01]+)*\\b`},{begin:`\\b0[oO][0-7]+(?:_[0-7]+)*\\b`},{begin:`\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b`},{ … [Строка слишком длинная. Вы можете скачать файл] ]*;`,relevance:0},{begin:`[vp][0-9]+`}]}}t.exports=n})),fn=o(((e,t)=>{function n(e){let t=`[a-z][a-zA-Z0-9_]*`,n={className:`string`,begin:`\\$.{1}`},r={className:`symbol`,begin:`#`+e.UNDERSCORE_IDENT … [Строка слишком длинная. Вы можете скачать файл] ]*?"'`},{begin:`"[^\r "]*"`}]},{className:`built_in`,variants:[{begin:`\\b(abs|acos|asin|atan|atan2|atanh|ceil|cloglog|comb|cos|digamma|exp|floor|invcloglog|invlogit|ln|lnfact|lnfactorial|lngamma|log|log10|max|min|mod|reld … [Строка слишком длинная. Вы можете скачать файл] (multipart)?`,end:`\\] `},{className:`string`,begin:`\\d{4}-\\d{2}-\\d{2}(\\s+)\\d{2}:\\d{2}:\\d{2}.\\d+Z`},{className:`string`,begin:`(\\+|-)\\d+`},{className:`keyword`,relevance:10,variants:[{begin:`^(test|testing|success … [Строка слишком длинная. Вы можете скачать файл] `+f.querySelector(m).textContent}return d+=` `+u}function d(n){try{var r=t.querySelectorAll(`code.hljs,code.nohighlight`);for(var i in r)r.hasOwnProperty(i)&&(r[i].classList.contains(`nohljsln`)||f(r[i],n))}catch(t){e.console.error(`LineNumbers error: `,t)}}function f(e,t){typeof e==`object`&&(e.innerHTML=p(e,t))}function p(e,t){var n,u,d=(n=e,{singleLine:function(e){return!!e.singleLine&&e.singleLine}(u=(u=t)||{}),startFrom:function(e,t){var n=1;isFinite(t.startFrom)&&(n=t.startFrom);var r=function(e,t){return e.hasAttribute(t)?e.getAttribute(t):null}(e,`data-ln-start-from`);return r!==null&&(n=function(e,t){if(!e)return t;var n=Number(e);return isFinite(n)?n:t}(r,1)),n}(n,u)});return function e(t){var n=t.childNodes;for(var r in n){var i;n.hasOwnProperty(r)&&(i=n[r],0<(i.textContent.trim().match(l)||[]).length&&(0<i.childNodes.length?e(i):m(i.parentNode)))}}(e),function(e,t){var n=h(e);if(n[n.length-1].trim()===``&&n.pop(),1<n.length||t.singleLine){for(var l=``,u=0,d=n.length;u<d;u++)l+=g(`<tr><td class="{0} {1}" {3}="{5}"><div class="{2}" {3}="{5}"></div></td><td class="{0} {4}" {3}="{5}">{6}</td></tr>`,[i,o,s,c,a,u+t.startFrom,0<n[u].length?n[u]:` `]);return g(`<table class="{0}">{1}</table>`,[r,l])}return e}(e.innerHTML,d)}function m(e){var t=e.className;if(/hljs-/.test(t)){for(var n=h(e.innerHTML),r=0,i=``;r<n.length;r++)i+=g(`<span class="{0}">{1}</span> `,[t,0<n[r].length?n[r]:` `]);e.innerHTML=i.trim()}}function h(e){return e.length===0?[]:e.split(l)}function g(e,t){return e.replace(/\{(\d+)\}/g,function(e,n){return t[n]===void 0?e:t[n]})}Q?(Q.initLineNumbersOnLoad=function(n){t.readyState===`interactive`||t.readyState===`complete`?d(n):e.addEventListener(`DOMContentLoaded`,function(){d(n)})},Q.lineNumbersBlock=f,Q.lineNumbersValue=function(e,t){if(typeof e==`string`){var n=document.createElement(`code`);return n.innerHTML=e,p(n,t)}},(n=t.createElement(`style`)).type=`text/css`,n.innerHTML=g(`.{0}{border-collapse:collapse}.{0} td{padding:0}.{1}:before{content:attr({2})}`,[r,s,c]),t.getElementsByTagName(`head`)[0].appendChild(n)):e.console.error(`highlight.js not detected!`),document.addEventListener(`copy`,function(e){var t,n=window.getSelection();!function(e){for(var t=e;t;){if(t.className&&t.className.indexOf(`hljs-ln-code`)!==-1)return 1;t=t.parentNode}}(n.anchorNode)||(t=window.navigator.userAgent.indexOf(`Edge`)===-1?n.toString():u(n),e.clipboardData.setData(`text/plain`,t),e.preventDefault())})})(window,document);var $={id:`highlight`,HIGHLIGHT_STEP_DELIMITER:`|`,HIGHLIGHT_LINE_DELIMITER:`,`,HIGHLIGHT_LINE_RANGE_DELIMITER:`-`,hljs:Q,init:function(e){let t=e.getConfig().highlight||{};t.highlightOnLoad=typeof t.highlightOnLoad==`boolean`?t.highlightOnLoad:!0,t.escapeHTML=typeof t.escapeHTML==`boolean`?t.escapeHTML:!0,Array.from(e.getRevealElement().querySelectorAll(`pre code`)).forEach(e=>{e.parentNode.classList.add(`code-wrapper`);let n=e.querySelector(`script[type="text/template"]`);n&&(e.textContent=n.innerHTML),e.hasAttribute(`data-trim`)&&typeof e.innerHTML.trim==`function`&&(e.innerHTML=Un(e)),t.escapeHTML&&!e.hasAttribute(`data-noescape`)&&(e.innerHTML=e.innerHTML.replace(/</g,`<`).replace(/>/g,`>`)),e.addEventListener(`focusout`,function(e){Q.highlightElement(e.currentTarget)},!1)}),typeof t.beforeHighlight==`function`&&t.beforeHighlight(Q),t.highlightOnLoad&&Array.from(e.getRevealElement().querySelectorAll(`pre code`)).forEach(e=>{$.highlightBlock(e)}),e.on(`pdf-ready`,function(){[].slice.call(e.getRevealElement().querySelectorAll(`pre code[data-line-numbers].current-fragment`)).forEach(function(e){$.scrollHighlightedLineIntoView(e,{},!0)})})},highlightBlock:function(e){if(Q.highlightElement(e),e.innerHTML.trim().length!==0&&e.hasAttribute(`data-line-numbers`)){Q.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},n=$.deserializeHighlightSteps(e.getAttribute(`data-line-numbers`));if(n.length>1){var r=parseInt(e.getAttribute(`data-fragment-index`),10);(typeof r!=`number`||isNaN(r))&&(r=null),n.slice(1).forEach(function(n){var i=e.cloneNode(!0);i.setAttribute(`data-line-numbers`,$.serializeHighlightSteps([n])),i.classList.add(`fragment`),e.parentNode.appendChild(i),$.highlightLines(i),typeof r==`number`?(i.setAttribute(`data-fragment-index`,r),r+=1):i.removeAttribute(`data-fragment-index`),i.addEventListener(`visible`,$.scrollHighlightedLineIntoView.bind($,i,t)),i.addEventListener(`hidden`,$.scrollHighlightedLineIntoView.bind($,i.previousElementSibling,t))}),e.removeAttribute(`data-fragment-index`),e.setAttribute(`data-line-numbers`,$.serializeHighlightSteps([n[0]]))}var i=typeof e.closest==`function`?e.closest(`section:not(.stack)`):null;if(i){var a=function(){$.scrollHighlightedLineIntoView(e,t,!0),i.removeEventListener(`visible`,a)};i.addEventListener(`visible`,a)}$.highlightLines(e)}},scrollHighlightedLineIntoView:function(e,t,n){cancelAnimationFrame(t.animationFrameID),t.currentBlock&&(e.scrollTop=t.currentBlock.scrollTop),t.currentBlock=e;var r=this.getHighlightedLineBounds(e),i=e.offsetHeight,a=getComputedStyle(e);i-=parseInt(a.paddingTop)+parseInt(a.paddingBottom);var o=e.scrollTop,s=r.top+(Math.min(r.bottom-r.top,i)-i)/2,c=e.querySelector(`.hljs-ln`);if(c&&(s+=c.offsetTop-parseInt(a.paddingTop)),s=Math.max(Math.min(s,e.scrollHeight-i),0),n===!0||o===s)e.scrollTop=s;else{if(e.scrollHeight<=i)return;var l=0,u=function(){l=Math.min(l+.02,1),e.scrollTop=o+(s-o)*$.easeInOutQuart(l),l<1&&(t.animationFrameID=requestAnimationFrame(u))};u()}},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(t.length===0)return{top:0,bottom:0};var n=t[0],r=t[t.length-1];return{top:n.offsetTop,bottom:r.offsetTop+r.offsetHeight}},highlightLines:function(e,t){var n=$.deserializeHighlightSteps(t||e.getAttribute(`data-line-numbers`));n.length&&n[0].forEach(function(t){var n=[];typeof t.end==`number`?n=[].slice.call(e.querySelectorAll(`table tr:nth-child(n+`+t.start+`):nth-child(-n+`+t.end+`)`)):typeof t.start==`number`&&(n=[].slice.call(e.querySelectorAll(`table tr:nth-child(`+t.start+`)`))),n.length&&(n.forEach(function(e){e.classList.add(`highlight-line`)}),e.classList.add(`has-highlights`))})},deserializeHighlightSteps:function(e){return e=e.replace(/\s/g,``),e=e.split($.HIGHLIGHT_STEP_DELIMITER),e.map(function(e){return e.split($.HIGHLIGHT_LINE_DELIMITER).map(function(e){if(/^[\d-]+$/.test(e)){e=e.split($.HIGHLIGHT_LINE_RANGE_DELIMITER);var t=parseInt(e[0],10),n=parseInt(e[1],10);return isNaN(n)?{start:t}:{start:t,end:n}}else return{}})})},serializeHighlightSteps:function(e){return e.map(function(e){return e.map(function(e){return typeof e.end==`number`?e.start+$.HIGHLIGHT_LINE_RANGE_DELIMITER+e.end:typeof e.start==`number`?e.start:``}).join($.HIGHLIGHT_LINE_DELIMITER)}).join($.HIGHLIGHT_STEP_DELIMITER)}};function Un(e){function t(e){return e.replace(/^[\s\uFEFF\xA0]+/g,``)}function n(e){for(var t=e.split(` `),n=0;n<t.length&&t[n].trim()===``;n++)t.splice(n--,1);for(var n=t.length-1;n>=0&&t[n].trim()===``;n--)t.splice(n,1);return t.join(` `)}return(function(e){var r=n(e.innerHTML).split(` `),i=r.reduce(function(e,n){return n.length>0&&t(n).length>0&&e>n.length-t(n).length?n.length-t(n).length:e},1/0);return r.map(function(e,t){return e.slice(i)}).join(` `)})(e)}return()=>$});