sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

sphinx.ext.graphviz + graphviz_output_format = "svg"

Open kassbohm opened this issue 1 year ago • 0 comments

Describe the bug

I use sphinx.ext.graphviz with the option:

graphviz_output_format = "svg"

to include svg files into my documentation. In my source files I use:

.. graphviz::
   :caption:
   :align: center
   
   ... dot code

Thus graphviz-svg files are produced and are shown as expected, when I open the respective html-page on a browser.

But if I embed my Sphinx-html-Documentation on a third-party website and open a respective html-page on this third-party website: The browser is downloading the graphviz-svg instead of just showing it.

The html-page source including a graphviz-svg looks like this:

<figure class="align-center" id="id1">
<div class="graphviz"><object data="_images/graphviz-svg" type="image/svg+xml" class="graphviz">
<p class="warning">graph a ...
...
</figcaption></figure>

On the other hand: If I include a regular-svg file (without graphviz): The html-page source looks like this:

<figure class="align-center">
<img alt="_images/1.5.A.svg" src="_images/regular.svg" /></figure>

And the regular-svg is just shown, as expected.

My assumption is, that the div class="graphviz" ... class="graphviz" makes a difference.

Anybody who has an idea what the problem is? From my understanding, sphinx.ext.graphviz should make sure, that its own classes or whatever cannot interfere with classes defined elsewhere... or am I wrong?

How to Reproduce

Unrelated, because error only appears on third-party website.

Environment Information

Platform:              linux; (Linux-6.5.0-1019-oem-x86_64-with-glibc2.35)
Python version:        3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0])
Python implementation: CPython
Sphinx version:        7.2.6
Docutils version:      0.18.1
Jinja2 version:        3.1.2
Pygments version:      2.16.1

Sphinx extensions

sphinx.ext.graphviz

Additional context

No response

kassbohm avatar Apr 16 '24 06:04 kassbohm