MarkdownText
MarkdownText copied to clipboard
Is it possible to support table display?
Thx for the open source, it is absolutely a great library. However I noticed that the table style is missing, it's kind of important for academic articles.
Yeah supporting table's should be possible because I think Apple's parser does actually call through to those walkers.
However its non-trivial and I haven't had time to commit to this project recently.
I'm open to reviewing a PR and getting this in, but I'd suggest for a v1 of this, limiting to iOS 16 and using the native tables implementation only.
This is because unclear how best to proceed for iOS 13+ support, I think the best approach would be to use a CompositionalLayout and a UI/NS CollectionView – but as I said I've not properly explored this yet.
Hello @wyk111wyk and @shaps80. I have a similar project MarkdownView which supports table rendering with iOS 14+.
Behind the scene, I use a powerful combination of multiple geometry readers to achieve that on older OS. I have detached that amazing component and open-sourced. It's called AdaptiveGrid, and you can try it out.
Interesting, I actually plan to implement this myself, but I was going to use Table in SwiftUI for iOs 16+ and then UICollectionView for older versions.
I'll def check your out, even if I can't use it as-is, I'm sure it'll provide as a great reference, I'll credit you of course where appropriate 👍
Thanks for mentioning this.
@LiYanan2004 what performance testing have you done btw and does this work on macOS as well?
This could also be a great reference for back porting Grid actually 👍
Yeah. It's working on macOS as well. I use Grid
to render Tables which can give me opportunities to customize the UI.
My goal to AdaptiveGrid
is to build a back-deployable version of Grid
which behaves the same as the built-in one on iOS 16+. Actually, It can.
The calculation inside AdaptiveGrid
is light-weight, so it won't impact the overall performance. If you are experiencing a bad performance, you can give an issue 🤣
Ok interesting. I'll take a look when I have some time. Personally I tend to work on the smallest primitive first, then build on top.
So I had planned actually to rebuild Layout
first, which would then make it relatively simpler to build things like Grid
, Table
, ViewThatFits
and other awesome iOS 16/17+ features.
Looking forward.
Thanks again for posting though, looks like a neat library 👍
Just in case you're unaware you can find ALL of my backports here:
- https://github.com/shaps80/SwiftBackports
- https://github.com/shaps80/SwiftUIBackports
- https://github.com/shaps80/SwiftUIPlus
@LiYanan2004 just FYI I have an early version of a backported Table implementation with SwiftUI matching APIs. Its "close" and is being tested currently in a production app, so if it pans out I should be able to get Table support into the library soonish.