Skip to content

Commit

Permalink
imgmath: Fix relative file path
Browse files Browse the repository at this point in the history
Closes #10944
  • Loading branch information
jschueller authored and jfbu committed Jan 4, 2023
1 parent a9b0f27 commit f971081
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sphinx/ext/imgmath.py
Expand Up @@ -319,7 +319,8 @@ def html_visit_math(self: HTML5Translator, node: nodes.math) -> None:
image_format = self.builder.config.imgmath_image_format.lower()
img_src = render_maths_to_base64(image_format, rendered_path)
else:
relative_path = path.relpath(rendered_path, self.builder.outdir)
bname = path.basename(rendered_path)
relative_path = path.join(self.builder.imgpath, 'math', bname)
img_src = relative_path.replace(path.sep, '/')
c = f'<img class="math" src="{img_src}"' + get_tooltip(self, node)
if depth is not None:
Expand Down Expand Up @@ -359,7 +360,8 @@ def html_visit_displaymath(self: HTML5Translator, node: nodes.math_block) -> Non
image_format = self.builder.config.imgmath_image_format.lower()
img_src = render_maths_to_base64(image_format, rendered_path)
else:
relative_path = path.relpath(rendered_path, self.builder.outdir)
bname = path.basename(rendered_path)
relative_path = path.join(self.builder.imgpath, 'math', bname)
img_src = relative_path.replace(path.sep, '/')
self.body.append(f'<img src="{img_src}"' + get_tooltip(self, node) +
'/></p>\n</div>')
Expand Down

0 comments on commit f971081

Please sign in to comment.