jupyter / nbviewer

nbconvert as a web service: Render Jupyter Notebooks as static web pages

Home Page:https://nbviewer.jupyter.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

all rendered notebook return malformed html

tonyfast opened this issue · comments

Describe the bug
when nbviewer renders the notebook body it recieves a complete html document including a new head and body. this is invalid html if we check it on the w3c validator.

To Reproduce
Steps to reproduce the behavior:

  1. visit https://validator.w3.org/
  2. enter an nbviewer url like https://github.com/jupyterlab/jupyterlab-demo/blob/master/notebooks/Lorenz.ipynb
  3. Scroll down to Error Stray Doctype

Expected behavior
two options:

  1. the javascript assets for the notebook are loaded in the existing head and the notebook contents is rendered inside the body.
  2. iframe!

Screenshots
image

Additional context
these errors were discovered when trying to remediate the accessibility of nbviewer. most accessibility fixes can't be made until we have well formed html. the current malformed dom structure will have unknown effects across browsers, AT, and OS.

it would be really nice to have the w3c validator running as a pytest for several different projects including nbconvert and nbviewer. this is a feature in nbconvert-a11y that might be worth extracting https://github.com/deathbeds/nbconvert-a11y/blob/main/nbconvert_a11y/pytest_w3c.py