emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Standalone hyperlinked images in HTML export


From: Kodi Arfer
Subject: [O] Standalone hyperlinked images in HTML export
Date: Sun, 30 Jun 2013 16:07:19 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

The manual explains in "Images in HTML export" that you can make an image a hyperlink like this:

[[file:highres.jpg][file:thumb.jpg]]

where thumb.jpg becomes the <img> 'src' and highres.jpg becomes the <a> 'href'. One might infer it should also be possible to link to something other than an image, like this:

[[http://gnu.org][http://example.com/gnu-head.jpg]]

For example, try exporting this file:

#+begin_src org
Some initial text.

[[http://example.com/a.png]]

Some text between images 1 and 2.

[[http://eeyup.com][http://example.com/b.png]]

Some text between images 2 and 3.

http://example.com/c.png

Some trailing text.
#+end_src

You do indeed get

<a href="http://eeyup.com";><img src="http://example.com/b.png"; alt="b.png" /></a>

in the output, but the exporter doesn't regard the image as standalone, so it doesn't get put in a <div> (or, in HTML5 mode, <figure>) like the others, and if you add a #+CAPTION, no caption will be included.

The attached patch to master shows how this can be fixed, but I hesitate to recommend applying it because two new bugs are immediately apparent:

1. Figure numbers are screwed up. If you add #+CAPTIONs to each image in the above file, the figure numbers go Figure 1, Figure 3, Figure 4.

2. The <a ...> ... </a> gets wrapped around the whole <div> or <figure>, not just the <img>. This breaks markup validity (<div> isn't allowed in <a>) and makes the caption, if you have one, into a giant hyperlink.

I think I'm going to stop working on this issue for now, but at least what I've done could be helpful for anybody else who wants to go further down the rabbit hole.

P.S. I sent a request for a copyright-assignment form earlier today.

Attachment: 0001-ox-html-Allow-standalone-images-to-be-hyperlinked.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]