Remove extra line break from spoiler text

This commit is contained in:
Thomas Ricouard 2023-02-04 13:36:56 +01:00
parent 4c40adc195
commit 508b180a1d

View file

@ -29,6 +29,7 @@ public struct HTMLString: Codable, Equatable, Hashable {
let document: Document = try SwiftSoup.parse(htmlValue)
handleNode(node: document)
document.outputSettings(OutputSettings().prettyPrint(pretty: false))
try document.select("br").after("\n")
try document.select("p").after("\n\n")
@ -40,6 +41,11 @@ public struct HTMLString: Codable, Equatable, Hashable {
_ = text.removeLast()
}
asRawText = text
if asMarkdown.hasPrefix("\n") {
_ = asMarkdown.removeFirst()
}
} catch {
asRawText = htmlValue
}