quarto-dev / quarto-dev/quarto-cli
Incorrect svg id salting with html `embed-resources: true`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
When using the embed-resources: true option, svg files are written inline into the html document. In order to avoid interactions between the svgs, all ids are salted with the svg id. We've noticed that CairoMakie.jl svg plots have their clipping paths disabled, and I could trace this to a missing salt of clip path ids.
Steps to reproduce
---
title: Quarto test
format:
html:
embed-resources: true
---
```{julia}
using CairoMakie
CairoMakie.activate!(type = "svg")
s = Scene()
ss = Scene(s, BBox(100, 200, 100, 200), camera = campixel!)
lines!(ss, [(-1000, -1000), (3000, 3000)])
print(repr(MIME"image/svg+xml"(), s))
```
```{julia}
s
```
Expected behavior
The line in the svg should be clipped to the scene boundingbox at (100, 200, 100, 200). In the non-embedded html this is correct and looks like:
I'm printing out the raw svg code in the example and it's:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="360pt" height="360pt" viewBox="0 0 360 360" version="1.1">
<defs>
<clipPath id="clip1-cc0e8a3b">
<path d="M 75 210 L 150 210 L 150 285 L 75 285 Z M 75 210 "/>
</clipPath>
</defs>
<g id="surface1-cc0e8a3b">
<rect x="0" y="0" width="360" height="360" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"/>
<g clip-path="url(#clip1-cc0e8a3b)" clip-rule="nonzero">
<path style="fill:none;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.705883%,69.803923%);stroke-opacity:1;stroke-miterlimit:2;" d="M -900 1380 L 3100 -2620 " transform="matrix(0.75,0,0,0.75,0,0)"/>
</g>
</g>
</svg>
Actual behavior
The line stretches across the whole svg and is not clipped.
When I inspect the source of the broken svg in the browser, I get this svg code:
<svg id="svg_1b8afb45a56147804e72" class="img-fluid figure-img" width="360pt" height="360pt" viewBox="0 0 360 360">
<defs>
<clipPath id="svg_1b8afb45a56147804e72_clip1-cc0e8a3b">
<path d="M 75 210 L 150 210 L 150 285 L 75 285 Z M 75 210 "></path>
</clipPath>
</defs>
<g id="svg_1b8afb45a56147804e72_surface1-cc0e8a3b">
<rect x="0" y="0" width="360" height="360" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"></rect>
<g clip-path="url(#clip1-cc0e8a3b)" clip-rule="nonzero">
<path style="fill:none;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.705883%,69.803923%);stroke-opacity:1;stroke-miterlimit:2;" d="M -900 1380 L 3100 -2620 " transform="matrix(0.75,0,0,0.75,0,0)"></path>
</g>
</g>
</svg>
Note the clip path definition <clipPath id="svg_1b8afb45a56147804e72_clip1-cc0e8a3b"> vs the clip path reference <g clip-path="url(#clip1-cc0e8a3b)". The salt is missing from the reference, breaking clipping.
Your environment
VScode
MacOS Monterey 12.3
Quarto check output
I ran this on latest quarto master, hence the weird version:
~/dev/quarto-cli/package/dist/bin/quarto check
Quarto 99.9.9
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.1.11: OK
Dart Sass version 1.69.5: OK
Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 99.9.9
Path: /Users/krumbiegel/dev/quarto-cli/package/dist/bin
[✓] Checking tools....................OK
TinyTeX: v2022.09
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/krumbiegel/Library/TinyTeX/bin/universal-darwin
Version: 2022
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.9.12 (Conda)
Path: /Users/krumbiegel/opt/miniconda3/bin/python
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with conda install jupyter
[✓] Checking R installation...........(None)
Unable to locate an installed version of R.
Install R from https://cloud.r-project.org/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Render the provided Quarto document with html embed-resources: true and inspect the generated inline SVG. Compare the salted clipPath id with the clip-path reference shown in the issue. Done means the reference includes the same salt as the definition and the line is clipped to the scene bounding box.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, julia
- Domain
- cli, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100