Skip to content

Commit

Permalink
Merge pull request #401 from narthur/master
Browse files Browse the repository at this point in the history
Fix font mismatch
  • Loading branch information
narthur authored Oct 10, 2023
2 parents ff7ac51 + 74b5dab commit 2e84b98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/lib/addBlankLines.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ describe("addBlankLines", () => {

expect(result).toEqual('<a href="#">hello</a>\nparagraph');
});

it("adds blank lines after html with a space at end", () => {
const markdown = "<h4>title</h4> \nparagraph";

const result = addBlankLines(markdown);

expect(result).toEqual("<h4>title</h4>\n\nparagraph");
});
});
2 changes: 1 addition & 1 deletion src/lib/addBlankLines.ts
Original file line number Diff line number Diff line change
@@ -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(`(</?(${blockElements})[^>]*>)\n+`, "g");
const regex = new RegExp(`(</?(${blockElements})[^>]*>) *\n+`, "g");

export default function addBlankLines(markdown: string): string {
return markdown.replace(regex, "$1\n\n");
Expand Down

0 comments on commit 2e84b98

Please sign in to comment.