Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Support embedded images #8

Open
coldacid opened this issue Nov 13, 2020 · 1 comment
Open

Support embedded images #8

coldacid opened this issue Nov 13, 2020 · 1 comment

Comments

@coldacid
Copy link

Spinning this out to its own issue from #7.

ox-html checks if a link is the only content for a paragraph, and if so checks if the link's file extension matches in a customizable list, to determine whether or not to emit an <img> tag into the exported HTML. If the paragraph has a #+CAPTION keyword it will use the caption value as well. ox-slimhtml should be able to emit images as well, although with simpler HTML than ox-html emits. There is also support for #+ATTR_HTML to explicitly set attributes on the <img> tag.

As an example, org-mode versus ox-html output, as well as what ox-slimhtml currently emits:

#+CAPTION: This is the image caption.
#+ATTR_HTML: :width 300
[[http://example.com/picture.png]]

ox-html:

<figure id="orgfffffff">
<img src="http://example.com/picture.png" alt="picture.png" width="300">

<figcaption><span class="figure-number">Figure 1: </span>This is the image caption.</figcaption>
</figure>

ox-slimhtml:

<p><em>//example.com/picture.png</em>
</p>

Since <img> is an inline tag, despite being only supported as block-level content by Org, we should probably wrap the emitted image tag within a block such as a <div> or <p> tag, even if we don't support captions.

I've been hand-modifying ox-slimhtml's output so that the example above would become like this:

<p><img src="https://example.com/picture.png" alt="This is the image caption."/><br/>
<em>This is the image caption</em>
</p>

Open questions:

  • Support captions or not?
  • Support custom tag attributes or not?
  • Use org-html-inline-image-rules or hard-coded extension list? (By default, the rules only match for file, http, https schemes for GIF, JPEG, PNG, and SVG files.)
  • What should the alt attribute be set to? (ox-html defaults to the base filename unless explicitly overridden by #+ATTR_HTML)
@coldacid
Copy link
Author

Looks like ox-html does processing both in its paragraph emitter and its link emitter to handle images. Captions and the wrapping block tag for an image come out of the paragraph transcoder (org-html--wrap-image via org-html-paragraph), while the <img> tag itself comes out of the link transcoder (org-html--format-image by way of org-html-link).

A simple export that ignores captions could probably be handled strictly via the link transcoder. Anyone who needs captions could use a derived exporter with a custom paragraph transcoder.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant