jgm/pandoc

`--embed-resources` drops the classes of embedded image when embedding element has classes of their own

cscheid opened this issue · 1 comments

Explain the problem.

When --embed-resources is used to embed an svg file that contains classes, and the image element that references it also contains classes, then pandoc picks the classes of the image element and drops those of the svg element.

Instead, I believe it should merge the two class lists. Repro follows:

$ cat svg_in.html
<img class="something" src="svg_with_classes.svg" />
$ cat svg_with_classes.svg
<?xml version='1.0' encoding='UTF-8' ?>
<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' class='please-do-not-delete-me' width='504.00pt' height='360.00pt' viewBox='0 0 504.00 360.00'>
</svg>
$ pandoc --embed-resources -f html -t html svg_in.html
<svg id="svg_b627f92299158b36552b" role="img" class="something" width="504.00pt" height="360.00pt" viewBox="0 0 504.00 360.00">
</svg>

Note that please-do-not-delete-me is missing from the result.

Pandoc version?

Pandoc 3.1.13, built from the github repo on macOS 13.5.2 (22G91), Apple Silicon.

I'll contribute the fix to this one, it affects Quarto's embedding of R plots with the svglite graphics device.

jgm commented

Sounds good, I'll await your PR.