jupyter-book: Ipython Markdown Display Widget doesn't render in Jupyter-book

The ipython display widget doesn’t render in my jupyter book HTML output. It does in my sphinx material.

To Reproduce

Steps to reproduce the behavior:

Create a markdown table and try to display it with the ipython widget.

from jinja2 import Environment, BaseLoader

rendered_report_header_table="""# Report

## Sample-1

---

|  |  |  |  |
| --- | --- | --- | --- |
| **Patient Name:** | Smith, Todd | **Ordered By:** | Dr. Who |
| **Date of Birth:** | 12/11/1977 | **Sample Collection Date:** | 12/9/2020 | 
| **Gender**: | Male | **Sample Accession Date:** | 12/9/2020 |
| **Sample Type:** | blood | **Report Data:** | 12/9/2020 |
| **Sample ID/MRN:** | 1234567 | | |
| **Test Accession:** | BRCA122345 | | | 
| **Test Ordered:** | BRCA2 sequencing & Deletion/Duplication analysis | | | 
| **Test Code:** | ABCD | | |
| **Test Indictation** | Patient has family history of breast cancer. | | |

---

## Result: Postitive

---

| Gene   | Variant   | Zygosity     | Variant Classification   |
|:-------|:----------|:-------------|:-------------------------|
| BRCA2  | c.10G>T   | Heterozygous | Likely Pathogenic        |
| BRCA2  | c.-172A>G | Heterozygous | Unknown                  |
"""

# This doesn't work in the jupyterhub output
from IPython.display import display, Markdown, Latex, HTML
display(Markdown(rendered_report_header_table))
Screen Shot 2020-11-18 at 10 13 03 AM

Expected behavior

I expect the Markdown widget to display. It does display correctly when using sphinx + nbsphinx +the sphinx-material theme. It also displays correctly in the jupyter notebook itself.

Screen Shot 2020-11-18 at 9 22 15 AM

A link to your documentation repository.

Github Repo Link to Docs in Sphinx

$ jupyter-book build mybook
ERROR ...

Environment

  • Python Version [e.g. 3.7.1]:
  • Package versions or output of jupyter-book --version:
  • Operating System:
OS: Linux
Python 3.7.5
Jupyter Book: 0.8.3
MyST-NB: 0.10.1
Sphinx Book Theme: 0.0.39
MyST-Parser: 0.12.10
Jupyter-Cache: 0.4.1
NbClient: 0.5.1

Additional context

Nothing else really.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Note that background-color: transparent has already been removed in a previous request

@dirkroorda have you tried using sphinx and nbsphinx? That’s what I’m using for my project that requires displaying the markdown widgets. I’m sure jupyter-book will be able to display IPython display widgets.

@chrisjsewell , I’m not sure if this is an option (or just a stupid suggestion 😉 ) but is it possible to use nbsphinx for the ipynb notebooks and the myst-parser for markdown files? Then my markdown widgets would display correctly in the notebooks, and I would get the nice markdown syntax!

that’s a strange one, I’d think it would work. Rather than displaying with display(, could you use an “include” directive like so:

```{include} ../README.md
```

It wouldn’t be included in the ipynb version of the page, but would work in the documentation

Just a quick note, I’m halfway through a PR that changes how notebook output cells are dealt with (essentially just processing them a bit earlier in the process). This will fix this issue, so I’d just ask for a little more time (but not too much) 😉

Because the rendering of a notebook with its outputcell that can contain arbitrary HTML, Markdown and CSS is quite another thing than rendering a “plain” markdown file.

That is just not correct; nbsphinx does not work theoretically any differently to myst-nb/jupyter-book, particularly once the above PR is merged. The only difference is that it goes through an extra (unnecessary) step of converting the file to RestructuredText first, rather than straight to the sphinx syntax tree (this is actually a long term goal of nbsphinx anyway).

I have multiple struggles with the Juptyer Book rendering of output cells.

If you have any issue additional to rendering of Markdown, then I would encourage to open additional issues, to point us to what needs fixing 😄

@chrisjsewell there’s no problem. I just really like jupyterbook and this would be a nice feature to have. It’s actually only necessary for me for one particular project, and I can use jupyterbook fine on other projects. 😉