Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated SVGs do not get height and width attributes when --embed-resources is used #9439

Closed
frabjous opened this issue Feb 9, 2024 · 2 comments
Labels

Comments

@frabjous
Copy link

frabjous commented Feb 9, 2024

(Note, this is copied over from a comment I made on closed issue #8969; also relevant may be #9206 and #9420.)

There seems to be an issue with multiple instances of the svg in a document when --embed-resources is used.

Consider this markdown:

Here is my circle: ![small circle](smallcircle.svg).

Here is my circle again: ![small circle](smallcircle.svg).

If you process this with just pandoc --standalone test.md -o test.html so the svgs are not embedded you get a fairly normal looking document when viewed in a browser:

circtest-no-embed

If you process the same but embed the svgs with pandoc --standalone --embed-resources test.md -o test.html you get a completely different looking document, where the first circle swells to fill the space.

circtest-with-embed

From what I can tell this is just because the first svg element references the second but does have have its own height and width attributes, and so swells to fill the remainder. Setting the viewBox is insufficient. If the height and width attributes are manually added to the first svg tag, the problem is solved.

I'm attaching smallcircle.svg used for testing, but I've had this issue will all svgs.

smallcircle

(Tested with pandoc 3.1.11.1 on linux x86_64, released Jan 2024.)

@jgm
Copy link
Owner

jgm commented Feb 9, 2024

Output:

  <p>Here is my circle:
    <svg alt="small circle" viewBox="0 0 4.9742332 4.732645" inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" sodipodi:docname="smallcircle.svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
      <use href="#svg1" width="100%" height="100%" />
    </svg>.
  </p>
  <p>Here is my circle again:
    <svg id="svg1" alt="small circle" width="4.9742332mm" height="4.732645mm" viewBox="0 0 4.9742332 4.732645" inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" sodipodi:docname="smallcircle.svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
      <sodipodi:namedview id="svg1_namedview1" pagecolor="#ffffff" bordercolor="#000000" borderopacity="0.25" inkscape:showpageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:document-units="mm" inkscape:zoom="0.7786055" inkscape:cx="389.15728" inkscape:cy="547.13202" inkscape:window-width="1115" inkscape:window-height="1072" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="layer1">
      </sodipodi:namedview>
      <defs id="svg1_defs1">
      </defs>
  <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="svg1_layer1" transform="translate(-2.1787294,-3.5764914)">
    <ellipse style="fill:none;stroke:#000000;stroke-width:0.264583" id="svg1_path1" cx="4.6658459" cy="5.9428139" rx="2.354825" ry="2.234031">
    </ellipse>
  </g>
    </svg>.
  </p>

@jgm
Copy link
Owner

jgm commented Feb 9, 2024

Adding width="4.9742332mm" height="4.732645mm" to the first svg element seems to fix this.
Need to remember why we removed it originally!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants