Closed charrondev closed 7 months ago
The issue of handling tables is indeed quite complex because NSAttributedString only provides basic typesetting functionality.
Achieving a complete table implementation, including scaling, can be very challenging.
Currently, the project only has a simple implementation for tables.
One possible approach could be obtaining the screen size and converting the table content into an image to be inserted into NSAttributedString.
ref: may use ascii-table instead: https://ozh.github.io/ascii-tables/
I've abandonded my use of Swift altogether for the area that I need to view HTML content and am instead just using a webview.
In addition to having much greater support for all manor of HTML, I'm also finding it's rendering on large amounts of text far faster than the equivalent NSAttributedString
s. I wasn't expecting that at all.
I've noticed that table rendering is relatively lackluster.
I'm willing to take a crack at it in the next few months but wanted to open this issue to start getting some ideas down.
Current Limitations
Currently the table implementation creates tries to even things out by making use of whitespace characters to even the columns. This has numerous shortcomings, most notably that
Implementation Ideas
My goal would be something like the following:
To actually accomplish this it will certainly need to be some type of NSTextAttachment, and
ZNSTextAttachment
seems like a good enough inspiration of something with dynamic, initially unknown height to calculate and render.