Skip to content

Commit d2b037f

Browse files
committed
checking if the image path is inside a subdir of dir
1 parent 3407de5 commit d2b037f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

jupyter_sphinx/ast.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ def cell_output_to_nodes(cell, data_priority, write_stderr, dir, thebe_config):
274274
# directory, so make a relative path, which Sphinx treats
275275
# as being relative to the current working directory.
276276
filename = os.path.basename(output.metadata["filenames"][mime_type])
277+
278+
# checks if file dir path is inside a subpath of dir
279+
filedir = os.path.dirname(output.metadata["filenames"][mime_type])
280+
subpaths = filedir.split(dir)
281+
if subpaths and len(subpaths) > 1:
282+
subpath = subpaths[1]
283+
dir += subpath
284+
277285
uri = os.path.join(dir, filename)
278286
to_add.append(docutils.nodes.image(uri=uri))
279287
elif mime_type == "text/html":

0 commit comments

Comments
 (0)