table 中的换行符使用 GitHub 风味降价

Line break in table using GitHub flavored markdown

我正在使用 Jekyll 和 GitHub 风味降价。最终结果是在 GitHub 页面上托管内容。我有一个 table,我希望其中一行的第 2 列有一个换行符。这样做的正确方法是什么?我当然可以插入一个 <br/> 并且 GitHub 似乎是对它的尊重——但这是正确的做法吗?在 table 内容中插入物理换行符似乎会破坏 table.

的呈现
First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell Line 1
              | Content Cell Line 2
Content Cell  | Content Cell

Jekyll 支持两者 Markdown and Textile。遗憾的是 Markdown 仅适用于 最基本的表格。 Textile 可以轻松处理这种情况。命名一个文件 something.textile,并使用此语法:

|_. First Header |_. Second Header     |
| Content Cell   | Content Cell Line 1
                   Content Cell Line 2 |
| Content Cell   | Content Cell        |

Result

需要注意的是Syntax Rules状态(部分):

Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown’s formatting syntax only addresses issues that can be conveyed in plain text.

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.

所以,是的,插入 <br /> 是正确的方法。

事实上,由于 tables 不是“散文”,一些人认为 Markdown 不应该支持任何类型的 table 语法——tables 应该只使用原始 HTML 创建。虽然许多人不同意这一点(我在这里不做任何争论,只是说明存在分歧),但很难忽视原始实现(通常称为“参考实现”)不支持 tables 在原始 HTML 之外。事实上,规则中原始 HTML 的第一个示例是 HTML table.

关键是你永远不需要质疑插入原始 HTML 是否是在 Markdown 中完成某些事情的正确方法。 Markdown 是专门为这一意图而设计的。