From ae652a8e4e06bb59ebcb6bd9f4e220ed85038d30 Mon Sep 17 00:00:00 2001 From: John Kristensen Date: Thu, 2 Feb 2023 13:27:09 +0100 Subject: [PATCH] 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: ```
some text indented text more indented text
``` 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. --- plugin/markdown/markdown.esm.js | 2 +- plugin/markdown/markdown.js | 2 +- plugin/markdown/plugin.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/markdown/markdown.esm.js b/plugin/markdown/markdown.esm.js index e762a2d..c9fcf9f 100644 --- a/plugin/markdown/markdown.esm.js +++ b/plugin/markdown/markdown.esm.js @@ -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 * 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'+N(n[1].trim())+""),'