Skip to content

Commit bc4311c

Browse files
committed
Make sure we don't add the ipynb source prefix twice
1 parent 7d36cb2 commit bc4311c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/jupyterlite_sphinx.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,16 @@ def parse(self, inputstring, document):
201201
)
202202

203203

204-
def inited(app: Sphinx, error):
204+
def inited(app: Sphinx, config):
205205
# Create the content dir
206206
os.makedirs(os.path.join(app.srcdir, CONTENT_DIR), exist_ok=True)
207207

208+
if (
209+
".ipynb" not in config.source_suffix
210+
and ".ipynb" not in app.registry.source_suffix
211+
):
212+
app.add_source_suffix(".ipynb", "jupyterlite_notebook")
213+
208214

209215
def jupyterlite_build(app: Sphinx, error):
210216
if app.builder.format == "html":
@@ -242,6 +248,9 @@ def jupyterlite_build(app: Sphinx, error):
242248

243249

244250
def setup(app):
251+
# Initialize RetroLite parser
252+
app.add_source_parser(RetroLiteParser)
253+
245254
app.connect("config-inited", inited)
246255
# We need to build JupyterLite at the end, when all the content was created
247256
app.connect("build-finished", jupyterlite_build)
@@ -269,10 +278,6 @@ def setup(app):
269278
)
270279
app.add_directive("jupyterlite", JupyterLiteDirective)
271280

272-
# Initialize RetroLite parser
273-
app.add_source_parser(RetroLiteParser)
274-
app.add_source_suffix(".ipynb", "jupyterlite_notebook")
275-
276281
# Initialize Replite directive
277282
app.add_node(
278283
RepliteIframe,

0 commit comments

Comments
 (0)