-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Optionally embed SVG as data URI instead of inlining? #9787
Comments
Same thing on Safari. Well, maybe we need a command line option for this. |
It also has other side effects. E.g., the default CSS for revealjs presentations sets the max width for |
One solution to this would be to add a rule for |
Not sure what the right interface would be for this. One option would be to make it configurable on a per-image basis, e.g. by inlining sensitive to a Or there could be an option like |
Because inlined SVGs act differently than SVGs included via So my proposal would be: |
Let's get input from @nxn-4-wdf who proposed the inline SVG feature in #8948. |
As I understand it, a big part of the original issue was that prior to the change, the SVGs were converted to PNGs and then linked as data URIs in img tags. This was problematic because of a loss of resolution (moving from a vector to a bitmap format). I don't know why we didn't consider using a data URI with the encoded SVGs, since as far as I know SVGs can be used in img tags. But I see a lot of contradictory suggestions on this on the net, and I'm really not up on this. What's the current advice about using SVGs in img tags? |
Today, SVG is a standard image file format and can be used basically everywhere in HTML & CSS where other image files are used: MDN SVG as an Image. Displaying SVG via The difference to other image file formats is that SVG is an XML application and a subset of HTML5, and can therefore additionally inlined into HTML. That, too, is widely supported: CanIUse Inline SVG in HTML5. I didn't find any consistent advice on inline vs
However, since without But to keep those possibilities available, new proposal: By default, Regarding #8948: Rendering SVGs to a bitmap for embedding is obviously not the right thing to do, because of the loss of resolution as pointed out in the issue. I suspect @nxn-4-wdf was simply not aware that SVGs work as data URI with |
I like that. |
One nice thing the inlining gives us, though, is compression. If you have many images with the same SVG, pandoc will use |
Hi @jgm ,
Yes, inlining as with 1. breaks the existing behaviour, and should be made opt-in. Using an attribute like
|
You can also create a filter that adds |
When an SVG file is embedded in HTML output with
--embed-resources
, Pandoc inlines the SVG code into the HTML code. This differs from the behavior for other image file types, which are embedded by setting theimg
src
attribute to a data URI. This special behavior makes sense, because the data URI unnecessarily obfuscates things.However, it has the unfortunate side effect that the SVG image can no longer be easily saved to a file or opened in a separate tab from a browser. I.e. right-clicking on the image opens a context menu which lacks the entries "Open image in new tab", "Save image as..." etc. (tested in Brave, Chromium, and Firefox on Linux).
Example HTML to demonstrate the difference:
The two images look exactly the same, but the first cannot be saved to a file while the second can.
I find it useful for a user to be able to access an image separately from the main document.
Therefore my feature request: Could we have an option to disable the inlining of SVG files (with
--embed-resources
) such that data URIs are created instead?The text was updated successfully, but these errors were encountered: