Figure caption not showing when using inline SVG #5266
-
Hello, I'm using this filter for converting TikZ code to SVG in Quarto. When using the filter as is, it works (an example can be found at https://raw.githubusercontent.com/pandoc-ext/diagram/main/test/input-tikz.md). However, when I changed the code to replace the SVG file with inline SVG, the caption is not showing (I checked the output HTML and the More precisely, in the original code, an SVG image is created and store in -- Use the block's filename attribute or create a new name by hashing the image content.
local basename, _extension = pandoc.path.split_extension(
props.filename or pandoc.sha1(img)
)
local fname = basename .. '.' .. extension_for_mimetype[imgtype]
-- Store the data in the media bag:
pandoc.mediabag.insert(fname, imgtype, img)
-- Create a figure that contains just this image.
local img_obj = pandoc.Image(props.alt, fname, "", props['image-attr'])
return pandoc.Figure(pandoc.Plain{img_obj}, props.caption, props['fig-attr']) What I did is, instead of creating a file in the media bag, I used directly the SVG as an inline HTML element: return pandoc.Figure(pandoc.RawInline('html', img), props.caption, props['fig-attr']) (the above line replaces the entire previous code block) Using Pandoc alone, it worked:
However, when rendering
with Quarto, the SVG is displayed but not in a figure container and thus there's no caption. Could you please help? Thank you very much in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 14 replies
-
Could you share a more actionable example, such as a complete and small Quarto document using your filter? |
Beta Was this translation helpful? Give feedback.
Workaround: use the original
diagram.lua
filter and run the below filter after the Quarto filters:The time at which quarto filters are run can be controlled by using the special
quarto
filter:(Untested, so might need some tweeking.)