Skip to content

Commit

Permalink
Omit empty lines from paragraph generation
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdburdick committed Jun 26, 2024
1 parent 4d79a6c commit 9919a39
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/convertNewLinesToHTML.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function convertNewLinesToHTML(inputString: string) {
const paragraphs = inputString.split("\n")

const htmlParagraphs = paragraphs.map((paragraph) => `<p>${paragraph}</p>`)
const htmlParagraphs = paragraphs
.filter(Boolean)
.map((paragraph) => `<p>${paragraph}</p>`)

const htmlString = htmlParagraphs.join("")

Expand Down

0 comments on commit 9919a39

Please sign in to comment.