Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparency failing for svg output #102

Open
fpreiss opened this issue Dec 21, 2022 · 0 comments · May be fixed by #131
Open

Transparency failing for svg output #102

fpreiss opened this issue Dec 21, 2022 · 0 comments · May be fixed by #131

Comments

@fpreiss
Copy link

fpreiss commented Dec 21, 2022

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).

tsibley added a commit to tsibley/sphinxcontrib-mermaid that referenced this issue Nov 9, 2023
<img>, unlike <object>, 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 <mgaitan#102>
as well.
tsibley added a commit to tsibley/sphinxcontrib-mermaid that referenced this issue Nov 9, 2023
<img>, unlike <object>, 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 <mgaitan#102>
as well.
@tsibley tsibley linked a pull request Nov 9, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant