diff --git a/src/markdown/markdown.js b/src/markdown/markdown.js index 1b5d9a0..54eb2dc 100644 --- a/src/markdown/markdown.js +++ b/src/markdown/markdown.js @@ -204,6 +204,17 @@ export function markdownToHTML(text) { "$1" ); + // 6.2) Trim breaks around code blocks + html = html + .replace(new RegExp(`${brPattern}\\s*(?=
]*>[\\s\\S]*?<\\/div>)\\s*(?:${brPattern}\\s*)+`, + "g" + ), + "$1" + ); + // 7) Restore code blocks with header + copy button html = html.replace(/@@CODEBLOCK(\d+)@@/g, (_, idx) => { const { lang, code } = codeblocks[+idx];