-
Notifications
You must be signed in to change notification settings - Fork 391
Description
Installing rsvg-convert on Windows can be challenging for users, requiring either manual binary installation or complex package manager setup. This affects workflows that convert SVG to PDF/LaTeX output, including mermaid diagrams with mermaid-format: svg.
resvg (https://github.com/linebender/resvg) is a modern Rust-based SVG rendering library with better cross-platform support. It provides pre-built binaries for all platforms and is available through Windows package managers (scoop, winget), making installation significantly easier for Windows users.
We could add resvg as an alternative SVG converter alongside rsvg-convert and Inkscape. The conversion pipeline in src/resources/filters/quarto-post/pdf-images.lua already handles rsvg-convert and has infrastructure for tool detection.
quarto-cli/src/resources/filters/quarto-post/pdf-images.lua
Lines 28 to 61 in c9008d7
| local function convert_svg(image) | |
| -- If the src is pointing to a local file that is an svg, process it | |
| local ext = select(2, pandoc.path.split_extension(image.src)) | |
| if ext ~= '.svg' then | |
| return nil | |
| end | |
| if not option("use-rsvg-convert", true) then | |
| local stem = pandoc.path.split_extension(image.src) | |
| local output = stem .. '.pdf' | |
| if not _quarto.file.exists(output) then | |
| warn("Skipping SVG conversion for " .. path .. " because use-rsvg-convert is false, but required PDF file does not exist: " .. output) | |
| else | |
| image.src = output | |
| return image | |
| end | |
| end | |
| local converted_path, must_clean = call_rsvg_convert(image.src) | |
| if converted_path == nil then | |
| return nil | |
| end | |
| local contents = _quarto.file.read(converted_path) | |
| assert(contents ~= nil) | |
| local relative_path = pandoc.path.make_relative(converted_path, '.') | |
| -- add to media bag and remove the converted file | |
| pandoc.mediabag.insert(relative_path, 'application/pdf', contents) | |
| if must_clean then | |
| _quarto.file.remove(relative_path) | |
| end | |
| image.src = relative_path | |
| return image | |
| end |
We could implement this similar to the existing use-rsvg-convert option, perhaps with a more general svg-converter option that accepts resvg, rsvg-convert, or inkscape, with automatic fallback to whichever tool is available.
This came up while investigating #13661, where better SVG tooling options would help Windows users. Directly addresses the request in #1144 for specifying alternative SVG conversion tools.