-
Notifications
You must be signed in to change notification settings - Fork 331
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
Images in gt tables are not processed correctly by quarto into Typst #11829
Comments
I can repro this, thanks for the report. That's very strange. |
That's not surprising. GT emits HTML and Quarto needs to convert the table to Pandoc's AST format in order for it to have any chance to show up in Typst! |
GT (understandably) emits these images as data URIs; I wonder if this is fundamentally the issue. |
I did not attempt to test images inside gt when implementing Typst CSS / html table processing for Typst. It would be nice to have sparklines and such. Would think data URIs would work. |
They do work in a simplified setting outside of GT:
That is a wholly-white PNG image, and this compiles to a table without a problem. |
Copy-pasting the image from the GT output into my simple table reintroduces the bug. So this is not GT: it's either Pandoc or Quarto. |
I can repro with your simplified example. On a hunch, I disabled juice, and both examples succeed. So it's either juice or my glue code around it. |
@gordonwoodhull It's a juice bug 😬 Instrumenting local function handle_raw_html_as_table(el)
local eltext
-- write el.text to disk
local f = io.open("/tmp/juice-input.html", "w")
f:write(el.text)
f:close()
if(_quarto.format.isTypstOutput()) then
eltext = juice(el.text)
local f = io.open("/tmp/juice-output.html", "w")
f:write(eltext)
f:close()
else
eltext = el.text
end
... Then we can already see the problem with the file sizes:
|
It should be possible for us to protect data-URI-encoded images to work around |
Yeah, seeing the same thing. I think it could be a line length issue ( > 43300 characters) Agree, any kind of placeholder should work. Will try. |
Interestingly (?), calling
|
Oh, that must be a bug they fixed in 11.0.0; we're running juice 10.0.0. EDIT: No, that's not it. Running juice directly from deno on those inputs doesn't trigger the bug (on version 10, or 11, either from |
Nod, I still see truncation if I change
and version is 11 |
Okay I misread this at first: https://stackoverflow.com/questions/695151/data-protocol-url-size-limitations There isn't any fixed limit of 32K but it does seem that juice is deciding to truncate data URIs under 15K characters for its own reasons. |
Ok cool. Our workaround then is pretty clear - we intercept data URIs, replace them with UUIDs and then wrap it back. |
Bug description
I have found an issue while trying to use gt for tables with plots in Typst.
The plots that are created in the
text_transform
function are copied into thefilename_files/mediabag
folder incorrectly. Some of all of them are broken and they appears incomplete. png and svg files seems truncated and jpg files have a broken encoding.I was able to reproduce the behaviour with the following gt functions:
ggplot_image
,local_image
,fmt_image
.The issue may be related to Pandoc and the HTML processing that is performed on tables. However, when I tried using the
html-table-processing: none
option the table simply did not appear.In the .typ output file it is clear that the issue is related to pointing the image to a broken copy of the picture, which happens even if a static image is provided.
Steps to reproduce
Expected behavior
Pictures that are copied into
filename_files/mediabag
should be identical to the originalActual behavior
Pictures that are copied into
filename_files/mediabag
are broken, possibly truncated.Error message
Your environment
Quarto check output
Note: I am on the pre-release version right now because updated in the hope of resolving the issue. The issue was the same in the 1.6 version I was using before.
The text was updated successfully, but these errors were encountered: