Line break in table using GitHub flavored markdown

不羁的心 提交于 2019-12-10 09:37:48

问题


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

回答1:


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

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.

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

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.

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.




回答2:


Jekyll supports both Markdown and Textile. Sadly Markdown is good only for the most basic of tables. Textile can handle this case easily. Name a file something.textile, and use this syntax:

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

Result



来源:https://stackoverflow.com/questions/33066427/line-break-in-table-using-github-flavored-markdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!