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:
- visit https://validator.w3.org/
- enter an nbviewer url like https://github.com/jupyterlab/jupyterlab-demo/blob/master/notebooks/Lorenz.ipynb
- Scroll down to Error Stray Doctype
Expected behavior
two options:
- the javascript assets for the notebook are loaded in the existing head and the notebook contents is rendered inside the body.
- iframe!
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