Fixes #1418 - Preserve new lines when parsing html strings

This commit is contained in:
Stefan Ceriu
2023-08-08 17:17:13 +03:00
committed by Stefan Ceriu
parent 0511bef33a
commit 35685db3c4
2 changed files with 19 additions and 2 deletions
@@ -396,6 +396,17 @@ class AttributedStringBuilderTests: XCTestCase {
XCTAssertEqual(numberOfBlockquotes, 3, "Couldn't find all the blockquotes")
}
func testNewLinesArePreserved() {
let htmlString = "Bob's\nyour\nuncle\nand\nFanny's\nyour\naunt"
guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else {
XCTFail("Could not build the attributed string")
return
}
XCTAssertEqual(String(attributedString.characters), htmlString.replacingOccurrences(of: "\n", with: "\u{2028}"))
}
// MARK: - Private
private func checkLinkIn(attributedString: AttributedString?, expectedLink: String, expectedRuns: Int) {