diff --git a/Mastodon/Helper/MastodonStatusContent.swift b/Mastodon/Helper/MastodonStatusContent.swift index 391519e8..d338615d 100755 --- a/Mastodon/Helper/MastodonStatusContent.swift +++ b/Mastodon/Helper/MastodonStatusContent.swift @@ -17,7 +17,6 @@ enum MastodonStatusContent { static func parse(content: String, emojiDict: EmojiDict) throws -> MastodonStatusContent.ParseResult { let document: String = { var content = content - content = content.replacingOccurrences(of: "
", with: "\n") for (shortcode, url) in emojiDict { let emojiNode = "\(shortcode)" let pattern = ":\(shortcode):" @@ -189,6 +188,14 @@ extension MastodonStatusContent { static func parse(document: String) throws -> MastodonStatusContent.Node { let html = try HTML(html: document, encoding: .utf8) + + // add `\r\n` explicit due to Kanna text missing it after convert to text + // ref: https://github.com/tid-kijyun/Kanna/issues/150 + let brNodes = html.css("br").makeIterator() + while let brNode = brNodes.next() { + brNode.addNextSibling(try! HTML(html: "\r\n", encoding: .utf8).body!) + } + let body = html.body ?? nil let text = body?.text ?? "" let level = 0