Skip to content

Commit

Permalink
fix(nbconvert2): monkey patch partially functional clean_html
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmcasey committed Mar 1, 2023
1 parent 2439fe3 commit a457bf0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mkdocs_jupyter/nbconvert2.py
Expand Up @@ -12,6 +12,7 @@
import jupytext
import mistune
from nbconvert.exporters import HTMLExporter, MarkdownExporter
from nbconvert.exporters.templateexporter import default_filters
from nbconvert.filters.highlight import _pygments_highlight
from nbconvert.filters.markdown_mistune import (
IPythonRenderer,
Expand Down Expand Up @@ -99,6 +100,13 @@ def nb2html(
# "markdown2html": custom_markdown2html,
}

# Ensures SVG rendered with data and rdkit exit with NOOP
# Source: https://github.com/jupyter/nbconvert/issues/1894#issuecomment-1334355109
def custom_clean_html(element):
return element.decode() if isinstance(element, bytes) else str(element)

default_filters["clean_html"] = custom_clean_html

exporter = HTMLExporter(
config=app.config,
template_file=template_file,
Expand Down

0 comments on commit a457bf0

Please sign in to comment.