1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:27:34 +00:00

LibMarkdown: Implement hard and soft line breaks

Hard line breaks insert a <br /> when two spaces are at the end of a
line. soft line breaks are just regular newlines, but whitespace is now
stripped before and after them
This commit is contained in:
Peter Elliott 2021-09-10 00:45:45 -06:00 committed by Andreas Kling
parent af5a07399e
commit 9c0563cc10
3 changed files with 75 additions and 3 deletions

View file

@ -92,6 +92,7 @@ OwnPtr<Document> Document::parse(const StringView& str)
if ((*lines).is_empty()) {
++lines;
flush_paragraph();
continue;
}
@ -108,8 +109,9 @@ OwnPtr<Document> Document::parse(const StringView& str)
continue;
}
if (!paragraph_text.is_empty())
paragraph_text.append("\n");
paragraph_text.append(*lines++);
paragraph_text.append("\n");
}
flush_paragraph();