Ink icon indicating copy to clipboard operation
Ink copied to clipboard

Support multiple table headers

Open stury opened this issue 5 years ago • 6 comments

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 header to headers, and converted its type from a Row? 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

stury avatar May 19 '20 14:05 stury

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.

JohnSundell avatar May 19 '20 22:05 JohnSundell

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. :)

stury avatar May 20 '20 14:05 stury

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?

JohnSundell avatar May 21 '20 23:05 JohnSundell

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. 👍

john-mueller avatar May 22 '20 18:05 john-mueller

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 👍

JohnSundell avatar May 23 '20 11:05 JohnSundell

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.

stury avatar Jun 11 '20 18:06 stury