Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple table headers #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stury
Copy link

@stury stury commented May 19, 2020

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

@JohnSundell
Copy link
Owner

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.

Copy link
Contributor

@christiankm christiankm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see any problem adding support for this. Thanks for your contribution!
I am unaware if the standard markdown syntax allows this. As far as I can see the code looks fine.

@stury
Copy link
Author

stury commented May 20, 2020

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

@JohnSundell
Copy link
Owner

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?

@john-mueller
Copy link
Contributor

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

@JohnSundell
Copy link
Owner

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 👍

@stury
Copy link
Author

stury commented Jun 11, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants