-
Notifications
You must be signed in to change notification settings - Fork 816
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
feat: add inline-svg filter #1444
base: main
Are you sure you want to change the base?
Conversation
Thanks. Curious about something: This extension does the same thing as pandoc's That is a nice feature IMO ! Also, I saw you have a |
@cderv first I just want to make sure I understand what you're saying. This is what I think you're saying: if you use If my understanding is correct, I think I should change the description of this to add something to that effect! Mainly my use-case or rather thinking was that the generated images from code on each page are not re-usable resources. As such I just wanted to simplify the output directory and put everything in a single page. This makes it easier to do something like upload the source to an S3 without having to search for related files or whatever. |
Also, since this was my first time writing a Lua filter (and last time I touched it), is this how I would update the filter to use the Quarto base64? I have to admit I don't understand how packaging works in Lua, but it seems like of like JS where the Quarto packages have already been loaded for use by extensions...? Before: -- Find references to generated SVGs and replace with SVGs.
local formats = { "html*", "markdown*", "commonmark*", "gfm", "markua" }
if match_any(FORMAT, formats) then
function Image(elem)
if file_exists(elem.src) and ends_with(elem.src, ".svg") then
local svg = read_svg(elem.src)
elem.src = "data:image/svg+xml;base64," .. base64(svg)
return { elem }
end
end
end After: ```lua
-- Find references to generated SVGs and replace with SVGs.
local formats = { "html*", "markdown*", "commonmark*", "gfm", "markua" }
if match_any(FORMAT, formats) then
function Image(elem)
if file_exists(elem.src) and ends_with(elem.src, ".svg") then
local svg = read_svg(elem.src)
elem.src = "data:image/svg+xml;base64," .. quarto.base64.encode(svg)
return { elem }
end
end
end |
Yes exactly. When using
This is definitely a good idea, that we could have leveraged into knitr directly. Your extension is even in better as it apply to all engine, not just knitr.
Yes any API we describe in https://quarto.org/docs/extensions/lua-api.html is available to be used in filter in Quarto context. There is no need to load anything. |
@cderv thanks for the feedback and clarifications! I updated the description here and in my README to note the similarity and difference from |
As requested by @RoyiAvital (coursekata/quarto-inline-svg#1)