Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carriage Returns in Markdown Section of IPython Notebook

Tags:

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?

like image 526
datajunkie Avatar asked Oct 03 '14 23:10

datajunkie


People also ask

How do you insert a line break in Jupyter Notebook markdown?

Just add <br> where you would like to make the new line.

What does %% do in Jupyter Notebook?

Both ! and % allow you to run shell commands from a Jupyter notebook. % is provided by the IPython kernel and allows you to run "magic commands", many of which include well-known shell commands. ! , provided by Jupyter, allows shell commands to be run within cells.

How do you itemize in a Jupyter Notebook?

Indented quoting: Use a greater than sign ( > ) and then a space, then type the text. The text is indented and has a gray horizontal line to the left of it until the next carriage return.

How do I edit markdown in Jupyter Notebook?

You can change the cell type of any cell in Jupyter Notebook using the Toolbar. The default cell type is Code. To use the Keyboard Shortcuts, hit the esc key. After that, you can change a cell to Markdown by hitting the m key, or you can change a cell to Code by hitting the y key.


1 Answers

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.

like image 62
Chris Avatar answered Sep 20 '22 10:09

Chris