pythonipythonjupyterjupyter-notebook

How to programmatically generate markdown output in Jupyter notebooks?


I want to write a report for classes in Jupyter notebook. I'd like to count some stuff, generate some results and include them in markdown. Can I set the output of the cell to be interpreted as markdown?
I'd like such command: print '$\phi$' to generate phi symbol, just like in markdown.
In other words, I'd like to have a template made in markdown and insert the values generated by the program written in the notebook. Recalculating the notebook should generate new results and new markdown with those new values inserted. Is that possible with this software, or do I need to replace the values by myself?


Solution

  • The functions you want are in the IPython.display module.

    from IPython.display import display, Markdown, Latex
    display(Markdown('*some markdown* $\phi$'))
    # If you particularly want to display maths, this is more direct:
    display(Latex('\phi'))