Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 788
codechurn Avatar asked Oct 11 '15 14:10

codechurn


People also ask

How do you break a line in a Markdown table?

A newline in Markdown is created by “2 spaces at the end of the line and a single newline”.

How do I add a new line in GitHub Markdown?

Markdown is so basic: you just type in your desired text, then tell it what to do by attaching certain symbols to it. If you want a blank line, you insert one blank line — or more, if you want bigger blank space — in between two lines of text. ###### This is as small as it gets before regular text.

How do you insert multiple line breaks in Markdown?

Blank Lines To add a single extra line after a paragraph, add two extra spaces at the end of the text. To add an extra line of space between paragraphs, add the HTML &nbsp; code, followed by two extra spaces (e.g. &nbsp.. , replacing the periods with spaces).

How do I insert a breakdown Markdown?

When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.


2 Answers

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.

like image 183
Waylan Avatar answered Sep 28 '22 05:09

Waylan


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

like image 39
Zombo Avatar answered Sep 28 '22 05:09

Zombo