使用GitHub风格的markdown在表格中换行 [英] Line break in table using GitHub flavored markdown

查看:553
本文介绍了使用GitHub风格的markdown在表格中换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与Jekyll和 GitHub 调味的markdown一起工作.最终结果是将内容托管在GitHub Pages上.我有一张桌子,我想在其中一个行的第2列中有一个换行符.这样做的正确方法是什么?我当然可以插入<br/>并且GitHub似乎很荣幸-但这是正确的方法吗?在表内容中插入物理换行符似乎会破坏表的呈现.

I am working with Jekyll and GitHub flavored markdown. The end result is to host the content on GitHub Pages. I have a table, in which I would like there to be a line break in column #2 of one of the rows. What is the proper way to do this? I can certainly insert a <br/> and GitHub seems to honor it -- but is that the correct way to do it? Inserting a physical line break into the table content seems to break the rendering of the table.

First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell Line 1
              | Content Cell Line 2
Content Cell  | Content Cell

推荐答案

请务必注意,语法规则" 状态(部分):

It is important to note that the Syntax Rules state (in part):

Markdown不能替代HTML,甚至不能替代HTML.它的语法非常小,仅对应于很小的HTML标签子集.我们的想法是 not 来创建一种语法,使插入HTML标记更加容易.我认为HTML标记已经很容易插入. Markdown的想法是使其易于阅读,编写和编辑散文. HTML是一种发布格式; Markdown是一种 writing 格式.因此,Markdown的格式语法仅解决了可以以纯文本形式传达的问题.

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.

对于Markdown语法未涵盖的任何标记,您只需使用HTML本身即可.无需在其前添加或定界以表明您正在从Markdown切换为HTML;您只需使用标签即可.

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 />是正确的方法.

So, yes, inserting a <br /> is the proper way to do it.

实际上,由于表不是散文",因此有人认为Markdown不应该支持任何类型的表语法-只能使用原始HTML创建表.尽管许多人在这一点上存在分歧(我在这里不做任何论点,只是说存在分歧),但不容错过的是原始实现(通常称为参考实现")不为外部表提供支持原始HTML.实际上,规则中原始HTML的第一个示例是HTML表.

In fact, as tables are not "prose," some have argued that Markdown should not support any kind of table syntax -- that tables should only be created using raw HTML. While many disagree on that point (I'm not making either argument here, simply stating that the disagreement exists), it is hard to miss that the original implementation (often referred to as the "reference implementation") offers no support for tables outside of raw HTML. In fact, the first example of raw HTML in the rules is of an HTML table.

重点是,您永远不必怀疑插入原始HTML是否是在Markdown中完成某件事的正确方法. Markdown在设计时就考虑到了这种意图.

The point is that you should never need to question whether inserting raw HTML is the proper way to accomplish something in Markdown. Markdown was designed specifically with that intention in mind.

这篇关于使用GitHub风格的markdown在表格中换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆