diff --git a/Tusker/Views/ContentTextView.swift b/Tusker/Views/ContentTextView.swift index 18a5cf88..5f11aff8 100644 --- a/Tusker/Views/ContentTextView.swift +++ b/Tusker/Views/ContentTextView.swift @@ -105,14 +105,20 @@ class ContentTextView: LinkTextView { self.attributedText = mutAttrString } - func attributedTextForHTMLNode(_ node: Node) -> NSAttributedString { + func attributedTextForHTMLNode(_ node: Node, usePreformattedText: Bool = false) -> NSAttributedString { switch node { case let node as TextNode: - return NSAttributedString(string: node.text(), attributes: [.font: defaultFont]) + let text: String + if usePreformattedText { + text = node.getWholeText() + } else { + text = node.text() + } + return NSAttributedString(string: text, attributes: [.font: defaultFont]) case let node as Element: let attributed = NSMutableAttributedString(string: "", attributes: [.font: defaultFont]) for child in node.getChildNodes() { - attributed.append(attributedTextForHTMLNode(child)) + attributed.append(attributedTextForHTMLNode(child, usePreformattedText: usePreformattedText || node.tagName() == "pre")) } switch node.tagName() {