为 Markdown 设计表定义语法

发布于 2024-12-04 07:28:11 字数 770 浏览 2 评论 0原文

我毫不掩饰我对 BBCode 的蔑视和支持对于更具可读性的文本到 HTML 转换器,例如 Markdown,这是 SO 使用的。 “规范”Markdown 但是没有定义表格的语法。因此,我正在尝试设计一个能够实现这一点的扩展。

最重要的是,它应该易于阅读和编写。当然它也不应该与现有的 Markdown 语法冲突。 PHP Markdown 的表格语法如下所示:

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  |

出于某种原因,这我觉得“还不够”(主要是因为它看起来有点太冗长)。有谁知道语法更好的 Markdown 方言吗?也欢迎您自己编写。

如果解析不是特别困难,但仍然足够灵活来处理对齐方式(水平和垂直)、表头以及可能的 colspanrowspan,那就加分了。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜味拾荒者 2024-12-11 07:28:11

我喜欢 Textile 的表格语法。看起来像:

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

解析器不关心空格。这种语法很灵活,避免了语法(如您的、Reddit 等)的僵化,需要在单个标题行和表格的其余部分之间使用“分隔符”行。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文