This is to track possible enhancement/fix when inline HTML such as SVG is included in a Figure Pandoc AST node (such as the one emitted by `diagram.lua` below).

Note that the issue was raised in the discussion below when using a version of <https://github.com/pandoc-ext/diagram> under active development.
A workaround has been found and is documented in the discussion.

### Discussed in https://github.com/quarto-dev/quarto-cli/discussions/5266

<div type='discussions-op-text'>

<sup>Originally posted by **netw0rkf10w** April 21, 2023</sup>
Hello,

I'm using [this filter](https://github.com/pandoc-ext/diagram/blob/main/diagram.lua) 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 `figure` container was not even generated).

More precisely, in the original code, an SVG image is created and store in `img`, then:

```lua
-- 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:
```lua
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:**

```
quarto pandoc --lua-filter filters/diagram.lua -s tikz.qmd  -o tikz.html
```

However, when rendering `tikz.qmd` containing
```
filters:
  - diagram.lua
```
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!</div>
cscheid
2023-04-24T21:03:41Z
mcanouil
enhancement crossref
v1.4
open
Caption not showing when using inline SVG in Figure AST node
https://github.com/quarto-dev/quarto-cli/issues/5297