Giter VIP home page Giter VIP logo

mkdocs-jupyter's Introduction

mkdocs-jupyter: Use Jupyter Notebooks in mkdocs

  • Docs demo Site
  • Add Jupyter Notebooks directly to the mkdocs navigation
  • Support for multiple formats:
  • Same style as regular Jupyter Notebooks
    • Support Jupyter Themes
  • Option to execute the notebook before converting
  • Support for ipywidgets
  • Support for mkdocs TOC
  • Option to include notebook source

mkdocs-jupyter default theme mkdocs-jupyter material theme

Installation

pip install mkdocs-jupyter

Configuration

In the mkdocs.yml use Jupyter notebooks (.ipynb) or Python scripts (.py) as pages:

nav:
    - Home: index.md
    - Notebook page: notebook.ipynb
    - Python file: python_script.py
plugins:
    - mkdocs-jupyter

Titles and Table of Contents

The first h1 header (#) in your notebook will be used as the title.

# This H1 header will be the the title.

This can be turned off in the configuration (in which case the filename will be used as title):

plugins:
    - mkdocs-jupyter:
          ignore_h1_titles: True

In order to see the table of contents you need to maintain a hierarchical headers structure in your notebooks. You must use h2 headers (##) and not h1 (#)

## This H2 title will show in the table of contents

If you want to nest headers in the TOC you need to add additional levels later in the same markdown cell or new bottom markdown cells:

## This header will show as top level in the table of contents

<content>

### This one will be displayed inside the above level

Including or Ignoring Files

You can control which files are included or ignored via lists of glob patterns:

plugins:
    - mkdocs-jupyter:
          include: ["*.ipynb"] # Default: ["*.py", "*.ipynb"]
          ignore: ["some-irrelevant-files/*.ipynb"]

Execute Notebook

You can tell the plugin to execute the notebook before converting, default is False:

plugins:
    - mkdocs-jupyter:
          execute: true

You can tell the plugin to ignore the execution of some files (with glob matching):

plugins:
    - mkdocs-jupyter:
          execute_ignore:
              - "my-secret-files/*.ipynb"

To fail when notebook execution fails set allow_errors to false:

plugins:
    - mkdocs-jupyter:
          execute: true
          allow_errors: false

Kernel

By default the plugin will use the kernel specified in the notebook to execute it. You can specify a custom kernel name to use for all the notebooks:

plugins:
    - mkdocs-jupyter:
          kernel_name: python3

Ignore Code Input

By default the plugin will show full code and regular cell output details. You can hide cell code input for all the notebooks:

plugins:
    - mkdocs-jupyter:
          show_input: False

You can also decide to hide the Out[#] output notation and other cell metadata for all the notebooks:

plugins:
    - mkdocs-jupyter:
          no_input: True

Remove Cell Using Tags

By default the plugin will show full code and regular cell output details. You can hide cell code input for specific cells using tags:

plugins:
    - mkdocs-jupyter:
          remove_tag_config:
              remove_input_tags:
                  - hide_code

More detailed on removing cell based on tag, see NbConvert Customization)

Jupyter themes

You can configure the different Jupyter themes. For example if using material with slate color scheme you can use the Jupyter Lab dark theme:

plugins:
    - mkdocs-jupyter:
          theme: dark

theme:
    name: material
    palette:
        scheme: slate

Extra CSS classes

This option will add a custom CSS class to the div container that highlights the code cells. This can be useful to add custom styles to the code cells.

plugins:
  - mkdocs-jupyter:
      highlight_extra_classes: "custom-css-classes

RequireJS

By default RequireJS is not loaded. This is required for Plotly. You can enable it with:

plugins:
    - mkdocs-jupyter:
          include_requirejs: true

Download notebook link

You can tell the plugin to include the notebook source to make it easy to show a download button in the theme, default is False:

plugins:
    - mkdocs-jupyter:
          include_source: True

This setting will also create a page.nb_url value that you can use in your theme to make a link in each page.

For example in mkdocs-material (see customization), you can create a main.html file like this:

{% extends "base.html" %}

{% block content %}
{% if page.nb_url %}
    <a href="{{ page.nb_url }}" title="Download Notebook" class="md-content__button md-icon">
        {% include ".icons/material/download.svg" %}
    </a>
{% endif %}

{{ super() }}
{% endblock content %}

Download Notebook button

Styles

This extensions includes the Jupyter Lab nbconvert CSS styles and does some modifications to make it as generic as possible in order for it to work with a variety of mkdocs themes. This is not always possible and the theme we test the most is mkdocs-material.

It's possible you might need to do some CSS changes to make it look as good as you want, for example for the material theme take a look at their customization docs.

Create a main.html file like:

{% extends "base.html" %}

{% block content %}
{{ super() }}

<style>
// Do whatever changes you need here

.jp-RenderedHTMLCommon p {
    color: red
}

</style>
{% endblock content %}

Mkdocs Material notes

Any markdown specific features such as admonitions won't work with mkdocs-jupyter because those features are not supported by Jupyter itself and we use nbconvert to make the conversion.

To use this type of features you have to define the HTML directly in the markdown cells:

<div class="admonition note">
    <p class="admonition-title">Note</p>
    <p>
        If two distributions are similar, then their entropies are similar,
        implies the KL divergence with respect to two distributions will be
        smaller...
    </p>
</div>

mkdocs-jupyter's People

Contributors

acivitillo avatar angus-g avatar cpcloud avatar danielfrg avatar dependabot[bot] avatar fortierq avatar ggbaro avatar giswqs avatar hadim avatar hameye avatar hannorein avatar hkennyv avatar josephmcasey avatar koaning avatar matthewcaseres avatar metab0t avatar nickcrews avatar oprypin avatar ozekik avatar petebachant avatar rikedyp avatar szabgab avatar vincentsarago avatar xmnlab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mkdocs-jupyter's Issues

LaTeX rendering

I'm having trouble rendering equations with this plugin.

Neither of these work for me:

\begin{equation} f(x) = y \end{equation}
$$ g(f) = g(f(x)) $$

With mknotebooks I usually have to add the mathjax cdn

extra_javascript: 
     - https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML

I've also tried swapping this cdn with the one mentioned in #11 but no dice.

Making use of title from nbconvert

mkdocs-jupyter is currently not setting the title attribute in the mkdoc page object. Therefore, if no title is provided manually in the navigation, mkdocs uses the filename.

When nbconvert converts a document it can generate a title (see e.g. the html files it creates). I'm not entirely sure how it determines the title, but it might be the first h1 header it sees I the file. It would be nice if mkdocs-jupyter could use the title from nbconvert to set the title in the mkdoc page object.

I'm not sure how to implement this in a clean way.

Base Example Breaks

When running a base example with this notebook;

image

Then running mkdocs serve gives a hard to parse error. This is the trace:

(venv) โžœ  scikit-fairness git:(documentation) โœ— mkdocs serve
INFO    -  Building documentation... 
INFO    -  Cleaning site directory 
INFO    -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
  - fairness.ipynb 
Converting: /Users/vincent/Development/scikit-fairness/docs/fairness.ipynb
ERROR   -  Error reading page 'fairness.ipynb': string indices must be integers 
Traceback (most recent call last):
  File "/Users/vincent/Development/scikit-fairness/venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs/__main__.py", line 143, in serve_command
    **kwargs
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 141, in serve
    config = builder()
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 136, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs/commands/build.py", line 274, in build
    _populate_page(file.page, config, files, dirty)
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    page.render(config, files)
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs_jupyter/plugin.py", line 57, in new_render
    self.toc = get_nb_toc(page.file.abs_src_path)
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs_jupyter/plugin.py", line 74, in get_nb_toc
    toc = get_toc(getattr(md, "toc", ""))
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs/structure/toc.py", line 11, in get_toc
    toc = [_parse_toc_token(i) for i in toc_tokens]
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs/structure/toc.py", line 11, in <listcomp>
    toc = [_parse_toc_token(i) for i in toc_tokens]
  File "/Users/vincent/Development/scikit-fairness/venv/lib/python3.7/site-packages/mkdocs/structure/toc.py", line 59, in _parse_toc_token
    anchor = AnchorLink(token['name'], token['id'], token['level'])
TypeError: string indices must be integers

Strip out the `In` and `Out` label for code cells

The css class is jp-InputPrompt jp-InputArea-prompt. Tweaking the CSS to add visiblity: hidden to it make it disappear but leave an empty block.

Is there is another way to strip out this HTML block?

Headings after "```" not displaying

Big fan of this repo, thank you so much for creating it.

I've just found an issue when converting notebooks with containing code block ticks in markdown, such as:

image

The image above is to show the triple backticks (otherwise GitHub's markdown editor will format them).

If I have a cell displaying some information using triple backticks, all of the headings below the cell with triple backticks won't get displayed in the Table of Contents.

See the example image:

Screen Shot 2021-06-21 at 6 47 05 pm

The live example is available here: https://dev.mrdbourke.com/tensorflow-deep-learning/03_convolutional_neural_networks_in_tensorflow/#inspect-the-data-become-one-with-it

I've found this issue to occur in all notebooks with the same "triple backticks in markdown" formatting.

Anyone facing this issue?

I've thought of removing the triple backticks but I do like how it displays the content.

Otherwise, anywhere I should look in the notebook formatting scripts?

Difficulties packaging mkdocs-jupyter due to alpha version of poetry

Awesome project!

I see that mkdocs-jupyter is using an alpha version of poetry, which makes it impossible to package using poetry2nix.

I would love to use mkdocs-jupyter in my projects, but the use of an unreleased version of poetry is preventing me from doing so. nix enforces a unique version of Python packages over the entire dependency closure and many other projects are using poetry, so I am unable include this package in the closure.

Would you accept a PR to use a released version of poetry? I realize that means that some of the nice features of poetry 1.2 aren't available anymore (dependency groups being the primary one used here), but I think it's worth it for compatibility with external packaging systems.

I'll put up a PR anyway, but wanted to open up an issue to discuss.

Thanks again for the great project.

Can't pip install repo

I am modifying a fork of this project but can't install it via pip & git :

pip install git+https://github.com/fortierq/mkdocs-jupyter.git
...
mkdocs gh-deploy --force
INFO     -  Converting notebook (execute=False): /home/runner/work/mp2i-2021/mp2i-2021/docs/0_intro/1_jupyter.ipynb
jinja2.exceptions.TemplateNotFound: mkdocs_html/assets/mkdocs-jupyter.css

pip install git+https://github.com/danielfrg/mkdocs-jupyter.git gives the same error message.
Do you know where it comes from and how to solve it ? Is it mandatory to upload my fork on PyPI ?

feature request: support for jupyter/ipython cell separator syntax

Hey, just wanted to say I've used this plugin for a while now and it's been going great, thank you!

I have a feature request, that IMO would be very helpful:

Support for the jupyter/ipython cell separator syntax # %% or #%%.

Many Python IDEs support this type of syntax for interactive IDE support:

It has been a huge improvement for my workflow, especially wrt version control (much easier to use git with a .py file vs .ipynb).

In addition, there exist a few tools that already help convert between .ipynb and .py files and working with this cell syntax:

So, with that said, I think this could be a great addition to this plugin and would be happy to contribute if anyone could point me in the right direction. Cheers :)

Issues with jupyter cells and larger LaTeX equations

Hi @danielfrg

Thanks for this fantastic library. I am loving it. Here are a few issues I have encountered while using mkdocs-jupyter. I am very less familiar with CSS/JS so I used hacks to solve these issues.

  1. Responsiveness breaks on smaller screens for larger lines in jupyter cells.
    Screenshot 2020-05-31 at 8 51 50 PM

To solve this, I have created a css file with code below and linked that in mkdocs.yml.

pre {
    overflow: auto;
}

I want to ask if this responsiveness behaviour is expected or is it more likely an issue?

  1. Similarly, rendering of larger LaTex equations breaks on smaller screens

WhatsApp Image 2020-05-31 at 9 10 04 PM

Sorry for ugly screenshots.
I have solved this issue, by updating mathjaxscript.src in templates.py module to this -

mathjaxscript.src = "//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML";

Again, I want to ask if this LaTeX behaviour is expected or is it more likely an issue?

Checkout this web page which I have deployed to inspect the issues live.

admonition support

Would it be possible to add support for admonitions being rendered in markdown cells. I'd be happy to contribute to this too if needed

Update pypi

Hi! Version 0.21.0 solves some compatibility issues, and we'd love to be able to simply install it from PyPI. Would it be possible to push 0.21 to the PyPI?

Add a copy button to each cell

It would be great if there was a button to copy the content of each input or output cell (which probably requires a JS solution as described in this SO answer).

Ideally, the solution would not be dependent on mkdocs-material. Currently some of the features of mkdocs-jupyter seem tightly coupled with mkdocs-material, such as the download button.

This plugin is really nice and painless to set up - thanks for developing it!

ERROR - Error reading page '[INSERT_NOTEBOOK_TITLE].ipynb': 'state'

I'm not sure what's going on when converting a notebook I've been working on.

You can see the original notebook here: https://github.com/mrdbourke/pytorch-deep-learning/blob/main/03_pytorch_computer_vision.ipynb

The error I'm getting is:

ERROR    -  Error reading page '03_pytorch_computer_vision.ipynb': 'state'

The full traceback is:

ERROR    -  Error reading page '03_pytorch_computer_vision.ipynb': 'state'
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.2/x64/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/mkdocs/__main__.py", line [20](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:20)8, in gh_deploy_command
    build.build(cfg, dirty=not clean)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/mkdocs/commands/build.py", line 292, in build
    _populate_page(file.page, config, files, dirty)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    page.render(config, files)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/mkdocs_jupyter/plugin.py", line 94, in new_render
    body = convert.nb2html(
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/mkdocs_jupyter/nbconvert2.py", line 105, in nb2html
    content, resources = exporter.from_filename(nb_path)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/nbconvert/exporters/exporter.py", line 190, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/nbconvert/exporters/exporter.py", line 208, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/nbconvert/exporters/html.py", line [21](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:21)0, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/nbconvert/exporters/templateexporter.py", line 392, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/jinja2/environment.py", line 9[25](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:25), in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/mkdocs_jupyter/templates/mkdocs_html/notebook.html.j2", line 78, in top-level template code
    {%- set vars = {"cell_id": 0 } -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/lab/index.html.j2", line 3, in top-level template code
    {% from 'jupyter_widgets.html.j2' import jupyter_widgets %}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/lab/base.html.j2", line [26](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:26)0, in top-level template code
    {% set div_id = uuid4() %}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/display_priority.j2", line 1, in top-level template code
    {%- extends 'base/null.j2' -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/null.j2", line 26, in top-level template code
    {%- block body -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/null.j2", line [29](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:29), in block 'body'
    {%- block body_loop -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/null.j2", line [31](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:31), in block 'body_loop'
    {%- block any_cell scoped -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/null.j2", line [34](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:34), in block 'any_cell'
    {%- block codecell scoped -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/mkdocs_jupyter/templates/mkdocs_html/notebook.html.j2", line 119, in block 'codecell'
    {{ super() }}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/lab/base.html.j2", line 12, in block 'codecell'
    {{ super() }}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/null.j2", line 44, in block 'codecell'
    {%- block output_group -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/lab/base.html.j2", line [38](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:38), in block 'output_group'
    {{ super() }}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/null.j2", line 48, in block 'output_group'
    {%- block outputs scoped -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/lab/base.html.j2", line [44](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:44), in block 'outputs'
    {{ super() }}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/null.j2", line [50](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:50), in block 'outputs'
    {%- block output scoped -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/lab/base.html.j2", line 87, in block 'output'
    {{ super() }}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/null.j2", line 67, in block 'output'
    {%- block display_data scoped -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/null.j2", line 68, in block 'display_data'
    {%- block data_priority scoped -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/lab/base.html.j2", line 115, in block 'data_priority'
    {{ super() }}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/share/jupyter/nbconvert/templates/base/display_priority.j2", line 7, in block 'data_priority'
    {%- for type in output.data | filter_data_type -%}
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/nbconvert/filters/widgetsdatatypefilter.py", line [56](https://github.com/mrdbourke/pytorch-deep-learning/runs/5670248420?check_suite_focus=true#step:8:56), in __call__
    metadata['widgets'][WIDGET_STATE_MIMETYPE]['state'] if
KeyError: 'state'
Error: Process completed with exit code 1.

I'm not quite sure where to even start with this one.

I'm going to be stepping back through the error.

But I've tried several things with the existing notebook:

  • Rerunning the code cells + re-commiting
  • Starting a fresh notebook and copying the code/markdown into the new notebook manually, cell by cell, error remains

I don't think I've done anything different to other notebooks I've worked on.

Yet this error remains.

You can see the GitHub Action I'm using to do the conversion here: https://github.com/mrdbourke/pytorch-deep-learning/blob/main/.github/workflows/make_docs.yml

Please forgive me if this is the wrong repo to be posting this issue.

Support mkdocs-material theme toggle

The README describes how to implement the Jupyter Lab dark theme for use with the material slate theme:

plugins:
  - mkdocs-jupyter:
      theme: dark

theme:
  name: material
  palette:
    scheme: slate

Is it possible to support toggling between Jupyter Lab themes when material toggles between themes? This is the implementation of the theme toggle in material:

theme:
  palette: 
    - scheme: default
      toggle:
        icon: material/toggle-switch-off-outline
        name: Switch to dark mode
    - scheme: slate 
      toggle:
        icon: material/toggle-switch
        name: Switch to light mode

I'm not sure if there are any inherent limitations, but I thought this would be an interesting feature request!

Specify kernel

I can't enable the execute option because the kernel in my notebook are not standard. Could you force the execution using the current kernel?

Full traceback:

 File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/mkdocs_jupyter/plugin.py", line 54, in new_render
    body = convert.nb2html(page.file.abs_src_path, execute=exec_nb)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/mkdocs_jupyter/convert.py", line 132, in nb2html
    html, info = exporter.from_filename(nb_path)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 181, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 199, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbconvert/exporters/html.py", line 119, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 369, in from_notebook_node
    nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 143, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 318, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 79, in preprocess
    self.execute()
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbclient/util.py", line 74, in wrapped
    return just_run(coro(*args, **kwargs))
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbclient/util.py", line 53, in just_run
    return loop.run_until_complete(coro)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nest_asyncio.py", line 95, in run_until_complete
    return f.result()
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/asyncio/futures.py", line 181, in result
    raise self._exception
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/asyncio/tasks.py", line 249, in __step
    result = coro.send(None)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbclient/client.py", line 524, in async_execute
    async with self.async_setup_kernel(**kwargs):
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/async_generator/_util.py", line 34, in __aenter__
    return await self._agen.asend(None)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbclient/client.py", line 482, in async_setup_kernel
    await self.async_start_new_kernel(**kwargs)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbclient/client.py", line 394, in async_start_new_kernel
    await ensure_async(self.km.start_kernel(extra_arguments=self.extra_arguments, **kwargs))
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/nbclient/util.py", line 85, in ensure_async
    result = await obj
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/jupyter_client/manager.py", line 571, in start_kernel
    kernel_cmd, kw = self.pre_start_kernel(**kw)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/jupyter_client/manager.py", line 262, in pre_start_kernel
    kernel_cmd = self.format_kernel_cmd(extra_arguments=extra_arguments)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/jupyter_client/manager.py", line 181, in format_kernel_cmd
    cmd = self.kernel_spec.argv + extra_arguments
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/jupyter_client/manager.py", line 87, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "/home/hadim/local/conda/envs/datamol/lib/python3.7/site-packages/jupyter_client/kernelspec.py", line 235, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named conda-env-datamol-py

Error with new version of Pygments (2.12.0)

๐Ÿ‘‹ Hi! First off, thank you for this project, it's really handy!

I tried installing it today in an environment with the latest version of Pygments - 2.12.0 (released 4 days ago) and ran into an error converting your demo notebook:

ERROR    -  Error reading page 'notebooks/_demo.ipynb': format() argument must be a formatter instance, not a class
Traceback (most recent call last):
  File "/apps/python3.7.12/lib/python3.7/site-packages/pygments/__init__.py", line 61, in format
    formatter.format(tokens, realoutfile)
  File "/apps/python3.7.12/lib/python3.7/site-packages/pygments/formatter.py", line 94, in format
    return self.format_unencoded(tokensource, outfile)
  File "/apps/python3.7.12/lib/python3.7/site-packages/pygments/formatters/html.py", line 981, in format_unencoded
    source = self.wrap(source)
TypeError: wrap() missing 1 required positional argument: 'outfile'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/apps/python3.7/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/apps/python3.7.12/lib/python3.7/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/apps/python3.7.12/lib/python3.7/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/apps/python3.7.12/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/apps/python3.7.12/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/apps/python3.7.12/lib/python3.7/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/apps/python3.7.12/lib/python3.7/site-packages/mkdocs/__main__.py", line 177, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, **kwargs)
  File "/apps/python3.7.12/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 54, in serve
    config = builder()
  File "/apps/python3.7.12/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 49, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/apps/python3.7.12/lib/python3.7/site-packages/mkdocs/commands/build.py", line 292, in build
    _populate_page(file.page, config, files, dirty)
  File "/apps/python3.7.12/lib/python3.7/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    page.render(config, files)
  File "/home/jindig/.local/lib/python3.7/site-packages/mkdocs_jupyter/plugin.py", line 98, in new_render
    theme=theme,
  File "/home/jindig/.local/lib/python3.7/site-packages/mkdocs_jupyter/nbconvert2.py", line 105, in nb2html
    content, resources = exporter.from_filename(nb_path)
  File "/home/jindig/.local/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 189, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/home/jindig/.local/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 207, in from_file
    nbformat.read(file_stream, as_version=4), resources=resources, **kw
  File "/home/jindig/.local/lib/python3.7/site-packages/nbconvert/exporters/html.py", line 215, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "/home/jindig/.local/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 400, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
  File "/apps/python3.7.12/lib/python3.7/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/apps/python3.7.12/lib/python3.7/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/jindig/.local/lib/python3.7/site-packages/mkdocs_jupyter/templates/mkdocs_html/notebook.html.j2", line 78, in top-level template code
    {%- set vars = {"cell_id": 0 } -%}
  File "/home/jindig/.local/share/jupyter/nbconvert/templates/lab/index.html.j2", line 3, in top-level template code
    {% from 'jupyter_widgets.html.j2' import jupyter_widgets %}
  File "/home/jindig/.local/share/jupyter/nbconvert/templates/lab/base.html.j2", line 260, in top-level template code
    {% set div_id = uuid4() %}
  File "/home/jindig/.local/share/jupyter/nbconvert/templates/base/display_priority.j2", line 1, in top-level template code
    {%- extends 'base/null.j2' -%}
  File "/home/jindig/.local/share/jupyter/nbconvert/templates/base/null.j2", line 26, in top-level template code
    {%- block body -%}
  File "/home/jindig/.local/share/jupyter/nbconvert/templates/base/null.j2", line 29, in block 'body'
    {%- block body_loop -%}
  File "/home/jindig/.local/share/jupyter/nbconvert/templates/base/null.j2", line 31, in block 'body_loop'
    {%- block any_cell scoped -%}
  File "/home/jindig/.local/share/jupyter/nbconvert/templates/base/null.j2", line 87, in block 'any_cell'
    {%- block markdowncell scoped-%} {%- endblock markdowncell -%}
  File "/home/jindig/.local/share/jupyter/nbconvert/templates/lab/base.html.j2", line 101, in block 'markdowncell'
    {{ cell.source  | markdown2html | strip_files_prefix }}
  File "/home/jindig/.local/lib/python3.7/site-packages/mkdocs_jupyter/nbconvert2.py", line 202, in custom_markdown2html
    ).render(source)
  File "/home/jindig/.local/lib/python3.7/site-packages/mistune.py", line 1001, in render
    return self.parse(text)
  File "/home/jindig/.local/lib/python3.7/site-packages/mistune.py", line 1004, in parse
    out = self.output(preprocessing(text))
  File "/home/jindig/.local/lib/python3.7/site-packages/mistune.py", line 1053, in output
    out += self.tok()
  File "/home/jindig/.local/lib/python3.7/site-packages/mistune.py", line 1063, in tok
    return getattr(self, 'output_%s' % t)()
  File "/home/jindig/.local/lib/python3.7/site-packages/mistune.py", line 1086, in output_code
    self.token['text'], self.token['lang']
  File "/home/jindig/.local/lib/python3.7/site-packages/mkdocs_jupyter/nbconvert2.py", line 219, in block_code
    return highlight(code, lexer, formatter)
  File "/apps/python3.7.12/lib/python3.7/site-packages/pygments/__init__.py", line 82, in highlight
    return format(lex(code, lexer), formatter, outfile)
  File "/apps/python3.7.12/lib/python3.7/site-packages/pygments/__init__.py", line 69, in format
    raise TypeError('format() argument must be a formatter instance, '
TypeError: format() argument must be a formatter instance, not a class

I don't know much about mkdocs (or Python, for that matter) but I tried downgrading to Pygments 2.10.0 (the same version I found in your poetry.lock file) and things are working again! So I'm guessing their latest release is not backwards-compatible ๐Ÿ˜ž

Just thought I'd give you a heads up in case you weren't aware. Cheers!

Images are not included correctly

It looks like images included in notebooks are not displayed properly after using mkdocs.
For example :
https://github.com/mp2i-fsm/mp2i-2021/blob/main/0_intro/2_rendu_tp.ipynb contains

<img src=img/editor.png width=450>

which remains the same in the output https://github.com/mp2i-fsm/mp2i-2021/blob/gh-pages/0_intro/2_rendu_tp/index.html

However, a new folder is created, containing the .html but not the images (which are one directory up) : https://github.com/mp2i-fsm/mp2i-2021/tree/gh-pages/0_intro/2_rendu_tp

Therefore the images are not found : https://mp2i-fsm.github.io/mp2i-2021/0_intro/2_rendu_tp

Is it solvable easily? I can take a look if needed.

h2 (##) vs h1 (#) headers

Thanks for writing this plugin! Exactly what I needed.

After reading the readme file, I can see that headers in a Jupyter notebook need to be h2 and not h1 to show up in the TOC. But I wonder why? Where is this limitation coming from and is there a way to change that? I'd like to avoid having to go through all my ipynb files to increasing the heading levels.

Subtitles overlapping with notebook text

Hello,

I'm using mkdocs-jupyter to automatically turn a repo of Jupyter Notebooks into documentation.

It's working fantastic for 95% of my Jupyter Notebooks, however, there's two notebooks which are overlapping with the subtitles for some reason, see the example here:
Screen Shot 2022-02-04 at 8 19 24 am

The link to the documentation pictured above is here: https://dev.mrdbourke.com/tensorflow-deep-learning/09_SkimLit_nlp_milestone_project_2/

It seems to only be happening to notebooks in the "Natural Language Processing" heading on the left, I'm not sure why this would be as they are created in the same way as the rest of the notebooks (no issue).

The notebook source is available here: https://github.com/mrdbourke/tensorflow-deep-learning/blob/main/09_SkimLit_nlp_milestone_project_2.ipynb

Any help or insight would be greatly appreciated.

pointing to a jupyter notebook via relative path

I'm making a docs page where I want one of my pages to point to a jupyter notebook in my repo.

right now, my yaml file reads as such:

nav:
    - Home: index.md
    - Getting Started: '../../tutorials/1 - Loading Data (Introduction).ipynb'
   

However, when trying to run the site, I get the following error:

 A relative path to '../../tutorials/1 - Loading Data (Introduction).ipynb' is included in the 'nav' configuration, which is not found in the documentation files

Any help would be appreciated to how to get this to work properly!

pip going backward to use 0.17.3 in CI

When I install this package in my CI environment it seems to fallback on 0.17.3 and in my local, it is using the latest version.
I recently started getting the ipython_genutils issue and noticed it was fixed in the latest version.
But then realized my CI is refusing to use the latest version.

On checking the changelog, I realized this was not added for the 0.17.x versions:
https://github.com/danielfrg/mkdocs-jupyter/blob/main/CHANGELOG.md#0170

So, then I checked the commits and found the main significant change being the switch to poetry:
acbeece

Just raising this issue in case anyone has any idea or faced similar issues.
I will continue to debug why my CI environment is not using the latest version

Logs from CI:

00:18:41.238 Collecting mkdocs-jupyter
00:18:41.254   Downloading mkdocs-jupyter-0.20.0.tar.gz (1.5 MB)
00:18:41.273      โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1.5/1.5 MB 94.7 MB/s eta 0:00:00
00:18:41.506   Installing build dependencies: started
00:18:44.520   Installing build dependencies: finished with status 'done'
00:18:44.524   Getting requirements to build wheel: started
00:18:44.888   Getting requirements to build wheel: finished with status 'done'
00:18:44.890   Preparing metadata (pyproject.toml): started
00:18:45.268   Preparing metadata (pyproject.toml): finished with status 'done'
00:18:45.520   Downloading mkdocs-jupyter-0.19.0.tar.gz (1.5 MB)
00:18:45.540      โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1.5/1.5 MB 93.3 MB/s eta 0:00:00
00:18:45.777   Installing build dependencies: started
00:18:54.453   Installing build dependencies: finished with status 'done'
00:18:54.460   Getting requirements to build wheel: started
00:18:54.660   Getting requirements to build wheel: finished with status 'done'
00:18:54.662   Preparing metadata (pyproject.toml): started
00:18:55.019   Preparing metadata (pyproject.toml): finished with status 'done'
00:18:55.339   Downloading mkdocs-jupyter-0.18.2.tar.gz (1.5 MB)
00:18:55.360      โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1.5/1.5 MB 87.9 MB/s eta 0:00:00
00:18:55.593   Installing build dependencies: started
00:19:03.359   Installing build dependencies: finished with status 'done'
00:19:03.363   Getting requirements to build wheel: started
00:19:03.555   Getting requirements to build wheel: finished with status 'done'
00:19:03.557   Preparing metadata (pyproject.toml): started
00:19:03.922   Preparing metadata (pyproject.toml): finished with status 'done'
00:19:03.987   Downloading mkdocs-jupyter-0.18.1.tar.gz (1.5 MB)
00:19:04.009      โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1.5/1.5 MB 78.4 MB/s eta 0:00:00
00:19:04.273   Installing build dependencies: started
00:19:11.849   Installing build dependencies: finished with status 'done'
00:19:11.853   Getting requirements to build wheel: started
00:19:12.049   Getting requirements to build wheel: finished with status 'done'
00:19:12.051   Preparing metadata (pyproject.toml): started
00:19:12.401   Preparing metadata (pyproject.toml): finished with status 'done'
00:19:12.429   Downloading mkdocs-jupyter-0.18.0.tar.gz (1.4 MB)
00:19:12.454      โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1.4/1.4 MB 65.3 MB/s eta 0:00:00
00:19:12.682   Installing build dependencies: started
00:19:20.969   Installing build dependencies: finished with status 'done'
00:19:20.974   Getting requirements to build wheel: started
00:19:21.346   Getting requirements to build wheel: finished with status 'done'
00:19:21.348   Preparing metadata (pyproject.toml): started
00:19:21.742   Preparing metadata (pyproject.toml): finished with status 'done'
00:19:21.803   Downloading mkdocs-jupyter-0.17.5.tar.gz (1.4 MB)
00:19:21.823      โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1.4/1.4 MB 87.3 MB/s eta 0:00:00
00:19:22.047   Installing build dependencies: started
00:19:29.931   Installing build dependencies: finished with status 'done'
00:19:29.935   Getting requirements to build wheel: started
00:19:30.312   Getting requirements to build wheel: finished with status 'done'
00:19:30.313   Preparing metadata (pyproject.toml): started
00:19:30.708   Preparing metadata (pyproject.toml): finished with status 'done'
00:19:30.734   Downloading mkdocs-jupyter-0.17.4.tar.gz (1.4 MB)
00:19:30.754      โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1.4/1.4 MB 82.2 MB/s eta 0:00:00
00:19:30.979   Installing build dependencies: started
00:19:38.956   Installing build dependencies: finished with status 'done'
00:19:38.960   Getting requirements to build wheel: started
00:19:39.340   Getting requirements to build wheel: finished with status 'done'
00:19:39.340   Preparing metadata (pyproject.toml): started
00:19:39.733   Preparing metadata (pyproject.toml): finished with status 'done'
00:19:39.738 Discarding https://files.pythonhosted.org/packages/60/18/a18f3ee3b378595a0b830a8a144108634cbfd360b1e62af981e19d35bc83/mkdocs-jupyter-0.17.4.tar.gz#sha256=e9a858f79f2cdd71a2558c3b51787663361ec258e1f709c19aa19e8be9582fa7 (from https://pypi.org/simple/mkdocs-jupyter/) (requires-python:>=3.7.1,<4): Requested mkdocs-jupyter from https://files.pythonhosted.org/packages/60/18/a18f3ee3b378595a0b830a8a144108634cbfd360b1e62af981e19d35bc83/mkdocs-jupyter-0.17.4.tar.gz#sha256=e9a858f79f2cdd71a2558c3b51787663361ec258e1f709c19aa19e8be9582fa7 (from -r requirements/build.txt (line 10)) has inconsistent version: filename has '0.17.4', but metadata has '0'
00:19:39.761   Downloading mkdocs-jupyter-0.17.3.tar.gz (1.9 MB)
00:19:39.784      โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1.9/1.9 MB 93.7 MB/s eta 0:00:00
00:19:40.031   Installing build dependencies: started
00:19:43.392   Installing build dependencies: finished with status 'done'
00:19:43.405   Getting requirements to build wheel: started
00:19:43.743   Getting requirements to build wheel: finished with status 'done'
00:19:43.747   Preparing metadata (pyproject.toml): started
00:19:45.397   Preparing metadata (pyproject.toml): finished with status 'done'
00:19:45.464 Collecting cssselect2>=0.1

support HTML outputs that use RequireJS

I'm using Plotly Express to generate charts within my notebooks, and am getting Uncaught ReferenceError: require is not defined. The issue seems to be that Plotly is outputting HTML with an embedded <script>, which expects RequireJS to be present. I tried making a custom theme that inherits from mkdocs to inject RequireJS, but no matter which block I tried, it caused even more JS errors.

Steps to reproduce

  1. Set up a site with mkdocs-jupyter
  2. Copy in this example notebook, which contains this Plotly example
  3. Add to the nav

Support for other languages than Python ?

Hi,
I tried to use mkdocs-jupyter with OCaml notebooks. However, the syntax highlighting is incorrect.
nbconvert works correctly though.
I guess I have to change the CSS. Do you have any advice ?

skip some notebooks being executed

When setting execute: True in mkdocs.yml, mkdocs-jupyter executes all notebooks under the docs directory. Is it possible to skip some notebooks during execution? For example, some notebooks might contain some interactive functions (e.g., input()) that require user input. Such notebooks will fail to execute. As a result, mkdocs fails to build.

Error Mathjax.tpl

notes$ mkdocs serve

INFO    -  Building documentation... 
INFO    -  Cleaning site directory 
INFO    -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
  - MCN/Practicals/MCN-EXP-1.ipynb
  - MCN/Practicals/MCN-EXP-2.ipynb
  - MCN/Unit-1/index.md 
ERROR   -  Error reading page 'MCN/Practicals/MCN-EXP-1.ipynb': mathjax.tpl 

mathjax.tpl

I am using latest version of mkdocs-jupyter==0.13.0
Unable to find solution.

0.12.0 breaks the ToC in notebooks

When deploying a Jupyter notebook with mkdocs 1.1.2 and and mkdocs-jupyter 0.12.0 the ToC does not render properly.

image

Rolling back to mkdocs-jupyter 0.11.0 resolves the issue.

Search bar disappears

When I add this plugin the search functionality is removed from the mkdocs site. Is this a known issue or something with my configuration.

Render ipywidgets

The readme says that mkdocs-jupyter supports ipywidgets. However, I can't seem to get to to work. Do you happen to have any examples for rendering ipywidgets? Thanks.

Related issue: opengeos/leafmap#85

Infinite converting after modifying text

What happens?

If in mkdocs.yml:

  - mkdocs-jupyter:
      execute: True

and command mkdocs serve is running
and any *.ipynb is modified
then mkdocs serve goes into infinite loop of converting notebooks instead waiting for change

  • Example log (notebook was modified once):
INFO     -  [18:28:53] Reloading browsers
INFO     -  [18:28:53] Detected file changes
INFO     -  Building documentation...
INFO     -  Converting notebook (execute=True): /Users/andy/Devel/test-vault/docs/repos/python-course/src/t01_strings.ipynb
INFO     -  Converting notebook (execute=True): /Users/andy/Devel/test-vault/docs/repos/python-course/src/t02_python_internals.ipynb
INFO     -  [18:28:57] Reloading browsers
INFO     -  [18:28:57] Detected file changes
INFO     -  Building documentation...
INFO     -  Converting notebook (execute=True): /Users/andy/Devel/test-vault/docs/repos/python-course/src/t01_strings.ipynb
INFO     -  Converting notebook (execute=True): /Users/andy/Devel/test-vault/docs/repos/python-course/src/t02_python_internals.ipynb
INFO     -  [18:29:00] Reloading browsers
INFO     -  [18:29:00] Detected file changes
INFO     -  Building documentation...
INFO     -  Converting notebook (execute=True): /Users/andy/Devel/test-vault/docs/repos/python-course/src/t01_strings.ipynb
INFO     -  Converting notebook (execute=True): /Users/andy/Devel/test-vault/docs/repos/python-course/src/t02_python_internals.ipynb
INFO     -  [18:29:04] Reloading browsers
INFO     -  [18:29:04] Detected file changes
INFO     -  Building documentation...
INFO     -  Converting notebook (execute=True): /Users/andy/Devel/test-vault/docs/repos/python-course/src/t01_strings.ipynb
INFO     -  Converting notebook (execute=True): /Users/andy/Devel/test-vault/docs/repos/python-course/src/t02_python_internals.ipynb
INFO     -  [18:29:07] Reloading browsers
INFO     -  [18:29:07] Detected file changes
INFO     -  Building documentation...
INFO     -  Converting notebook (execute=True): /Users/andy/Devel/test-vault/docs/repos/python-course/src/t01_strings.ipynb
...

Desired Outcome

mkdocs serve should wait for a file modifications and convert file again if next change occurs.

Rendering of images failed

Hi @danielfrg
Thanks a lot for this library. I wanted to discuss the issue long time back. But I completely forgot about this. Here I go -

If I have an image in the same directory as that of my notebook, the image is rendered using markdown syntax in the notebook but fails to show up in the mkdocs site.

And I get 404 error of Image not found because mkdocs is looking for the image in the path including my notebook's name. As an example -

$ tree .
.
โ”œโ”€โ”€ docs
โ”‚ย ย  โ”œโ”€โ”€ img.png
โ”‚ย ย  โ””โ”€โ”€ inference.ipynb
โ””โ”€โ”€ mkdocs.yml

$ mkdocs serve
404 GET /inference/img.png 

Now, I am wondering how my notebook's name gets added to the path for finding the image. Is this expected behaviour or am I missing something? Please help in this regard.

More interestingly, this is not the case if I render the image from markdown file. As a workaround, I uploaded the picture on GitHub and used that link to render both in notebook and mkdocs.

Embed pictures and downloadable notebook

Hi there, first of all thanks for putting this repo together! We are trying to use it to embed Jupyter notebooks tutorials directly into a docs site.

More than an issue this is a shameless request for features / advice :)

It would be great to:

Would you have any advice on how to go about it?

Support mkdocs-material 8

Hi! First of all, thanks for the amazing package! :)

mkdocs-material has released version 8.0.x, however installing mkdocs-jupyter downgrades the mkdocs-material install to the latest 7.x version. Are there any plans to support the 8.0.x version of mkdocs-material?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.