From bc4311cf1d0939e85fa4ab6fa483dd3b735b7517 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 9 Mar 2022 15:34:50 +0100 Subject: [PATCH] Make sure we don't add the ipynb source prefix twice --- src/jupyterlite_sphinx.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/jupyterlite_sphinx.py b/src/jupyterlite_sphinx.py index eefdb64..e4c34be 100644 --- a/src/jupyterlite_sphinx.py +++ b/src/jupyterlite_sphinx.py @@ -201,10 +201,16 @@ def parse(self, inputstring, document): ) -def inited(app: Sphinx, error): +def inited(app: Sphinx, config): # Create the content dir os.makedirs(os.path.join(app.srcdir, CONTENT_DIR), exist_ok=True) + if ( + ".ipynb" not in config.source_suffix + and ".ipynb" not in app.registry.source_suffix + ): + app.add_source_suffix(".ipynb", "jupyterlite_notebook") + def jupyterlite_build(app: Sphinx, error): if app.builder.format == "html": @@ -242,6 +248,9 @@ def jupyterlite_build(app: Sphinx, error): def setup(app): + # Initialize RetroLite parser + app.add_source_parser(RetroLiteParser) + app.connect("config-inited", inited) # We need to build JupyterLite at the end, when all the content was created app.connect("build-finished", jupyterlite_build) @@ -269,10 +278,6 @@ def setup(app): ) app.add_directive("jupyterlite", JupyterLiteDirective) - # Initialize RetroLite parser - app.add_source_parser(RetroLiteParser) - app.add_source_suffix(".ipynb", "jupyterlite_notebook") - # Initialize Replite directive app.add_node( RepliteIframe,