diff --git a/src/lib/addBlankLines.spec.ts b/src/lib/addBlankLines.spec.ts index e4e837d..19bc6cb 100644 --- a/src/lib/addBlankLines.spec.ts +++ b/src/lib/addBlankLines.spec.ts @@ -33,4 +33,12 @@ describe("addBlankLines", () => { expect(result).toEqual('hello\nparagraph'); }); + + it("adds blank lines after html with a space at end", () => { + const markdown = "

title

\nparagraph"; + + const result = addBlankLines(markdown); + + expect(result).toEqual("

title

\n\nparagraph"); + }); }); diff --git a/src/lib/addBlankLines.ts b/src/lib/addBlankLines.ts index 6e83f71..376e018 100644 --- a/src/lib/addBlankLines.ts +++ b/src/lib/addBlankLines.ts @@ -1,7 +1,7 @@ // TODO: https://github.com/beeminder/blog/issues/354 const blockElements = "address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h\\d|header|hr|li|main|nav|noscript|ol|p|pre|section|table|tfoot|ul|video"; -const regex = new RegExp(`(]*>)\n+`, "g"); +const regex = new RegExp(`(]*>) *\n+`, "g"); export default function addBlankLines(markdown: string): string { return markdown.replace(regex, "$1\n\n");