1
0
Fork 0

Allow users to register additional languages via callback

This commit is contained in:
Asvin Goel 2021-10-04 12:16:00 +02:00
parent 444d127053
commit ca9ce4b592
3 changed files with 9 additions and 3 deletions

View File

@ -2,4 +2,4 @@ var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?windo
/*!
* reveal.js plugin that adds syntax highlight support.
*/
var Ad={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:Id,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 n=e.querySelector('script[type="text/template"]');n&&(e.textContent=n.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 n(e){for(var t=e.split("\n"),n=0;n<t.length&&""===t[n].trim();n++)t.splice(n--,1);for(n=t.length-1;n>=0&&""===t[n].trim();n--)t.splice(n,1);return t.join("\n")}return function(e){var a=n(e.innerHTML).split("\n"),r=a.reduce((function(e,n){return n.length>0&&t(n).length>0&&e>n.length-t(n).length?n.length-t(n).length:e}),Number.POSITIVE_INFINITY);return a.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){Id.highlightBlock(e.currentTarget)}),!1),t.highlightOnLoad&&Ad.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){Ad.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(Id.highlightBlock(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){Id.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},n=Ad.deserializeHighlightSteps(e.getAttribute("data-line-numbers"));if(n.length>1){var a=parseInt(e.getAttribute("data-fragment-index"),10);("number"!=typeof a||isNaN(a))&&(a=null),n.slice(1).forEach((function(n){var r=e.cloneNode(!0);r.setAttribute("data-line-numbers",Ad.serializeHighlightSteps([n])),r.classList.add("fragment"),e.parentNode.appendChild(r),Ad.highlightLines(r),"number"==typeof a?(r.setAttribute("data-fragment-index",a),a+=1):r.removeAttribute("data-fragment-index"),r.addEventListener("visible",Ad.scrollHighlightedLineIntoView.bind(Ad,r,t)),r.addEventListener("hidden",Ad.scrollHighlightedLineIntoView.bind(Ad,r.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",Ad.serializeHighlightSteps([n[0]]))}var r="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(r){r.addEventListener("visible",(function n(){Ad.scrollHighlightedLineIntoView(e,t,!0),r.removeEventListener("visible",n)}))}Ad.highlightLines(e)}},scrollHighlightedLineIntoView:function(e,t,n){cancelAnimationFrame(t.animationFrameID),t.currentBlock&&(e.scrollTop=t.currentBlock.scrollTop),t.currentBlock=e;var a=this.getHighlightedLineBounds(e),r=e.offsetHeight,i=getComputedStyle(e);r-=parseInt(i.paddingTop)+parseInt(i.paddingBottom);var o=e.scrollTop,s=a.top+(Math.min(a.bottom-a.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===n||o===s)e.scrollTop=s;else{if(e.scrollHeight<=r)return;var c=0;!function n(){c=Math.min(c+.02,1),e.scrollTop=o+(s-o)*Ad.easeInOutQuart(c),c<1&&(t.animationFrameID=requestAnimationFrame(n))}()}},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 n=t[0],a=t[t.length-1];return{top:n.offsetTop,bottom:a.offsetTop+a.offsetHeight}},highlightLines:function(e,t){var n=Ad.deserializeHighlightSteps(t||e.getAttribute("data-line-numbers"));n.length&&n[0].forEach((function(t){var n=[];"number"==typeof t.end?n=[].slice.call(e.querySelectorAll("table tr:nth-child(n+"+t.start+"):nth-child(-n+"+t.end+")")):"number"==typeof t.start&&(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=e.replace(/\s/g,"")).split(Ad.HIGHLIGHT_STEP_DELIMITER)).map((function(e){return e.split(Ad.HIGHLIGHT_LINE_DELIMITER).map((function(e){if(/^[\d-]+$/.test(e)){e=e.split(Ad.HIGHLIGHT_LINE_RANGE_DELIMITER);var t=parseInt(e[0],10),n=parseInt(e[1],10);return isNaN(n)?{start:t}:{start:t,end:n}}return{}}))}))},serializeHighlightSteps:function(e){return e.map((function(e){return e.map((function(e){return"number"==typeof e.end?e.start+Ad.HIGHLIGHT_LINE_RANGE_DELIMITER+e.end:"number"==typeof e.start?e.start:""})).join(Ad.HIGHLIGHT_LINE_DELIMITER)})).join(Ad.HIGHLIGHT_STEP_DELIMITER)}};export default function(){return Ad}
var Ad={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:Id,init:function(e){var t=e.getConfig().highlight||{};t.callback="function"==typeof t.callback?t.callback:null,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 n=e.querySelector('script[type="text/template"]');n&&(e.textContent=n.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 n(e){for(var t=e.split("\n"),n=0;n<t.length&&""===t[n].trim();n++)t.splice(n--,1);for(n=t.length-1;n>=0&&""===t[n].trim();n--)t.splice(n,1);return t.join("\n")}return function(e){var a=n(e.innerHTML).split("\n"),r=a.reduce((function(e,n){return n.length>0&&t(n).length>0&&e>n.length-t(n).length?n.length-t(n).length:e}),Number.POSITIVE_INFINITY);return a.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){Id.highlightBlock(e.currentTarget)}),!1),t.callback&&t.callback(Id),t.highlightOnLoad&&Ad.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){Ad.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(Id.highlightBlock(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){Id.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},n=Ad.deserializeHighlightSteps(e.getAttribute("data-line-numbers"));if(n.length>1){var a=parseInt(e.getAttribute("data-fragment-index"),10);("number"!=typeof a||isNaN(a))&&(a=null),n.slice(1).forEach((function(n){var r=e.cloneNode(!0);r.setAttribute("data-line-numbers",Ad.serializeHighlightSteps([n])),r.classList.add("fragment"),e.parentNode.appendChild(r),Ad.highlightLines(r),"number"==typeof a?(r.setAttribute("data-fragment-index",a),a+=1):r.removeAttribute("data-fragment-index"),r.addEventListener("visible",Ad.scrollHighlightedLineIntoView.bind(Ad,r,t)),r.addEventListener("hidden",Ad.scrollHighlightedLineIntoView.bind(Ad,r.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",Ad.serializeHighlightSteps([n[0]]))}var r="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(r){r.addEventListener("visible",(function n(){Ad.scrollHighlightedLineIntoView(e,t,!0),r.removeEventListener("visible",n)}))}Ad.highlightLines(e)}},scrollHighlightedLineIntoView:function(e,t,n){cancelAnimationFrame(t.animationFrameID),t.currentBlock&&(e.scrollTop=t.currentBlock.scrollTop),t.currentBlock=e;var a=this.getHighlightedLineBounds(e),r=e.offsetHeight,i=getComputedStyle(e);r-=parseInt(i.paddingTop)+parseInt(i.paddingBottom);var o=e.scrollTop,s=a.top+(Math.min(a.bottom-a.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===n||o===s)e.scrollTop=s;else{if(e.scrollHeight<=r)return;var c=0;!function n(){c=Math.min(c+.02,1),e.scrollTop=o+(s-o)*Ad.easeInOutQuart(c),c<1&&(t.animationFrameID=requestAnimationFrame(n))}()}},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 n=t[0],a=t[t.length-1];return{top:n.offsetTop,bottom:a.offsetTop+a.offsetHeight}},highlightLines:function(e,t){var n=Ad.deserializeHighlightSteps(t||e.getAttribute("data-line-numbers"));n.length&&n[0].forEach((function(t){var n=[];"number"==typeof t.end?n=[].slice.call(e.querySelectorAll("table tr:nth-child(n+"+t.start+"):nth-child(-n+"+t.end+")")):"number"==typeof t.start&&(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=e.replace(/\s/g,"")).split(Ad.HIGHLIGHT_STEP_DELIMITER)).map((function(e){return e.split(Ad.HIGHLIGHT_LINE_DELIMITER).map((function(e){if(/^[\d-]+$/.test(e)){e=e.split(Ad.HIGHLIGHT_LINE_RANGE_DELIMITER);var t=parseInt(e[0],10),n=parseInt(e[1],10);return isNaN(n)?{start:t}:{start:t,end:n}}return{}}))}))},serializeHighlightSteps:function(e){return e.map((function(e){return e.map((function(e){return"number"==typeof e.end?e.start+Ad.HIGHLIGHT_LINE_RANGE_DELIMITER+e.end:"number"==typeof e.start?e.start:""})).join(Ad.HIGHLIGHT_LINE_DELIMITER)})).join(Ad.HIGHLIGHT_STEP_DELIMITER)}};export default function(){return Ad}

View File

@ -2,4 +2,4 @@
/*!
* reveal.js plugin that adds syntax highlight support.
*/
var Kd={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:Qd,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 n=e.querySelector('script[type="text/template"]');n&&(e.textContent=n.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 n(e){for(var t=e.split("\n"),n=0;n<t.length&&""===t[n].trim();n++)t.splice(n--,1);for(n=t.length-1;n>=0&&""===t[n].trim();n--)t.splice(n,1);return t.join("\n")}return function(e){var a=n(e.innerHTML).split("\n"),r=a.reduce((function(e,n){return n.length>0&&t(n).length>0&&e>n.length-t(n).length?n.length-t(n).length:e}),Number.POSITIVE_INFINITY);return a.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){Qd.highlightBlock(e.currentTarget)}),!1),t.highlightOnLoad&&Kd.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){Kd.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(Qd.highlightBlock(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){Qd.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},n=Kd.deserializeHighlightSteps(e.getAttribute("data-line-numbers"));if(n.length>1){var a=parseInt(e.getAttribute("data-fragment-index"),10);("number"!=typeof a||isNaN(a))&&(a=null),n.slice(1).forEach((function(n){var r=e.cloneNode(!0);r.setAttribute("data-line-numbers",Kd.serializeHighlightSteps([n])),r.classList.add("fragment"),e.parentNode.appendChild(r),Kd.highlightLines(r),"number"==typeof a?(r.setAttribute("data-fragment-index",a),a+=1):r.removeAttribute("data-fragment-index"),r.addEventListener("visible",Kd.scrollHighlightedLineIntoView.bind(Kd,r,t)),r.addEventListener("hidden",Kd.scrollHighlightedLineIntoView.bind(Kd,r.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",Kd.serializeHighlightSteps([n[0]]))}var r="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(r){r.addEventListener("visible",(function n(){Kd.scrollHighlightedLineIntoView(e,t,!0),r.removeEventListener("visible",n)}))}Kd.highlightLines(e)}},scrollHighlightedLineIntoView:function(e,t,n){cancelAnimationFrame(t.animationFrameID),t.currentBlock&&(e.scrollTop=t.currentBlock.scrollTop),t.currentBlock=e;var a=this.getHighlightedLineBounds(e),r=e.offsetHeight,i=getComputedStyle(e);r-=parseInt(i.paddingTop)+parseInt(i.paddingBottom);var o=e.scrollTop,s=a.top+(Math.min(a.bottom-a.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===n||o===s)e.scrollTop=s;else{if(e.scrollHeight<=r)return;var c=0;!function n(){c=Math.min(c+.02,1),e.scrollTop=o+(s-o)*Kd.easeInOutQuart(c),c<1&&(t.animationFrameID=requestAnimationFrame(n))}()}},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 n=t[0],a=t[t.length-1];return{top:n.offsetTop,bottom:a.offsetTop+a.offsetHeight}},highlightLines:function(e,t){var n=Kd.deserializeHighlightSteps(t||e.getAttribute("data-line-numbers"));n.length&&n[0].forEach((function(t){var n=[];"number"==typeof t.end?n=[].slice.call(e.querySelectorAll("table tr:nth-child(n+"+t.start+"):nth-child(-n+"+t.end+")")):"number"==typeof t.start&&(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=e.replace(/\s/g,"")).split(Kd.HIGHLIGHT_STEP_DELIMITER)).map((function(e){return e.split(Kd.HIGHLIGHT_LINE_DELIMITER).map((function(e){if(/^[\d-]+$/.test(e)){e=e.split(Kd.HIGHLIGHT_LINE_RANGE_DELIMITER);var t=parseInt(e[0],10),n=parseInt(e[1],10);return isNaN(n)?{start:t}:{start:t,end:n}}return{}}))}))},serializeHighlightSteps:function(e){return e.map((function(e){return e.map((function(e){return"number"==typeof e.end?e.start+Kd.HIGHLIGHT_LINE_RANGE_DELIMITER+e.end:"number"==typeof e.start?e.start:""})).join(Kd.HIGHLIGHT_LINE_DELIMITER)})).join(Kd.HIGHLIGHT_STEP_DELIMITER)}};return function(){return Kd}}));
var Kd={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:Qd,init:function(e){var t=e.getConfig().highlight||{};t.callback="function"==typeof t.callback?t.callback:null,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 n=e.querySelector('script[type="text/template"]');n&&(e.textContent=n.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 n(e){for(var t=e.split("\n"),n=0;n<t.length&&""===t[n].trim();n++)t.splice(n--,1);for(n=t.length-1;n>=0&&""===t[n].trim();n--)t.splice(n,1);return t.join("\n")}return function(e){var a=n(e.innerHTML).split("\n"),r=a.reduce((function(e,n){return n.length>0&&t(n).length>0&&e>n.length-t(n).length?n.length-t(n).length:e}),Number.POSITIVE_INFINITY);return a.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){Qd.highlightBlock(e.currentTarget)}),!1),t.callback&&t.callback(Qd),t.highlightOnLoad&&Kd.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){Kd.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(Qd.highlightBlock(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){Qd.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},n=Kd.deserializeHighlightSteps(e.getAttribute("data-line-numbers"));if(n.length>1){var a=parseInt(e.getAttribute("data-fragment-index"),10);("number"!=typeof a||isNaN(a))&&(a=null),n.slice(1).forEach((function(n){var r=e.cloneNode(!0);r.setAttribute("data-line-numbers",Kd.serializeHighlightSteps([n])),r.classList.add("fragment"),e.parentNode.appendChild(r),Kd.highlightLines(r),"number"==typeof a?(r.setAttribute("data-fragment-index",a),a+=1):r.removeAttribute("data-fragment-index"),r.addEventListener("visible",Kd.scrollHighlightedLineIntoView.bind(Kd,r,t)),r.addEventListener("hidden",Kd.scrollHighlightedLineIntoView.bind(Kd,r.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",Kd.serializeHighlightSteps([n[0]]))}var r="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(r){r.addEventListener("visible",(function n(){Kd.scrollHighlightedLineIntoView(e,t,!0),r.removeEventListener("visible",n)}))}Kd.highlightLines(e)}},scrollHighlightedLineIntoView:function(e,t,n){cancelAnimationFrame(t.animationFrameID),t.currentBlock&&(e.scrollTop=t.currentBlock.scrollTop),t.currentBlock=e;var a=this.getHighlightedLineBounds(e),r=e.offsetHeight,i=getComputedStyle(e);r-=parseInt(i.paddingTop)+parseInt(i.paddingBottom);var o=e.scrollTop,s=a.top+(Math.min(a.bottom-a.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===n||o===s)e.scrollTop=s;else{if(e.scrollHeight<=r)return;var c=0;!function n(){c=Math.min(c+.02,1),e.scrollTop=o+(s-o)*Kd.easeInOutQuart(c),c<1&&(t.animationFrameID=requestAnimationFrame(n))}()}},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 n=t[0],a=t[t.length-1];return{top:n.offsetTop,bottom:a.offsetTop+a.offsetHeight}},highlightLines:function(e,t){var n=Kd.deserializeHighlightSteps(t||e.getAttribute("data-line-numbers"));n.length&&n[0].forEach((function(t){var n=[];"number"==typeof t.end?n=[].slice.call(e.querySelectorAll("table tr:nth-child(n+"+t.start+"):nth-child(-n+"+t.end+")")):"number"==typeof t.start&&(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=e.replace(/\s/g,"")).split(Kd.HIGHLIGHT_STEP_DELIMITER)).map((function(e){return e.split(Kd.HIGHLIGHT_LINE_DELIMITER).map((function(e){if(/^[\d-]+$/.test(e)){e=e.split(Kd.HIGHLIGHT_LINE_RANGE_DELIMITER);var t=parseInt(e[0],10),n=parseInt(e[1],10);return isNaN(n)?{start:t}:{start:t,end:n}}return{}}))}))},serializeHighlightSteps:function(e){return e.map((function(e){return e.map((function(e){return"number"==typeof e.end?e.start+Kd.HIGHLIGHT_LINE_RANGE_DELIMITER+e.end:"number"==typeof e.start?e.start:""})).join(Kd.HIGHLIGHT_LINE_DELIMITER)})).join(Kd.HIGHLIGHT_STEP_DELIMITER)}};return function(){return Kd}}));

View File

@ -30,6 +30,7 @@ const Plugin = {
// Read the plugin config options and provide fallbacks
var config = reveal.getConfig().highlight || {};
config.callback = typeof config.callback === 'function' ? config.callback : null;
config.highlightOnLoad = typeof config.highlightOnLoad === 'boolean' ? config.highlightOnLoad : true;
config.escapeHTML = typeof config.escapeHTML === 'boolean' ? config.escapeHTML : true;
@ -59,6 +60,11 @@ const Plugin = {
hljs.highlightBlock( event.currentTarget );
}, false );
// Allow users to register additional languages via callback
if ( config.callback ) {
config.callback( hljs );
}
if( config.highlightOnLoad ) {
Plugin.highlightBlock( block );
}
@ -87,7 +93,7 @@ const Plugin = {
hljs.highlightBlock( block );
// Don't generate line numbers for empty code blocks
// Don't generate line numbers for empty code blocks
if( block.innerHTML.trim().length === 0 ) return;
if( block.hasAttribute( 'data-line-numbers' ) ) {