skip to main content

@tonyfast s notebooks

site navigation
notebook summary
title
screen reader improvements to nbconvert html exporter
description
this post is used for testing screen reader improvements to the nbconvert html exporter. for the most part, without focus there are no visual changes just accessibility annotation changes.
cells
8 total
4 code
state
executed in order
kernel
Python [conda env:p311] *
language
python
name
conda-env-p311-py
lines of code
33
outputs
2
table of contents
{"kernelspec": {"display_name": "Python [conda env:p311] *", "language": "python", "name": "conda-env-p311-py"}, "language_info": {"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.3"}, "widgets": {"application/vnd.jupyter.widget-state+json": {"state": {}, "version_major": 2, "version_minor": 0}}, "title": "screen reader improvements to nbconvert html exporter", "description": "this post is used for testing screen reader improvements to the nbconvert html exporter.\nfor the most part, without focus there are no visual changes just accessibility annotation changes."}
notebook toolbar
Activate
cell ordering
1

screen reader improvements to nbconvert html exporter

this post is used for testing screen reader improvements to the nbconvert html exporter. for the most part, without focus there are no visual changes just accessibility annotation changes.

it adds:

  • hidden cell numbers as interactive elements to focus on
  • some chunky ass focus, i even toned it down from the default i use. i like my focus thikk.
  • list navigation of cells

it removes:

  • disability dongles using beautiful soup

    current the exporter ALWAYS runs the exported html through beautiful soup using the slowest horse in town. if your website is thikkk then thats a lot soup to boil.

it doesn't:

  • include lines of code and number of outputs in the details
  • any form elements. the only interactive element used is a link.
2
    import nbconvert
3

take a recent and pass it through the exporter

4
    (
        pandas.Series(
            ["2024-02-28-histograms-sucks.ipynb"]
        ).apply(
            nbconvert.get_exporter("html")().from_filename
        ).itemgetter(0)
        .apply(do(Path("tmp.html").write_text))
        .display.iframe().display()
    )
1 outputs.
5

write the file and copy the path to demo in another tab.

6
     Index(["tmp.html"]).path().path.absolute().path.as_uri().astype(
         str
     ).map(do(pyperclip.copy)).map(
         lambda x: F"[{x}]({x})"
     ).map(Markdown)#.display()
1 outputs.
tmp.html    <IPython.core.display.Markdown object>
Name: as_uri, dtype: object
7
8