为 Markdown 设计表定义语法
我毫不掩饰我对 BBCode 的蔑视和支持对于更具可读性的文本到 HTML 转换器,例如 Markdown,这是 SO 使用的。 “规范”Markdown 但是没有定义表格的语法。因此,我正在尝试设计一个能够实现这一点的扩展。
最重要的是,它应该易于阅读和编写。当然它也不应该与现有的 Markdown 语法冲突。 PHP Markdown 的表格语法如下所示:
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
出于某种原因,这我觉得“还不够”(主要是因为它看起来有点太冗长)。有谁知道语法更好的 Markdown 方言吗?也欢迎您自己编写。
如果解析不是特别困难,但仍然足够灵活来处理对齐方式(水平和垂直)、表头以及可能的 colspan
和 rowspan
,那就加分了。
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 | Content 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
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我喜欢 Textile 的表格语法。看起来像:
解析器不关心空格。这种语法很灵活,避免了语法(如您的、Reddit 等)的僵化,需要在单个标题行和表格的其余部分之间使用“分隔符”行。
I like Textile's table syntax. It looks like:
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.