mgaitan/sphinxcontrib-mermaid

Transparency failing for svg output

fpreiss opened this issue · 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).