Colabtools: IPython.display.Markdown doesn鈥檛 work

Created on 25 Oct 2018  路  9Comments  路  Source: googlecolab/colabtools

mybinder.org or locally installed Jupyter Notebook:
image

Colaboratory:
image

Most helpful comment

Currently Colab does not natively support markdown in outputs, will take this as a feature request.

All 9 comments

Currently Colab does not natively support markdown in outputs, will take this as a feature request.

Any update @blois ?

No progress but we'll take this into further consideration. There are actually two issues here- markdown and LaTeX processing. See https://github.com/googlecolab/colabtools/issues/594 for more details on the LaTeX issue.

+1

As a workaround, I replaced IPython.disaply.Markdown with a function that makes use of markdown:

!pip install markdown
import IPython
from markdown import markdown
Markdown = lambda string: IPython.display.HTML(markdown(string))

Markdown("# *test*")

It works fine for Markdown. For LaTeX, an extension must be used and the code gets a bit more messy:
First, a cell registering a pre_run_cell event so MathJax can be loaded:

from IPython.display import Math, HTML

def load_mathjax_in_cell_output():
    display(HTML("<script src='https://www.gstatic.com/external_hosted/"
                 "mathjax/latest/MathJax.js?config=default'></script>"))
get_ipython().events.register('pre_run_cell', load_mathjax_in_cell_output)

Then the definition of our function:

!pip install markdown python-markdown-math
import IPython
import markdown as md
import mdx_math

Markdown = lambda string: IPython.display.HTML(
    md.markdown(string, extensions=[mdx_math.MathExtension(enable_dollar_delimiter=True)])
)

Markdown("*test* $e^3$")

It'd be nice to have native markdown and LaTeX support though.

This should now be working.

Still not working for me
image
Is this something that will be rolled out on an incremental basis?

Perhaps try a page reload (shift-reload to skip cache)?

Awesome!
image
Many thanks

Was this page helpful?
0 / 5 - 0 ratings