Support multiple table headers
Hi John,
I appreciate you open sourcing this Swift Package! I had a need for it to convert a markdown document I'm creating at work into HTML. This was just about the right ticket for me. One issue I ran into, which the commercial application products Byword and iA Writer seem to support is that you can have multiple header rows in a Table. Ink doesn't support that. It's hard coded to only accept one row as the header.
I've updated the code, to add this functionality.
I think they're fairly lightweight changes:
- Changed the Table property
headertoheaders, and converted its type from aRow?to[Row]?. - Updated the rest of the code to then handle the case of having multiple header rows in the table.
- I added a new function
findHeaderAlignmentRow()to find where the row is for the header separator, and alignment hints in markdown. - Added a new Test Case in your unit tests to show this working in a general sense.
This update seems to be working well for me now. So I thought I'd send a PR back to you with these changes.
Thanks for this project! Nice and simple to integrate with, and was simple enough to troubleshoot and fix the problem I ran into.
Scott Tury
Thanks for this @stury. I'll try to review this as soon as possible, but in the meantime, if either @christiankm or @john-mueller wants to take a look at this, I think that'd be great - since they worked on the original implementation of tables for Ink.
Thanks! I could not find an official call out that Markdown supported this feature either, but using the Mac App Store applications ByWord and iA Writer do support this feature. So it seems like adding this would be a nice update, and allows me to automate my task another step. :)
Curious to hear if our CommonMark expert @john-mueller has any insight on this. Would merging this cause any problems in terms of CommonMark-conformance?
Tables are not part of the CommonMark spec yet, but they are a part of the GitHub-flavored spec, which is merely an extension to CommonMark. The tables @christiankm and I worked on are basically GitHub-flavored, so technically this would be an extension to their extension. I'll do a quick check this weekend that this doesn't break anything related to CommonMark, but I seriously doubt it will, and I think it's purely additive to the GitHub-flavored tables. 👍
Great, thanks a lot for your insight, guys 🙂 Let's move ahead with this one then, I'll try to have it reviewed sometime during the next week. Cheers 👍
Just checking in with you to see if you need any other help from me with this PR. It looks like the last comment was from 19 days ago.