sphinxcontrib-mermaid icon indicating copy to clipboard operation
sphinxcontrib-mermaid copied to clipboard

Transparency failing for svg output

Open fpreiss opened this issue 2 years ago • 0 comments

When targeting the svg output, the file is embedded using the html <object> tag. While this displays correctly on chromium, firefox does not apply the transparency correctly to the object (see the undesired white background in the image below):

Screenshot_20221221_164225

I suggest using an img tag instead of the object tag as listed below, as this will display the svg correctly in firefox:

         if _fmt == "svg":
-            svgtag = """<object data="%s" type="image/svg+xml">
-            <p class="warning">%s</p></object>\n""" % (
+            svgtag = """<img src="%s" alt="%s"/>\n""" % (
                 fname,
                 alt,
             )

One caveat for this approach is that this might impact the behaviour for animated/interactive svg files (if that is even a concern for the svg target of mmdc).

fpreiss avatar Dec 21 '22 16:12 fpreiss