mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
776 stars 146 forks source link

Feature request: support table cell merging #29

Open ec1oud opened 6 years ago

ec1oud commented 6 years ago

That is, it should be possible for a cell to span multiple columns and maybe even multiple rows.

For example MultiMarkdown does it like this:

https://fletcher.github.io/MultiMarkdown-5/tables.html

I'd suggest to add columnSpan and rowSpan to MD_BLOCK_TD_DETAIL.

I'm trying to use md4c to add Markdown support to Qt (the table patch is https://codereview.qt-project.org/#/c/214901/ ) and this is the main low-hanging fruit I've seen so far, since QTextTable supports it already.

mity commented 6 years ago

I understand your motivation.

But, to be honest, I think that adopting too easily too many extensions (just because we can) would eventually result in a Markdown parser which gets much bigger, much less maintainable, and which would strongly contribute to Markdown syntax babel, making the overall situation worse, not better.

There seems to be absolutely no consensus that multiple pipes should be understood as cell spans. (MultiMarkdown even reports some error when trying to parse the 1st part of the table from its own documentation!)

For the multi-row cells, the situation is likely even worse because I have no idea how a reasonable syntax for it might look like, and there are probably even fewer Markdown implementations which attempt to support it.

Last but not least, if I understand you correctly, you want the feature because you can easily wire it to some feature of Qt and not because there are users who need it.

Taking it all together, under the current circumstances my motivation to implement this (or even merge such feature) is very close to zero.

ec1oud commented 6 years ago

As it is, I can detect that the cell is completely empty, but I wouldn't think it would be too hard for the parser to detect that the pipes are exactly adjacent without even whitespace between them. Maybe just set a flag then, and leave interpretation of the colspan up to the user?

Row merging might be too hard, I agree.