From 20d7c87a2f967004a4ef42f6389f8127f50ef546 Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Tue, 6 Jul 2021 18:19:10 +0200 Subject: [PATCH 1/4] fix(highlight): allow pre fragments --- plugin/highlight/plugin.js | 2 +- test/test-markdown.html | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugin/highlight/plugin.js b/plugin/highlight/plugin.js index ff2ac8b2..f31e1a29 100644 --- a/plugin/highlight/plugin.js +++ b/plugin/highlight/plugin.js @@ -35,7 +35,7 @@ const Plugin = { Array.from( reveal.getRevealElement().querySelectorAll( 'pre code' ) ).forEach( block => { - block.parentNode.className = 'code-wrapper'; + block.parentNode.classList.add('code-wrapper'); // Code can optionally be wrapped in script template to avoid // HTML being parsed by the browser (i.e. when you need to diff --git a/test/test-markdown.html b/test/test-markdown.html index d79246c9..d6d48584 100644 --- a/test/test-markdown.html +++ b/test/test-markdown.html @@ -281,6 +281,15 @@ ``` +
+ +
@@ -453,6 +462,11 @@ assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights-and-lanugage .hljs.javascript[data-line-numbers="1,2,3"]' ).length, 1 ); }); + + QUnit.test( '```block should allow custom fragment', function( assert ) { + assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.with-code-in-fragment pre.fragment' ).length, 1 ); + }); + } ); deck1.initialize(); From 4d443826ab29bb2ce78aabd733451719e864e00c Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Tue, 6 Jul 2021 18:28:07 +0200 Subject: [PATCH 2/4] Update build output for highlightjs --- plugin/highlight/highlight.esm.js | 2 +- plugin/highlight/highlight.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/highlight/highlight.esm.js b/plugin/highlight/highlight.esm.js index 61bddeb9..02f7cd47 100644 --- a/plugin/highlight/highlight.esm.js +++ b/plugin/highlight/highlight.esm.js @@ -2,4 +2,4 @@ function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterat /*! * reveal.js plugin that adds syntax highlight support. */ -var of={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:rf,init:function(e){var 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((function(e){e.parentNode.className="code-wrapper";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=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,">")),e.addEventListener("focusout",(function(e){rf.highlightElement(e.currentTarget)}),!1),t.highlightOnLoad&&of.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){of.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(rf.highlightElement(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){rf.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},n=of.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",of.serializeHighlightSteps([n])),r.classList.add("fragment"),e.parentNode.appendChild(r),of.highlightLines(r),"number"==typeof a?(r.setAttribute("data-fragment-index",a),a+=1):r.removeAttribute("data-fragment-index"),r.addEventListener("visible",of.scrollHighlightedLineIntoView.bind(of,r,t)),r.addEventListener("hidden",of.scrollHighlightedLineIntoView.bind(of,r.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",of.serializeHighlightSteps([n[0]]))}var r="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(r){r.addEventListener("visible",(function n(){of.scrollHighlightedLineIntoView(e,t,!0),r.removeEventListener("visible",n)}))}of.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)*of.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=of.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(of.HIGHLIGHT_STEP_DELIMITER)).map((function(e){return e.split(of.HIGHLIGHT_LINE_DELIMITER).map((function(e){if(/^[\d-]+$/.test(e)){e=e.split(of.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+of.HIGHLIGHT_LINE_RANGE_DELIMITER+e.end:"number"==typeof e.start?e.start:""})).join(of.HIGHLIGHT_LINE_DELIMITER)})).join(of.HIGHLIGHT_STEP_DELIMITER)}};export default function(){return of} +var of={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:rf,init:function(e){var 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((function(e){e.parentNode.classList.add("code-wrapper");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=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,">")),e.addEventListener("focusout",(function(e){rf.highlightElement(e.currentTarget)}),!1),t.highlightOnLoad&&of.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){of.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(rf.highlightElement(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){rf.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},n=of.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",of.serializeHighlightSteps([n])),r.classList.add("fragment"),e.parentNode.appendChild(r),of.highlightLines(r),"number"==typeof a?(r.setAttribute("data-fragment-index",a),a+=1):r.removeAttribute("data-fragment-index"),r.addEventListener("visible",of.scrollHighlightedLineIntoView.bind(of,r,t)),r.addEventListener("hidden",of.scrollHighlightedLineIntoView.bind(of,r.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",of.serializeHighlightSteps([n[0]]))}var r="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(r){r.addEventListener("visible",(function n(){of.scrollHighlightedLineIntoView(e,t,!0),r.removeEventListener("visible",n)}))}of.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)*of.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=of.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(of.HIGHLIGHT_STEP_DELIMITER)).map((function(e){return e.split(of.HIGHLIGHT_LINE_DELIMITER).map((function(e){if(/^[\d-]+$/.test(e)){e=e.split(of.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+of.HIGHLIGHT_LINE_RANGE_DELIMITER+e.end:"number"==typeof e.start?e.start:""})).join(of.HIGHLIGHT_LINE_DELIMITER)})).join(of.HIGHLIGHT_STEP_DELIMITER)}};export default function(){return of} diff --git a/plugin/highlight/highlight.js b/plugin/highlight/highlight.js index 0423db5b..8edd4571 100644 --- a/plugin/highlight/highlight.js +++ b/plugin/highlight/highlight.js @@ -2,4 +2,4 @@ /*! * reveal.js plugin that adds syntax highlight support. */ -var Lf={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:Mf,init:function(e){var 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((function(e){e.parentNode.className="code-wrapper";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=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,">")),e.addEventListener("focusout",(function(e){Mf.highlightElement(e.currentTarget)}),!1),t.highlightOnLoad&&Lf.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){Lf.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(Mf.highlightElement(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){Mf.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},n=Lf.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",Lf.serializeHighlightSteps([n])),r.classList.add("fragment"),e.parentNode.appendChild(r),Lf.highlightLines(r),"number"==typeof a?(r.setAttribute("data-fragment-index",a),a+=1):r.removeAttribute("data-fragment-index"),r.addEventListener("visible",Lf.scrollHighlightedLineIntoView.bind(Lf,r,t)),r.addEventListener("hidden",Lf.scrollHighlightedLineIntoView.bind(Lf,r.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",Lf.serializeHighlightSteps([n[0]]))}var r="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(r){r.addEventListener("visible",(function n(){Lf.scrollHighlightedLineIntoView(e,t,!0),r.removeEventListener("visible",n)}))}Lf.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)*Lf.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=Lf.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(Lf.HIGHLIGHT_STEP_DELIMITER)).map((function(e){return e.split(Lf.HIGHLIGHT_LINE_DELIMITER).map((function(e){if(/^[\d-]+$/.test(e)){e=e.split(Lf.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+Lf.HIGHLIGHT_LINE_RANGE_DELIMITER+e.end:"number"==typeof e.start?e.start:""})).join(Lf.HIGHLIGHT_LINE_DELIMITER)})).join(Lf.HIGHLIGHT_STEP_DELIMITER)}};return function(){return Lf}})); +var Lf={id:"highlight",HIGHLIGHT_STEP_DELIMITER:"|",HIGHLIGHT_LINE_DELIMITER:",",HIGHLIGHT_LINE_RANGE_DELIMITER:"-",hljs:Mf,init:function(e){var 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((function(e){e.parentNode.classList.add("code-wrapper");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=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,">")),e.addEventListener("focusout",(function(e){Mf.highlightElement(e.currentTarget)}),!1),t.highlightOnLoad&&Lf.highlightBlock(e)})),e.on("pdf-ready",(function(){[].slice.call(e.getRevealElement().querySelectorAll("pre code[data-line-numbers].current-fragment")).forEach((function(e){Lf.scrollHighlightedLineIntoView(e,{},!0)}))}))},highlightBlock:function(e){if(Mf.highlightElement(e),0!==e.innerHTML.trim().length&&e.hasAttribute("data-line-numbers")){Mf.lineNumbersBlock(e,{singleLine:!0});var t={currentBlock:e},n=Lf.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",Lf.serializeHighlightSteps([n])),r.classList.add("fragment"),e.parentNode.appendChild(r),Lf.highlightLines(r),"number"==typeof a?(r.setAttribute("data-fragment-index",a),a+=1):r.removeAttribute("data-fragment-index"),r.addEventListener("visible",Lf.scrollHighlightedLineIntoView.bind(Lf,r,t)),r.addEventListener("hidden",Lf.scrollHighlightedLineIntoView.bind(Lf,r.previousSibling,t))})),e.removeAttribute("data-fragment-index"),e.setAttribute("data-line-numbers",Lf.serializeHighlightSteps([n[0]]))}var r="function"==typeof e.closest?e.closest("section:not(.stack)"):null;if(r){r.addEventListener("visible",(function n(){Lf.scrollHighlightedLineIntoView(e,t,!0),r.removeEventListener("visible",n)}))}Lf.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)*Lf.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=Lf.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(Lf.HIGHLIGHT_STEP_DELIMITER)).map((function(e){return e.split(Lf.HIGHLIGHT_LINE_DELIMITER).map((function(e){if(/^[\d-]+$/.test(e)){e=e.split(Lf.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+Lf.HIGHLIGHT_LINE_RANGE_DELIMITER+e.end:"number"==typeof e.start?e.start:""})).join(Lf.HIGHLIGHT_LINE_DELIMITER)})).join(Lf.HIGHLIGHT_STEP_DELIMITER)}};return function(){return Lf}})); From 28509e0c39c614ae6876a6a83520ec693168f186 Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Tue, 6 Jul 2021 18:34:52 +0200 Subject: [PATCH 3/4] fix test --- test/test-markdown.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/test-markdown.html b/test/test-markdown.html index d6d48584..fd608043 100644 --- a/test/test-markdown.html +++ b/test/test-markdown.html @@ -286,7 +286,7 @@ ```js foo.bar(); ``` - + @@ -461,10 +461,9 @@ QUnit.test( '```javascript [1,2,3] enables line highlights and sets language', function( assert ) { assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights-and-lanugage .hljs.javascript[data-line-numbers="1,2,3"]' ).length, 1 ); }); - QUnit.test( '```block should allow custom fragment', function( assert ) { - assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.with-code-in-fragment pre.fragment' ).length, 1 ); + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-code-in-fragment pre.fragment' ).length, 1 ); }); } ); From 9ca5068eee0ec896504a4e62b80b7d68d63af165 Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Tue, 6 Jul 2021 22:05:20 +0200 Subject: [PATCH 4/4] Update whitespaces --- test/test-markdown.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test-markdown.html b/test/test-markdown.html index fd608043..b0ead9c5 100644 --- a/test/test-markdown.html +++ b/test/test-markdown.html @@ -283,13 +283,13 @@
-
+