Is there a way to execute carriage returns in a markdown section of an IPython notebook so that when executed the text remains on separate lines (as displayed when typing), rather than combining all text into a single block of text?
Below is my input (and how it displays while typing), followed by the resulting output when the markdown section is executed.
Input:
XXXX [carriage return]
YYYY [carriage return]
ZZZZ [carriage return]
Output:
XXXX YYYY ZZZZ
I am able to create paragraphs by typing text, [carriage return], [space], text, [carriage return] (see below), but I am unable to display consecutive individual lines of text without some placeholder on the line between each line of text.
Input:
Paragraph 1 [carriage return] [space]
Paragraph 2 [carriage return] [space]
Paragraph 3
Output:
Paragraph 1
Paragraph 2
Paragraph 3
Am I missing something easy?
As per the Markdown specification, <br>
tags can be inserted by ending a line with two or more spaces:
Paragraphs and line breaks
A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line — a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.
The implication of the "one or more consecutive lines of text" rule is that Markdown supports "hard-wrapped" text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type's "Convert Line Breaks" option) which translate every line break character in a paragraph into a <br />
tag.
When you do want to insert a <br />
break tag using Markdown, you end a line with two or more spaces, then type return.
Yes, this takes a tad more effort to create a <br />
, but a simplistic "every line break is a <br />
" rule wouldn't work for Markdown. Markdown's email-style blockquoting and multi-paragraph list items work best — and look better — when you format them with hard breaks.
So something like
XXXX␣␣
YYYY␣␣
ZZZZ
(using ␣
to represent spaces) should work.
You can simply put 2 spaces after xxxx [2 spaces + enter], yyyy [2 spaces + enter] and zzzz [2 spaces + enter]
.