Correctly strip leading white-space from markdown
If the markdown contains something that is indented by more that the `leadingTabs`/`leadingWs` then extra white space is incorrectly removed. ie the following example: ``` <section data-markdown> some text indented text more indented text </section> ``` would result in the following markdown: ``` some text indented text more indented text ``` We can work around this problem by using a function to generate the replace value.
This commit is contained in:
parent
b1a9842b2f
commit
ae652a8e4e
|
@ -4,4 +4,4 @@ function e(){return{baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,h
|
||||||
* markdown inside of presentations as well as loading
|
* markdown inside of presentations as well as loading
|
||||||
* of external markdown documents.
|
* of external markdown documents.
|
||||||
*/
|
*/
|
||||||
const D="__SCRIPT_END__",P=/\[([\s\d,|-]*)\]/,M={"&":"&","<":"<",">":">",'"':""","'":"'"};export default()=>{let e;function t(e){var t=(e.querySelector("[data-template]")||e.querySelector("script")||e).textContent,n=(t=t.replace(new RegExp(D,"g"),"<\/script>")).match(/^\n?(\s*)/)[1].length,r=t.match(/^\n?(\t*)/)[1].length;return r>0?t=t.replace(new RegExp("\\n?\\t{"+r+"}","g"),"\n"):n>1&&(t=t.replace(new RegExp("\\n? {"+n+"}","g"),"\n")),t}function n(e){for(var t=e.attributes,n=[],r=0,s=t.length;r<s;r++){var i=t[r].name,l=t[r].value;/data\-(markdown|separator|vertical|notes)/gi.test(i)||(l?n.push(i+'="'+l+'"'):n.push(i))}return n.join(" ")}function r(e){return(e=e||{}).separator=e.separator||"\r?\n---\r?\n",e.notesSeparator=e.notesSeparator||"notes?:",e.attributes=e.attributes||"",e}function s(e,t){t=r(t);var n=e.split(new RegExp(t.notesSeparator,"mgi"));return 2===n.length&&(e=n[0]+'<aside class="notes">'+N(n[1].trim())+"</aside>"),'<script type="text/template">'+(e=e.replace(/<\/script>/g,D))+"<\/script>"}function i(e,t){t=r(t);for(var n,i,l,a=new RegExp(t.separator+(t.verticalSeparator?"|"+t.verticalSeparator:""),"mg"),o=new RegExp(t.separator),c=0,h=!0,p=[];n=a.exec(e);)!(i=o.test(n[0]))&&h&&p.push([]),l=e.substring(c,n.index),i&&h?p.push(l):p[p.length-1].push(l),c=a.lastIndex,h=i;(h?p:p[p.length-1]).push(e.substring(c));for(var u="",g=0,d=p.length;g<d;g++)p[g]instanceof Array?(u+="<section "+t.attributes+">",p[g].forEach((function(e){u+="<section data-markdown>"+s(e,t)+"</section>"})),u+="</section>"):u+="<section "+t.attributes+" data-markdown>"+s(p[g],t)+"</section>";return u}function l(e){return new Promise((function(r){var s=[];[].slice.call(e.querySelectorAll("section[data-markdown]:not([data-markdown-parsed])")).forEach((function(e,r){e.getAttribute("data-markdown").length?s.push(function(e){return new Promise((function(t,n){var r=new XMLHttpRequest,s=e.getAttribute("data-markdown"),i=e.getAttribute("data-charset");null!=i&&""!=i&&r.overrideMimeType("text/html; charset="+i),r.onreadystatechange=function(e,r){4===r.readyState&&(r.status>=200&&r.status<300||0===r.status?t(r,s):n(r,s))}.bind(this,e,r),r.open("GET",s,!0);try{r.send()}catch(e){console.warn("Failed to get the Markdown file "+s+". Make sure that the presentation and the file are served by a HTTP server and the file can be found there. "+e),t(r,s)}}))}(e).then((function(t,r){e.outerHTML=i(t.responseText,{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)})}),(function(t,n){e.outerHTML='<section data-state="alert">ERROR: The attempt to fetch '+n+" failed with HTTP status "+t.status+".Check your browser's JavaScript console for more details.<p>Remember that you need to serve the presentation HTML from a HTTP server.</p></section>"}))):e.outerHTML=i(t(e),{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)})})),Promise.all(s).then(r)}))}function a(e,t,n){var r,s,i=new RegExp(n,"mg"),l=new RegExp('([^"= ]+?)="([^"]+?)"|(data-[^"= ]+?)(?=[" ])',"mg"),a=e.nodeValue;if(r=i.exec(a)){var o=r[1];for(a=a.substring(0,r.index)+a.substring(i.lastIndex),e.nodeValue=a;s=l.exec(o);)s[2]?t.setAttribute(s[1],s[2]):t.setAttribute(s[3],"");return!0}return!1}function o(e,t,n,r,s){if(null!=t&&null!=t.childNodes&&t.childNodes.length>0)for(var i=t,l=0;l<t.childNodes.length;l++){var c=t.childNodes[l];if(l>0)for(var h=l-1;h>=0;){var p=t.childNodes[h];if("function"==typeof p.setAttribute&&"BR"!=p.tagName){i=p;break}h-=1}var u=e;"section"==c.nodeName&&(u=c,i=c),"function"!=typeof c.setAttribute&&c.nodeType!=Node.COMMENT_NODE||o(u,c,i,r,s)}t.nodeType==Node.COMMENT_NODE&&0==a(t,n,r)&&a(t,e,s)}function c(){var n=e.getRevealElement().querySelectorAll("[data-markdown]:not([data-markdown-parsed])");return[].slice.call(n).forEach((function(e){e.setAttribute("data-markdown-parsed",!0);var n=e.querySelector("aside.notes"),r=t(e);e.innerHTML=N(r),o(e,e,null,e.getAttribute("data-element-attributes")||e.parentNode.getAttribute("data-element-attributes")||"\\.element\\s*?(.+?)$",e.getAttribute("data-attributes")||e.parentNode.getAttribute("data-attributes")||"\\.slide:\\s*?(\\S.+?)$"),n&&e.appendChild(n)})),Promise.resolve()}return{id:"markdown",init:function(t){e=t;let{renderer:n,animateLists:r,...s}=e.getConfig().markdown||{};return n||(n=new N.Renderer,n.code=(e,t)=>{let n="";return P.test(t)&&(n=t.match(P)[1].trim(),n=`data-line-numbers="${n}"`,t=t.replace(P,"").trim()),`<pre><code ${n} class="${t}">${e=e.replace(/([&<>'"])/g,(e=>M[e]))}</code></pre>`}),!0===r&&(n.listitem=e=>`<li class="fragment">${e}</li>`),N.setOptions({renderer:n,...s}),l(e.getRevealElement()).then(c)},processSlides:l,convertSlides:c,slidify:i,marked:N}};
|
const D="__SCRIPT_END__",P=/\[([\s\d,|-]*)\]/,M={"&":"&","<":"<",">":">",'"':""","'":"'"};export default()=>{let e;function t(e){var t=(e.querySelector("[data-template]")||e.querySelector("script")||e).textContent,n=(t=t.replace(new RegExp(D,"g"),"<\/script>")).match(/^\n?(\s*)/)[1].length,r=t.match(/^\n?(\t*)/)[1].length;return r>0?t=t.replace(new RegExp("\\n?\\t{"+r+"}(.*)","g"),(function(e,t){return"\n"+t})):n>1&&(t=t.replace(new RegExp("\\n? {"+n+"}(.*)","g"),(function(e,t){return"\n"+t}))),t}function n(e){for(var t=e.attributes,n=[],r=0,s=t.length;r<s;r++){var i=t[r].name,l=t[r].value;/data\-(markdown|separator|vertical|notes)/gi.test(i)||(l?n.push(i+'="'+l+'"'):n.push(i))}return n.join(" ")}function r(e){return(e=e||{}).separator=e.separator||"\r?\n---\r?\n",e.notesSeparator=e.notesSeparator||"notes?:",e.attributes=e.attributes||"",e}function s(e,t){t=r(t);var n=e.split(new RegExp(t.notesSeparator,"mgi"));return 2===n.length&&(e=n[0]+'<aside class="notes">'+N(n[1].trim())+"</aside>"),'<script type="text/template">'+(e=e.replace(/<\/script>/g,D))+"<\/script>"}function i(e,t){t=r(t);for(var n,i,l,a=new RegExp(t.separator+(t.verticalSeparator?"|"+t.verticalSeparator:""),"mg"),o=new RegExp(t.separator),c=0,h=!0,p=[];n=a.exec(e);)!(i=o.test(n[0]))&&h&&p.push([]),l=e.substring(c,n.index),i&&h?p.push(l):p[p.length-1].push(l),c=a.lastIndex,h=i;(h?p:p[p.length-1]).push(e.substring(c));for(var u="",g=0,d=p.length;g<d;g++)p[g]instanceof Array?(u+="<section "+t.attributes+">",p[g].forEach((function(e){u+="<section data-markdown>"+s(e,t)+"</section>"})),u+="</section>"):u+="<section "+t.attributes+" data-markdown>"+s(p[g],t)+"</section>";return u}function l(e){return new Promise((function(r){var s=[];[].slice.call(e.querySelectorAll("section[data-markdown]:not([data-markdown-parsed])")).forEach((function(e,r){e.getAttribute("data-markdown").length?s.push(function(e){return new Promise((function(t,n){var r=new XMLHttpRequest,s=e.getAttribute("data-markdown"),i=e.getAttribute("data-charset");null!=i&&""!=i&&r.overrideMimeType("text/html; charset="+i),r.onreadystatechange=function(e,r){4===r.readyState&&(r.status>=200&&r.status<300||0===r.status?t(r,s):n(r,s))}.bind(this,e,r),r.open("GET",s,!0);try{r.send()}catch(e){console.warn("Failed to get the Markdown file "+s+". Make sure that the presentation and the file are served by a HTTP server and the file can be found there. "+e),t(r,s)}}))}(e).then((function(t,r){e.outerHTML=i(t.responseText,{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)})}),(function(t,n){e.outerHTML='<section data-state="alert">ERROR: The attempt to fetch '+n+" failed with HTTP status "+t.status+".Check your browser's JavaScript console for more details.<p>Remember that you need to serve the presentation HTML from a HTTP server.</p></section>"}))):e.outerHTML=i(t(e),{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)})})),Promise.all(s).then(r)}))}function a(e,t,n){var r,s,i=new RegExp(n,"mg"),l=new RegExp('([^"= ]+?)="([^"]+?)"|(data-[^"= ]+?)(?=[" ])',"mg"),a=e.nodeValue;if(r=i.exec(a)){var o=r[1];for(a=a.substring(0,r.index)+a.substring(i.lastIndex),e.nodeValue=a;s=l.exec(o);)s[2]?t.setAttribute(s[1],s[2]):t.setAttribute(s[3],"");return!0}return!1}function o(e,t,n,r,s){if(null!=t&&null!=t.childNodes&&t.childNodes.length>0)for(var i=t,l=0;l<t.childNodes.length;l++){var c=t.childNodes[l];if(l>0)for(var h=l-1;h>=0;){var p=t.childNodes[h];if("function"==typeof p.setAttribute&&"BR"!=p.tagName){i=p;break}h-=1}var u=e;"section"==c.nodeName&&(u=c,i=c),"function"!=typeof c.setAttribute&&c.nodeType!=Node.COMMENT_NODE||o(u,c,i,r,s)}t.nodeType==Node.COMMENT_NODE&&0==a(t,n,r)&&a(t,e,s)}function c(){var n=e.getRevealElement().querySelectorAll("[data-markdown]:not([data-markdown-parsed])");return[].slice.call(n).forEach((function(e){e.setAttribute("data-markdown-parsed",!0);var n=e.querySelector("aside.notes"),r=t(e);e.innerHTML=N(r),o(e,e,null,e.getAttribute("data-element-attributes")||e.parentNode.getAttribute("data-element-attributes")||"\\.element\\s*?(.+?)$",e.getAttribute("data-attributes")||e.parentNode.getAttribute("data-attributes")||"\\.slide:\\s*?(\\S.+?)$"),n&&e.appendChild(n)})),Promise.resolve()}return{id:"markdown",init:function(t){e=t;let{renderer:n,animateLists:r,...s}=e.getConfig().markdown||{};return n||(n=new N.Renderer,n.code=(e,t)=>{let n="";return P.test(t)&&(n=t.match(P)[1].trim(),n=`data-line-numbers="${n}"`,t=t.replace(P,"").trim()),`<pre><code ${n} class="${t}">${e=e.replace(/([&<>'"])/g,(e=>M[e]))}</code></pre>`}),!0===r&&(n.listitem=e=>`<li class="fragment">${e}</li>`),N.setOptions({renderer:n,...s}),l(e.getRevealElement()).then(c)},processSlides:l,convertSlides:c,slidify:i,marked:N}};
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
* markdown inside of presentations as well as loading
|
* markdown inside of presentations as well as loading
|
||||||
* of external markdown documents.
|
* of external markdown documents.
|
||||||
*/
|
*/
|
||||||
const D="__SCRIPT_END__",M=/\[([\s\d,|-]*)\]/,P={"&":"&","<":"<",">":">",'"':""","'":"'"};return()=>{let e;function t(e){var t=(e.querySelector("[data-template]")||e.querySelector("script")||e).textContent,n=(t=t.replace(new RegExp(D,"g"),"<\/script>")).match(/^\n?(\s*)/)[1].length,r=t.match(/^\n?(\t*)/)[1].length;return r>0?t=t.replace(new RegExp("\\n?\\t{"+r+"}","g"),"\n"):n>1&&(t=t.replace(new RegExp("\\n? {"+n+"}","g"),"\n")),t}function n(e){for(var t=e.attributes,n=[],r=0,s=t.length;r<s;r++){var i=t[r].name,l=t[r].value;/data\-(markdown|separator|vertical|notes)/gi.test(i)||(l?n.push(i+'="'+l+'"'):n.push(i))}return n.join(" ")}function r(e){return(e=e||{}).separator=e.separator||"\r?\n---\r?\n",e.notesSeparator=e.notesSeparator||"notes?:",e.attributes=e.attributes||"",e}function s(e,t){t=r(t);var n=e.split(new RegExp(t.notesSeparator,"mgi"));return 2===n.length&&(e=n[0]+'<aside class="notes">'+N(n[1].trim())+"</aside>"),'<script type="text/template">'+(e=e.replace(/<\/script>/g,D))+"<\/script>"}function i(e,t){t=r(t);for(var n,i,l,a=new RegExp(t.separator+(t.verticalSeparator?"|"+t.verticalSeparator:""),"mg"),o=new RegExp(t.separator),c=0,h=!0,p=[];n=a.exec(e);)!(i=o.test(n[0]))&&h&&p.push([]),l=e.substring(c,n.index),i&&h?p.push(l):p[p.length-1].push(l),c=a.lastIndex,h=i;(h?p:p[p.length-1]).push(e.substring(c));for(var u="",g=0,d=p.length;g<d;g++)p[g]instanceof Array?(u+="<section "+t.attributes+">",p[g].forEach((function(e){u+="<section data-markdown>"+s(e,t)+"</section>"})),u+="</section>"):u+="<section "+t.attributes+" data-markdown>"+s(p[g],t)+"</section>";return u}function l(e){return new Promise((function(r){var s=[];[].slice.call(e.querySelectorAll("section[data-markdown]:not([data-markdown-parsed])")).forEach((function(e,r){e.getAttribute("data-markdown").length?s.push(function(e){return new Promise((function(t,n){var r=new XMLHttpRequest,s=e.getAttribute("data-markdown"),i=e.getAttribute("data-charset");null!=i&&""!=i&&r.overrideMimeType("text/html; charset="+i),r.onreadystatechange=function(e,r){4===r.readyState&&(r.status>=200&&r.status<300||0===r.status?t(r,s):n(r,s))}.bind(this,e,r),r.open("GET",s,!0);try{r.send()}catch(e){console.warn("Failed to get the Markdown file "+s+". Make sure that the presentation and the file are served by a HTTP server and the file can be found there. "+e),t(r,s)}}))}(e).then((function(t,r){e.outerHTML=i(t.responseText,{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)})}),(function(t,n){e.outerHTML='<section data-state="alert">ERROR: The attempt to fetch '+n+" failed with HTTP status "+t.status+".Check your browser's JavaScript console for more details.<p>Remember that you need to serve the presentation HTML from a HTTP server.</p></section>"}))):e.outerHTML=i(t(e),{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)})})),Promise.all(s).then(r)}))}function a(e,t,n){var r,s,i=new RegExp(n,"mg"),l=new RegExp('([^"= ]+?)="([^"]+?)"|(data-[^"= ]+?)(?=[" ])',"mg"),a=e.nodeValue;if(r=i.exec(a)){var o=r[1];for(a=a.substring(0,r.index)+a.substring(i.lastIndex),e.nodeValue=a;s=l.exec(o);)s[2]?t.setAttribute(s[1],s[2]):t.setAttribute(s[3],"");return!0}return!1}function o(e,t,n,r,s){if(null!=t&&null!=t.childNodes&&t.childNodes.length>0)for(var i=t,l=0;l<t.childNodes.length;l++){var c=t.childNodes[l];if(l>0)for(var h=l-1;h>=0;){var p=t.childNodes[h];if("function"==typeof p.setAttribute&&"BR"!=p.tagName){i=p;break}h-=1}var u=e;"section"==c.nodeName&&(u=c,i=c),"function"!=typeof c.setAttribute&&c.nodeType!=Node.COMMENT_NODE||o(u,c,i,r,s)}t.nodeType==Node.COMMENT_NODE&&0==a(t,n,r)&&a(t,e,s)}function c(){var n=e.getRevealElement().querySelectorAll("[data-markdown]:not([data-markdown-parsed])");return[].slice.call(n).forEach((function(e){e.setAttribute("data-markdown-parsed",!0);var n=e.querySelector("aside.notes"),r=t(e);e.innerHTML=N(r),o(e,e,null,e.getAttribute("data-element-attributes")||e.parentNode.getAttribute("data-element-attributes")||"\\.element\\s*?(.+?)$",e.getAttribute("data-attributes")||e.parentNode.getAttribute("data-attributes")||"\\.slide:\\s*?(\\S.+?)$"),n&&e.appendChild(n)})),Promise.resolve()}return{id:"markdown",init:function(t){e=t;let{renderer:n,animateLists:r,...s}=e.getConfig().markdown||{};return n||(n=new N.Renderer,n.code=(e,t)=>{let n="";return M.test(t)&&(n=t.match(M)[1].trim(),n=`data-line-numbers="${n}"`,t=t.replace(M,"").trim()),`<pre><code ${n} class="${t}">${e=e.replace(/([&<>'"])/g,(e=>P[e]))}</code></pre>`}),!0===r&&(n.listitem=e=>`<li class="fragment">${e}</li>`),N.setOptions({renderer:n,...s}),l(e.getRevealElement()).then(c)},processSlides:l,convertSlides:c,slidify:i,marked:N}}}));
|
const D="__SCRIPT_END__",M=/\[([\s\d,|-]*)\]/,P={"&":"&","<":"<",">":">",'"':""","'":"'"};return()=>{let e;function t(e){var t=(e.querySelector("[data-template]")||e.querySelector("script")||e).textContent,n=(t=t.replace(new RegExp(D,"g"),"<\/script>")).match(/^\n?(\s*)/)[1].length,r=t.match(/^\n?(\t*)/)[1].length;return r>0?t=t.replace(new RegExp("\\n?\\t{"+r+"}(.*)","g"),(function(e,t){return"\n"+t})):n>1&&(t=t.replace(new RegExp("\\n? {"+n+"}(.*)","g"),(function(e,t){return"\n"+t}))),t}function n(e){for(var t=e.attributes,n=[],r=0,s=t.length;r<s;r++){var i=t[r].name,l=t[r].value;/data\-(markdown|separator|vertical|notes)/gi.test(i)||(l?n.push(i+'="'+l+'"'):n.push(i))}return n.join(" ")}function r(e){return(e=e||{}).separator=e.separator||"\r?\n---\r?\n",e.notesSeparator=e.notesSeparator||"notes?:",e.attributes=e.attributes||"",e}function s(e,t){t=r(t);var n=e.split(new RegExp(t.notesSeparator,"mgi"));return 2===n.length&&(e=n[0]+'<aside class="notes">'+N(n[1].trim())+"</aside>"),'<script type="text/template">'+(e=e.replace(/<\/script>/g,D))+"<\/script>"}function i(e,t){t=r(t);for(var n,i,l,a=new RegExp(t.separator+(t.verticalSeparator?"|"+t.verticalSeparator:""),"mg"),o=new RegExp(t.separator),c=0,h=!0,p=[];n=a.exec(e);)!(i=o.test(n[0]))&&h&&p.push([]),l=e.substring(c,n.index),i&&h?p.push(l):p[p.length-1].push(l),c=a.lastIndex,h=i;(h?p:p[p.length-1]).push(e.substring(c));for(var u="",g=0,d=p.length;g<d;g++)p[g]instanceof Array?(u+="<section "+t.attributes+">",p[g].forEach((function(e){u+="<section data-markdown>"+s(e,t)+"</section>"})),u+="</section>"):u+="<section "+t.attributes+" data-markdown>"+s(p[g],t)+"</section>";return u}function l(e){return new Promise((function(r){var s=[];[].slice.call(e.querySelectorAll("section[data-markdown]:not([data-markdown-parsed])")).forEach((function(e,r){e.getAttribute("data-markdown").length?s.push(function(e){return new Promise((function(t,n){var r=new XMLHttpRequest,s=e.getAttribute("data-markdown"),i=e.getAttribute("data-charset");null!=i&&""!=i&&r.overrideMimeType("text/html; charset="+i),r.onreadystatechange=function(e,r){4===r.readyState&&(r.status>=200&&r.status<300||0===r.status?t(r,s):n(r,s))}.bind(this,e,r),r.open("GET",s,!0);try{r.send()}catch(e){console.warn("Failed to get the Markdown file "+s+". Make sure that the presentation and the file are served by a HTTP server and the file can be found there. "+e),t(r,s)}}))}(e).then((function(t,r){e.outerHTML=i(t.responseText,{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)})}),(function(t,n){e.outerHTML='<section data-state="alert">ERROR: The attempt to fetch '+n+" failed with HTTP status "+t.status+".Check your browser's JavaScript console for more details.<p>Remember that you need to serve the presentation HTML from a HTTP server.</p></section>"}))):e.outerHTML=i(t(e),{separator:e.getAttribute("data-separator"),verticalSeparator:e.getAttribute("data-separator-vertical"),notesSeparator:e.getAttribute("data-separator-notes"),attributes:n(e)})})),Promise.all(s).then(r)}))}function a(e,t,n){var r,s,i=new RegExp(n,"mg"),l=new RegExp('([^"= ]+?)="([^"]+?)"|(data-[^"= ]+?)(?=[" ])',"mg"),a=e.nodeValue;if(r=i.exec(a)){var o=r[1];for(a=a.substring(0,r.index)+a.substring(i.lastIndex),e.nodeValue=a;s=l.exec(o);)s[2]?t.setAttribute(s[1],s[2]):t.setAttribute(s[3],"");return!0}return!1}function o(e,t,n,r,s){if(null!=t&&null!=t.childNodes&&t.childNodes.length>0)for(var i=t,l=0;l<t.childNodes.length;l++){var c=t.childNodes[l];if(l>0)for(var h=l-1;h>=0;){var p=t.childNodes[h];if("function"==typeof p.setAttribute&&"BR"!=p.tagName){i=p;break}h-=1}var u=e;"section"==c.nodeName&&(u=c,i=c),"function"!=typeof c.setAttribute&&c.nodeType!=Node.COMMENT_NODE||o(u,c,i,r,s)}t.nodeType==Node.COMMENT_NODE&&0==a(t,n,r)&&a(t,e,s)}function c(){var n=e.getRevealElement().querySelectorAll("[data-markdown]:not([data-markdown-parsed])");return[].slice.call(n).forEach((function(e){e.setAttribute("data-markdown-parsed",!0);var n=e.querySelector("aside.notes"),r=t(e);e.innerHTML=N(r),o(e,e,null,e.getAttribute("data-element-attributes")||e.parentNode.getAttribute("data-element-attributes")||"\\.element\\s*?(.+?)$",e.getAttribute("data-attributes")||e.parentNode.getAttribute("data-attributes")||"\\.slide:\\s*?(\\S.+?)$"),n&&e.appendChild(n)})),Promise.resolve()}return{id:"markdown",init:function(t){e=t;let{renderer:n,animateLists:r,...s}=e.getConfig().markdown||{};return n||(n=new N.Renderer,n.code=(e,t)=>{let n="";return M.test(t)&&(n=t.match(M)[1].trim(),n=`data-line-numbers="${n}"`,t=t.replace(M,"").trim()),`<pre><code ${n} class="${t}">${e=e.replace(/([&<>'"])/g,(e=>P[e]))}</code></pre>`}),!0===r&&(n.listitem=e=>`<li class="fragment">${e}</li>`),N.setOptions({renderer:n,...s}),l(e.getRevealElement()).then(c)},processSlides:l,convertSlides:c,slidify:i,marked:N}}}));
|
||||||
|
|
|
@ -47,10 +47,10 @@ const Plugin = () => {
|
||||||
leadingTabs = text.match( /^\n?(\t*)/ )[1].length;
|
leadingTabs = text.match( /^\n?(\t*)/ )[1].length;
|
||||||
|
|
||||||
if( leadingTabs > 0 ) {
|
if( leadingTabs > 0 ) {
|
||||||
text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}','g'), '\n' );
|
text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}(.*)','g'), function(m, p1) { return '\n' + p1 ; } );
|
||||||
}
|
}
|
||||||
else if( leadingWs > 1 ) {
|
else if( leadingWs > 1 ) {
|
||||||
text = text.replace( new RegExp('\\n? {' + leadingWs + '}', 'g'), '\n' );
|
text = text.replace( new RegExp('\\n? {' + leadingWs + '}(.*)', 'g'), function(m, p1) { return '\n' + p1 ; } );
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
Loading…
Reference in New Issue