Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions sphinxcontrib/jupyter/writers/translate_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,17 @@ def visit_image(self, node):
self.images.append(uri) #TODO: list of image files
if self.jupyter_download_nb_image_urlpath:
for file_path in self.jupyter_static_file_path:
if file_path in uri:
uri = uri.replace(file_path +"/", self.jupyter_download_nb_image_urlpath)
break #don't need to check other matches
#Adjust Relative References
if "../" in uri:
uri = uri.replace("../","")
#If the root path "/" is specified in RST URI then only the name of the source directory will be needed for substitution
if "/" in file_path and uri.split("/")[0] == file_path.split("/")[-1]:
uri = uri.replace(file_path.split("/")[-1]+"/", self.jupyter_download_nb_image_urlpath)
break
#Otherwise full file_path needs to be replaced
else:
uri = uri.replace(file_path+"/", self.jupyter_download_nb_image_urlpath)
break
attrs = node.attributes
if self.jupyter_images_markdown:
#-Construct MD image
Expand Down
4 changes: 3 additions & 1 deletion sphinxcontrib/jupyter/writers/translate_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ def __init__(self, builder, document):
self.jupyter_ignore_skip_test = builder.config["jupyter_ignore_skip_test"]
self.jupyter_lang_synonyms = builder.config["jupyter_lang_synonyms"]
self.jupyter_target_html = builder.config["jupyter_target_html"]
self.jupyter_download_nb_image_urlpath = builder.jupyter_download_nb_image_urlpath
self.jupyter_images_markdown = builder.config["jupyter_images_markdown"]
self.jupyter_target_pdf = builder.config["jupyter_target_pdf"]

# Non global variables set in builder
self.jupyter_download_nb_image_urlpath = builder.jupyter_download_nb_image_urlpath

# set the value of the cell metadata["slideshow"] to slide as the default option
self.slide = "slide"
self.metadata_slide = False #value by default for all the notebooks, we change it for those we want
Expand Down