HTML Bullet point sin NSAttributedString alignment

33 Views Asked by At

I've tried so many of the other answers on here and none seem to work. This one seems closest but the solutions haven't helped. I'm displaying the following HTML (we get this back in a response):

<p>Welcome blah blah</p>\n
<ul>\n
<li>Here's bullet point number one blah blah blahb blah blah</li>\n
<li>Here's bullet point number two</li>\n
<li>Bullet point number three is longer and will wrap around but look strange blah blah blah</li>\n
</ul>

I'm using NSAttributedString and have this in place:

public extension Data {
    var htmlToAttributedString: NSAttributedString? {
        do {
            return try NSAttributedString(data: self,
                                          options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue],
                                          documentAttributes: nil)
        } catch {
            print("error:", error)
            return  nil
        }
    }
    
    var htmlToString: String { htmlToAttributedString?.string ?? "" }
}

public extension String {
    var htmlToAttributedString: NSAttributedString? {
        Data(utf8).htmlToAttributedString
    }
    
    var htmlToString: String {
        htmlToAttributedString?.string ?? ""
    }
}

This works fine but for text longer than the view it wraps around without an indent. Any ideas on what I can do my side?

enter image description here

0

There are 0 best solutions below