当前位置: 动力学知识库 > 问答 > 编程问答 >

jekyll - Line break in table using GitHub flavored markdown

问题描述:

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 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.

网友答案:

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: