-
Notifications
You must be signed in to change notification settings - Fork 18
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
Issue#340 #341
Issue#340 #341
Conversation
Oooh, this is amazing! Thanks for taking the time to put this together. I'm having a crazy week at work so won't have to look at this right now. But at first glance, one thing I'll say is that I don't think we should add a new argument for this, since "portable" only applies to a single output format --- it is not a modifier for LaTeX, Typst, etc. So I would lean toward something like |
Thanks for your kind words. I had the above solution so there was no reason why not to contribute. That is a good idea about If I am reading and understanding the code correctly, the plots are created only when an object is forced to evaluate, either by print method or by explicitely calling Alternatively, (and with And yet another option would be to make the current brute-force approach just much more efficient, able to take any image, even user provided, and just force the generated images to be created in a I kind of like the idea of fully portable html with all packed images, rather than semi portable one. I will look into it and modify the code accordingly. |
Cool, that sounds excellent. Yes, obviously not deleting the user's images is crucial. I don't have a strong view on the other options since I haven't looked at this carefully, but doing all this in Note: If we're using an extra package to convert the encoding, I'd like that package to be optional, meaning in the Suggests section of DESCRIPTION, and calling |
There is an issue with Internally, we can use |
Yes, I agree that portable by default feels fine, as long as we can draw tables with no image without installing the suggested dependency. |
This is an alternative implementation that results in much simpler code. I wasn't able to figure out how to make But by modifying the Currently, only the locally available images are encoded, not remote URLs, since I had problem with the extension-less URL in the examples, this would require guessing mimetype. All images are assumed to be of mimetype image, not sure if it will work with some special cases like PDF. |
Would it be possible to do something like this at the very top of if (isTRUE(output == "html_portable")) {
output <- "html"
x@portable <- TRUE
} If I understand your logic, this would allow us to carry the |
Instead of: if(isTRUE(portable)){
assert_dependency("base64enc")
x@portable <- TRUE
} to remove the Or in addition to it so that If instead of, and thus removing the
Yes |
I thought we were going for portable by default. Is there a convincing use-case for not making HTML portable? I suppose one might want to keep the HTML itself smaller, but that seems like a niche application, which could potentially be dealt with using a global option rather than an extra argument. My issue with adding a What do you think? |
Can do. The only arguments against it might be that:
But if you are happy with this potentially breaking behaviour, I am happy to fix the PR so that we have |
Thanks, those are some good arguments against. How about we do it the other way?
|
FYI, I updated this PR to |
Test case was failing since the merge did change something with random string generation for the CSS formatting. |
Merged. Thanks a ton for this @J-Moravec . This is a super cool feature, and I'm very grateful for the code! |
Fix for #340.
The current implementation simply translates the png images into base64encoded string within the
save_tt()
function.The option
portable
is marked as experimental.A better implementation might utilize the lazy eval of the plots and translate them during the building process.
This would certainly avoid many different bugs. The proper fix should likely be somewhere in the
build_tt.R
, or even inplot_tt.R
and using some way of passing the "portable" parameter along, so that we are sure that only the generated images are encoded. But that would require quite a bit more knowledge from me about the structure of the code.Let's have this as a conversation starter about what would be the best way to fix it.
Issues:
Do to these issues, please do not merge yet.
All relevant tests are passing (but unrelated tests for markdown and pdf seem to be not passing, but their code paths were not modified)
Some contributor instructions would be helpful.