Skip to content

Commit 902df7f

Browse files
committed
Fix PDF build: render plantweb diagrams as PNG for non-HTML builders
plantweb defaults to SVG format, which pdflatex cannot include, causing a fatal 'Unknown graphics extension: .svg' error in the LaTeX build. Sphinx adds the builder name to 'tags' before executing conf.py, so we can override plantweb's defaults cache to use PNG for any non-HTML builder (latex, man, texinfo, etc.). HTML builds continue to use SVG for crisp vector output. https://claude.ai/code/session_014hVQ5UrK1B4N9ar4UfYpm4
1 parent 92e2529 commit 902df7f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

doc/conf.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
# that regardless of FORCE_COLOR, and dfetch's own Rich console respects it too.
2121
os.environ["NO_COLOR"] = "1"
2222

23+
# plantweb renders PlantUML diagrams as SVG by default, which pdflatex cannot
24+
# include. Override to PNG for all non-HTML builders (e.g. LaTeX/PDF).
25+
if not tags.has("html"): # type: ignore[name-defined] # noqa: F821
26+
import plantweb.defaults as _plantweb_defaults
27+
_pd = _plantweb_defaults.read_defaults()
28+
_pd["format"] = "png"
29+
_plantweb_defaults.read_defaults.cache = _pd
30+
2331
# -- General configuration ------------------------------------------------
2432

2533
ext_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "_ext"))

0 commit comments

Comments
 (0)