开发者

Designing table definition syntax for Markdown

开发者 https://www.devze.com 2023-04-04 10:46 出处:网络
I have made no secret of my disdain for BBCode and support for more readable text-to-HTML converters like Markdown, which is what SO uses. \"Canonical\" Markdown however doesn\'t have a syntax to defi

I have made no secret of my disdain for BBCode and support for more readable text-to-HTML converters like Markdown, which is what SO uses. "Canonical" Markdown however doesn't have a syntax to define tables. So, I am trying to come up with an extension that does just that.

Above all, it should be easy to read and write. Of course it also shouldn't be conflict with existing Markdown syntax. PHP Markdown has syntax for tables that looks like:

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Conten开发者_Go百科t Cell  |
| Content Cell  | Content Cell  |

For some reason, this strikes me as "not enough enough" (mainly because it looks a little too verbose). Does anyone know of a Markdown dialect with a nicer syntax? You are welcome to write your own as well.

Bonus points if it's not extraordinarily difficult to parse but still flexible enough to handle alignments (horizontal and vertical), table headers and possibly colspan and rowspan.


I like Textile's table syntax. It looks like:

|_. a header cell |_. another header |
|_. one more header |=. centered cell |
| regular cell |>. right-aligned cell |

The parser doesn't care about whitespace. This syntax is flexible and avoids the rigidity of syntaxes (like yours, Reddit's, etc.) requiring a "separator" line between a single header row and the rest of the table.

0

精彩评论

暂无评论...
验证码 换一张
取 消