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

Please consider support for multi-row Headers for Tables #1174

Closed
4 tasks done
wnm3 opened this issue Jun 9, 2023 · 2 comments
Closed
4 tasks done

Please consider support for multi-row Headers for Tables #1174

wnm3 opened this issue Jun 9, 2023 · 2 comments
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on

Comments

@wnm3
Copy link

wnm3 commented Jun 9, 2023

Initial checklist

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 <br> or something, but this loses the boundary for explicit headers.

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jun 9, 2023
@ChristianMurphy
Copy link
Member

ChristianMurphy commented Jun 10, 2023

Welcome @wnm3! 👋
Thanks for sharing your idea!

TL;DR

Our table implementation strictly follows GitHub Flavored Markdown (gfm), diverging from the standard, even as an option is a non-goal for the project.
This could be filed with the gfm team at https://github.com/github/cmark-gfm or https://github.com/orgs/community/discussions, and once approved and merged into the GFM standard, we will match the standard.

Alternatively you could create your own parser extension to create the new table type, the process is rather involved, and it is not necessarily advisable to create yet another markdown favor. But it is an option. https://github.com/micromark/micromark#extending-markdown

Either of the above you could do yourself, or you could explore sponsoring a remark maintainer to do so on your behalf. I believe both @wooorm and @remcohaszing have done some consulting in the past.

Context:

Remark is a wrapper around lower level utilities like https://github.com/micromark/micromark (CommonMark implementation), https://github.com/micromark/micromark-extension-gfm (GFM implementation), and https://github.com/micromark/micromark-extension-mdx (MDX implementation).
Designed to make it easier to work with the abstract syntax tree (more on that here: https://unifiedjs.com/learn/).

CommonMark (https://spec.commonmark.org/), GitHub flavored Markdown (https://github.github.com/gfm/), and MDX (https://github.com/mdx-js/specification) each follow a spec/standard.
These existing plugins will not add features from outside their respective standards.

That said, you and others are welcome to looking into creating your own extension if wanted (guide: https://github.com/micromark/micromark#extending-markdown).
Though know that creating yet another markdown flavor is both a complex endeavor technically, and would require training authors on the new standard.

Another possibility is reaching out to the standards groups themselves with the idea, and adding a feature to the standard. CommonMark has a standards discussion forum (https://talk.commonmark.org/), GitHub responses both to issues and discussions (https://github.com/github/cmark-gfm and https://github.com/orgs/community/discussions), and MDX has a discussion forum (https://github.com/orgs/mdx-js/discussions)

Your particular request is around tables, which is a part of the GFM standard.

@ChristianMurphy ChristianMurphy closed this as not planned Won't fix, can't repro, duplicate, stale Jun 10, 2023
@ChristianMurphy ChristianMurphy added the 👀 no/external This makes more sense somewhere else label Jun 10, 2023
@github-actions

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Jun 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants