github / cmark-gfm

GitHub's fork of cmark, a CommonMark parsing and rendering library and program in C
Other
909 stars 175 forks source link

Please consider adding multi-row header support for tables in github #335

Open wnm3 opened 1 year ago

wnm3 commented 1 year ago

Initial checklist I read the support docs I read the contributing guide I agree to follow the code of conduct I searched issues and couldn’t find anything (or linked relevant results below) Problem I also host the OSS site (MDfromHTML) to convert HTML to Markdown. I’ve recently been working to improve table rendering from a bunch of HTML tables I’d put into a test page here. Some of these provide multiple header rows. I’ve supported this and Fletcher Penney’s MultiMarkdown Viewer supports this format as well. Note: for colspans and rowspans in HTML I elected to replicate the value so the table in HTML with multiple headers originally looked like this: image

I did this replication as one goal I have is to associate row and column headers with each cell…

Below is a screen shot of the markdown and rendering I’d hoped would occur:

image

Unfortunately, the plugin renders the multi-line headers by ignoring all but the last line (directly above the header separator line with pipes and hyphens):

image

Do you suppose you could add support for multi-row headers? Thank you in advance for your consideration. I will want to request the same for github’s markdown processing so if you know who I should contact please let me know. Thanks.

Solution When encountering a table, read ahead to reach the header separator row (pipes, hyphens, spaces, colons...) then apply the alignment gleaned there to all rows above the separator to create the table header rows, then process the rows following the separator as table body rows.

Alternatives It could be possible to consolidate all cells for multi-row headers by column using
or something, but this loses the boundary for explicit headers.