From 2797b45abc70874cf3d0aab42df6b6c47241341f Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Thu, 9 Nov 2023 09:29:29 -0800 Subject: [PATCH] Use an for SVG output instead of an , unlike , has proper alt text support (i.e. that's not just fallback content) and is easily saved, opened in a new tab, etc. from the page where it appears. This does mean the SVG's DOM will no longer be available for inspection by JavaScript in the containing document (e.g. object.contentDocument), but I don't think that was intended to be a feature of SVG output for this Sphinx extension. Resolves as well. --- sphinxcontrib/mermaid.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/sphinxcontrib/mermaid.py b/sphinxcontrib/mermaid.py index ccec878..7ebbb76 100644 --- a/sphinxcontrib/mermaid.py +++ b/sphinxcontrib/mermaid.py @@ -285,20 +285,14 @@ def render_mm_html(self, node, code, options, prefix="mermaid", imgcls=None, alt if alt is None: alt = node.get("alt", self.encode(code).strip()) imgcss = imgcls and f'class="{imgcls}"' or "" - if _fmt == "svg": - svgtag = f""" -

{alt}

-""" - self.body.append(svgtag) - else: - if "align" in node: - self.body.append( - '
' % (node["align"], node["align"]) - ) + if "align" in node: + self.body.append( + '
' % (node["align"], node["align"]) + ) - self.body.append(f'{alt}\n') - if "align" in node: - self.body.append("
\n") + self.body.append(f'{alt}\n') + if "align" in node: + self.body.append("
\n") raise nodes.SkipNode