Hi there, this is Local State.
The current Image
directive is not enough for svg files. Using img
tag loses interactivities, and the width, and height can't be applied for svg files directly. It's better to use style="width:50%"
instead.
I'm hoping there could be 2 new options for Image
directive.
tag
This would determine the html tag used to render the image. The default value would be img
, and we could also use object
, iframe
and embed
as alternatives. Currently, all images are rendered with img
tag, which loses some interactivities (e.g., the text in svg file). We could avoid this by using object
tag. I see there are some similar work in html4css1
about object_image_types
.
Example: ``` <img src="a.png" width="50%" alt="alt msg">` <object data="a.png" style="width:50%">alt msg</object> <iframe src="a.png" width="50%" title="alt msg"></iframe> <embed src="a.png" width="50%">` ```
embed
If enabled, this option would embed the image into the html file using base64 encoding.
While I see there is already the if sentence in the visit_image
function.
if self.settings.embed_images or ('embed' in node):
The embed_images
could be set from command-line or setting, but I can't find how to satisfy the latter condition, since any node doesn't seem to have embed
attribute. Could anyone tell me how to enable it? If we can't, then it's necessary to add the embed
option, so that we could choose to embed one particular image or not.
Especially, I notice there exist a todo
item for svg embedding. I'd like to implement it if possible. But the first option is still in demand, because most times we don't want our html files to be so large and need separate svg files.
svg files under <img>
tag can't correctly render height and width if svg viewbox information is not contained in the file. It might be better to set the height and width in style
indirectly.
I would like to fix and implement all these things if possible. But I'm not quite familiar with SourceForge and don't know how to submit a PR like what we do in github.
Thanks for the correction. To clarify, I've tested more deeply and find the potential bug doesn't exist. It appears only because the css style in my project
width:100%
overrides thewidth=50%
option defined in the tag. Sorry for my misleading.But there is actually one bug for svg in generated latex docs, because
\includegraphics
doesn't support svg files.sphinx.ext.imgconverter
andsphinxcontrib-svg2pdfconverter
provides alternative solutions to convert svg files to pdf as alternative solutions.But in my opinion, maybe fix the
\includegraphics
to\includesvg
in upstream docutils might be a better solution.Last edit: Local State 2021-10-12
Thank you for the suggestion and the offer to contribute.
New Options
The "embed" option is planned in combination with "lazy" loading, see https://sourceforge.net/p/docutils/feature-requests/78/.
A "tag" option for a specific image format/output format combination does not seem the right approach to me.
Addition (2023-11-27): this is now discussed in [feature-requests:#100]
Potential bugs
The HTML5 writer already uses the "style" argument for width and height values with units (e.g.
:height: 0.8em
→style="height: 0.8em;"
). This should also override a rule from a CSS style-sheet.Contribution
The "Docutils Project Policies" have a section about ways to contribute:
https://docutils.sourceforge.io/docs/dev/policies.html#how-to-get-a-new-feature-into-docutils
We can work with patches made with "diff", SVN, or Git.
Related
Feature Requests:
#100Last edit: Günter Milde 2024-10-14
tag
andembed
options inImage
directive --> Support SVT images in LaTeXChanging the title to reflect the part of the report that is still open.
@milde the title should be "SVG" not "SVT" I believe.
A
SVG support via the "svg" LaTeX package is implemented in [r9999].
Related
Commit: [r9999]