Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format output of code cell with Markdown

Output of Python code cell seems to be not processed by Markdown.

For example in Python code cell there could be something like that:

print "**bold**"

And the output is: **bold** instead of bold. Is there a way to make it really bold?

like image 277
scdmb Avatar asked Aug 15 '15 16:08

scdmb


People also ask

How do you convert a code cell to a markdown cell or vice versa?

While the default cell type for new cells is Code, you can change the cell type of any existing cell by clicking in the cell and selecting a new cell type (e.g. Markdown ) in the cell type menu in the toolbar.

Is it possible to execute the code blocks within markdown cells?

Using Jupyter Lab, and coding in r, the way to enter code blocks in a markdown cell is easy and has good and predictable results. Just follow the same steps each time. Press Esc key, type m for markdown cell, press Enter key. The cursor is now in the markdown cell waiting for instructions.

How do you make a markdown cell bold in Jupyter notebook?

For example, to make a word bold, surround it with the HTML code for bold ( <b>text</b> instead of the Markdown code. You can attach image files directly to a notebook in Markdown cells by dragging and dropping it into the cell.

How do you edit a markdown cell in Jupyter notebook?

Just double click on the markdown cell. Edit what you want to and Run. It will reflect the changes.


1 Answers

To get markdown formatted output, you can use the Markdown object of the display machinery. A print-like function could thus look like

from IPython.display import Markdown, display
def printmd(string):
    display(Markdown(string))
printmd('**bold**')
like image 59
Jakob Avatar answered Oct 18 '22 02:10

Jakob