From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kodi Arfer Subject: Standalone hyperlinked images in HTML export Date: Sun, 30 Jun 2013 16:07:19 -0400 Message-ID: <51D08FF7.3020002@arfer.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030406000403050406060305" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtNu8-00048u-G9 for emacs-orgmode@gnu.org; Sun, 30 Jun 2013 16:07:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtNu5-0000el-Li for emacs-orgmode@gnu.org; Sun, 30 Jun 2013 16:07:24 -0400 Received: from mxout-08.mxes.net ([216.86.168.183]:26289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtNu5-0000eZ-F7 for emacs-orgmode@gnu.org; Sun, 30 Jun 2013 16:07:21 -0400 Received: from [192.168.1.103] (unknown [76.117.57.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTPSA id 3B55050A85 for ; Sun, 30 Jun 2013 16:07:20 -0400 (EDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------030406000403050406060305 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 'src' and highres.jpg becomes the '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 b.png in the output, but the exporter doesn't regard the image as standalone, so it doesn't get put in a
(or, in HTML5 mode,
) 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 ... gets wrapped around the whole
or
, not just the . This breaks markup validity (
isn't allowed in ) 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. --------------030406000403050406060305 Content-Type: text/x-patch; name="0001-ox-html-Allow-standalone-images-to-be-hyperlinked.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-ox-html-Allow-standalone-images-to-be-hyperlinked.patch" >From fe74b3507795f2664291250250bc24b943f8f12b Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 30 Jun 2013 15:40:33 -0400 Subject: [PATCH] ox-html: Allow standalone images to be hyperlinked * lisp/ox-html.el (org-html-standalone-image-p): If the link is the description of another link, look one more element up the tree to find `paragraph'. * lisp/ox.el (org-export-inline-image-p): When the description is a link, test the description instead of the path. TINYCHANGE --- lisp/ox-html.el | 9 ++++++--- lisp/ox.el | 38 ++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 4753e66..4091bcc 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2579,9 +2579,12 @@ standalone images, do the following. \(org-element-property :caption paragraph\)\)\)" (let ((paragraph (case (org-element-type element) (paragraph element) - (link (and (org-export-inline-image-p - element org-html-inline-image-rules) - (org-export-get-parent element))) + (link (let ((x (and (org-export-inline-image-p + element org-html-inline-image-rules) + (org-export-get-parent element)))) + (if (eq (org-element-type x) 'link) + (org-export-get-parent x) + x))) (t nil)))) (when (eq (org-element-type paragraph) 'paragraph) (when (or (not (and (boundp 'org-html-standalone-image-predicate) diff --git a/lisp/ox.el b/lisp/ox.el index 08fbddd..9179576 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -3919,20 +3919,30 @@ type is TYPE. The function will return a non-nil value if any of the provided rules is non-nil. The default rule is `org-export-default-inline-image-rule'. -This only applies to links without a description." - (and (not (org-element-contents link)) - (let ((case-fold-search t) - (rules (or rules org-export-default-inline-image-rule))) - (catch 'exit - (mapc - (lambda (rule) - (and (string= (org-element-property :type link) (car rule)) - (string-match (cdr rule) - (org-element-property :path link)) - (throw 'exit t))) - rules) - ;; Return nil if no rule matched. - nil)))) +This only applies to links without a description, unless the +description is itself a link, as for hyperlinked images in HTML. +In this case, the test is applied to the description instead of +the path." + (let* ((cs (org-element-contents link)) + (dlink (and (= (length cs) 1) + (eq (org-element-type (car cs)) 'link) + (car cs)))) + (when (or dlink (not (org-element-contents link))) + (message "dlink: %s" (show-org-element dlink)) + (when dlink + (setq link dlink)) + (let ((case-fold-search t) + (rules (or rules org-export-default-inline-image-rule))) + (catch 'exit + (mapc + (lambda (rule) + (and (string= (org-element-property :type link) (car rule)) + (string-match (cdr rule) + (org-element-property :path link)) + (throw 'exit t))) + rules) + ;; Return nil if no rule matched. + nil))))) (defun org-export-resolve-coderef (ref info) "Resolve a code reference REF. -- 1.8.1.2 --------------030406000403050406060305-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Standalone hyperlinked images in HTML export Date: Mon, 01 Jul 2013 00:08:05 +0200 Message-ID: <87zju7nryo.fsf@bzg.ath.cx> References: <51D08FF7.3020002@arfer.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtQHg-0005Me-AO for emacs-orgmode@gnu.org; Sun, 30 Jun 2013 18:39:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtQHe-00077E-8H for emacs-orgmode@gnu.org; Sun, 30 Jun 2013 18:39:52 -0400 Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:58405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtQHe-00076z-2t for emacs-orgmode@gnu.org; Sun, 30 Jun 2013 18:39:50 -0400 Received: by mail-wg0-f53.google.com with SMTP id y10so3226855wgg.20 for ; Sun, 30 Jun 2013 15:39:49 -0700 (PDT) In-Reply-To: <51D08FF7.3020002@arfer.net> (Kodi Arfer's message of "Sun, 30 Jun 2013 16:07:19 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Kodi Arfer Cc: emacs-orgmode@gnu.org Hi Kodi, Kodi Arfer writes: > 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. I can't follow this rabbit right now, but I hope someone can tidy things up a bit here (been there, done that...) > P.S. I sent a request for a copyright-assignment form earlier today. I added you here: http://orgmode.org/worg/org-contribute.html#sec-6-2 Thanks! -- Bastien From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Standalone hyperlinked images in HTML export Date: Mon, 01 Jul 2013 13:50:36 +0200 Message-ID: <87sizyqz1v.fsf@gmail.com> References: <51D08FF7.3020002@arfer.net> <87zju7nryo.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Utccj-0000Us-KP for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 07:50:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Utcci-0000KN-H4 for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 07:50:25 -0400 In-Reply-To: <87zju7nryo.fsf@bzg.ath.cx> (Bastien's message of "Mon, 01 Jul 2013 00:08:05 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: emacs-orgmode@gnu.org, Kodi Arfer Bastien writes: > Kodi Arfer writes: > >> 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. > > I can't follow this rabbit right now, but I hope someone can > tidy things up a bit here (been there, done that...) I will have a look later today. Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Standalone hyperlinked images in HTML export Date: Mon, 01 Jul 2013 23:01:46 +0200 Message-ID: <87hageq9j9.fsf@gmail.com> References: <51D08FF7.3020002@arfer.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtlEA-0003en-Dj for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 17:01:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtlE7-0000xO-Nn for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 17:01:38 -0400 Received: from mail-we0-x22e.google.com ([2a00:1450:400c:c03::22e]:64518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtlE7-0000wX-CU for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 17:01:35 -0400 Received: by mail-we0-f174.google.com with SMTP id q58so3740439wes.33 for ; Mon, 01 Jul 2013 14:01:34 -0700 (PDT) In-Reply-To: <51D08FF7.3020002@arfer.net> (Kodi Arfer's message of "Sun, 30 Jun 2013 16:07:19 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Kodi Arfer Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hello, Kodi Arfer writes: > 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 'src' and highres.jpg becomes the > '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 > > alt="b.png" /> > > in the output, but the exporter doesn't regard the image as standalone, > so it doesn't get put in a
(or, in HTML5 mode,
) like the > others, and if you add a #+CAPTION, no caption will be included. Indeed. Would you mind testing the following patch against master? It should fix the issues. Regards, -- Nicolas Goaziou --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-html-Fix-standalone-hyperlinked-images.patch >From b20ae9f2cc1af67250af9917541b071ab778f36f Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 1 Jul 2013 22:51:26 +0200 Subject: [PATCH] ox-html: Fix standalone hyperlinked images * lisp/ox-html.el (org-html-inline-images): Change default value and remove `maybe'. (org-html-format-inline-image): Remove functions. (org-html--wrap-image, org-html--format-image, org-html-inline-image-p): New functions. (org-html-latex-environment, org-html-latex-fragment): Use new functions. (org-html-standalone-image-p): Use new functions. Also remove an unused optional argument. (org-html-link, org-html-paragraph): Correctly export hyperlinked images. This patch permits the back-end to recognize links like: [[http://orgmode.org][http://orgmode.org/img/org-mode-unicorn-logo.png]] as standalone, so they can get wrapped within a proper environment and get captions. Thanks to Kodi Arfer for reporting it. --- lisp/ox-html.el | 257 +++++++++++++++++++++++++++----------------------------- 1 file changed, 124 insertions(+), 133 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 4753e66..b8d927f 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -713,16 +713,14 @@ When nil, the links still point to the plain `.org' file." ;;;; Links :: Inline images -(defcustom org-html-inline-images 'maybe +(defcustom org-html-inline-images t "Non-nil means inline images into exported HTML pages. This is done using an tag. When nil, an anchor with href is used to -link to the image. If this option is `maybe', then images in links with -an empty description will be inlined, while images with a description will -be linked only." +link to the image." :group 'org-export-html - :type '(choice (const :tag "Never" nil) - (const :tag "Always" t) - (const :tag "When there is no description" maybe))) + :version "24.4" + :package-version '(Org . "8.1") + :type 'boolean) (defcustom org-html-inline-image-rules '(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'") @@ -1326,39 +1324,43 @@ attributes with a nil value will be omitted from the result." "\"" """ (org-html-encode-plain-text item)))) (setcar output (format "%s=\"%s\"" key value)))))))) -(defun org-html-format-inline-image (src info &optional - caption label attr standalone-p) - "Format an inline image from SRC. -CAPTION, LABEL and ATTR are optional arguments providing the -caption, the label and the attribute of the image. -When STANDALONE-P is t, wrap the into a
...
." - (let* ((id (if (not label) "" - (format " id=\"%s\"" (org-export-solidify-link-text label)))) - (attr (concat attr - (format " src=\"%s\"" src) - (cond - ((string-match "\\%s%s\n
" - "\n%s%s\n
") - id (format "\n

%s

" img) - (if (and caption (not (string= caption ""))) - (format (if html5-fancy - "\n
%s
" - "\n

%s

") caption) "")))) - (t (org-html-close-tag "img" (concat attr id) info))))) +(defun org-html--wrap-image (contents info &optional caption label) + "Wrap CONTENTS string within an appropriate environment for images. +INFO is a plist used as a communication channel. When optional +arguments CAPTION and LABEL are given, use them for caption and +\"id\" attribute." + (let ((html5-fancy (and (org-html-html5-p info) + (plist-get info :html-html5-fancy)))) + (format (if html5-fancy "\n%s%s\n
" + "\n%s%s\n
") + ;; ID. + (if (not (org-string-nw-p label)) "" + (format " id=\"%s\"" (org-export-solidify-link-text label))) + ;; Contents. + (format "\n

%s

" contents) + ;; Caption. + (if (not (org-string-nw-p caption)) "" + (format (if html5-fancy "\n
%s
" + "\n

%s

") + caption))))) + +(defun org-html--format-image (source attributes info) + "Return \"img\" tag with given SOURCE and ATTRIBUTES. +SOURCE is a string specifying the location of the image. +ATTRIBUTES is a plist, as returned by +`org-export-read-attribute'. INFO is a plist used as +a communication channel." + (org-html-close-tag + "img" + (org-html--make-attribute-string + (org-combine-plists + (list :src source + :alt (if (string-match-p "^ltxpng/" source) + (org-html-encode-plain-text + (org-find-text-property-in-string 'org-latex-src source)) + (file-name-nondirectory source))) + attributes)) + info)) (defun org-html--textarea-block (element) "Transcode ELEMENT into a textarea block. @@ -2478,21 +2480,19 @@ CONTENTS is nil. INFO is a plist holding contextual information." (let ((processing-type (plist-get info :with-latex)) (latex-frag (org-remove-indentation (org-element-property :value latex-environment))) - (caption (org-export-data - (org-export-get-caption latex-environment) info)) - (attr nil) ; FIXME - (label (org-element-property :name latex-environment))) - (cond - ((memq processing-type '(t mathjax)) - (org-html-format-latex latex-frag 'mathjax)) - ((eq processing-type 'dvipng) - (let* ((formula-link (org-html-format-latex - latex-frag processing-type))) - (when (and formula-link - (string-match "file:\\([^]]*\\)" formula-link)) - (org-html-format-inline-image - (match-string 1 formula-link) info caption label attr t)))) - (t latex-frag)))) + (attributes (org-export-read-attribute :attr_html latex-environment))) + (case processing-type + ((t mathjax) + (org-html-format-latex latex-frag 'mathjax)) + (dvipng + (let ((formula-link (org-html-format-latex latex-frag processing-type))) + (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) + ;; Do not provide a caption or a name to be consistent with + ;; `mathjax' handling. + (org-html--wrap-image + (org-html--format-image + (match-string 1 formula-link) attributes info) info)))) + (t latex-frag)))) ;;;; Latex Fragment @@ -2505,12 +2505,9 @@ CONTENTS is nil. INFO is a plist holding contextual information." ((t mathjax) (org-html-format-latex latex-frag 'mathjax)) (dvipng - (let* ((formula-link (org-html-format-latex - latex-frag processing-type))) - (when (and formula-link - (string-match "file:\\([^]]*\\)" formula-link)) - (org-html-format-inline-image - (match-string 1 formula-link) info)))) + (let ((formula-link (org-html-format-latex latex-frag processing-type))) + (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) + (org-html--format-image (match-string 1 formula-link) nil info)))) (t latex-frag)))) ;;;; Line Break @@ -2522,41 +2519,30 @@ CONTENTS is nil. INFO is a plist holding contextual information." ;;;; Link -(defun org-html-link--inline-image (link desc info) - "Return HTML code for an inline image. - -LINK is the link pointing to the inline image. INFO is a plist -used as a communication channel. - -Inline images can have these attributes: - -#+ATTR_HTML: :width 100px :height 100px :alt \"Alt description\"." - (let* ((type (org-element-property :type link)) - (raw-path (org-element-property :path link)) - (path (cond ((member type '("http" "https")) - (concat type ":" raw-path)) - ((file-name-absolute-p raw-path) - (expand-file-name raw-path)) - (t raw-path))) - (parent (org-export-get-parent-element link)) - (caption - (let ((raw (org-export-data (org-export-get-caption parent) info)) - (org-html-standalone-image-predicate 'org-html--has-caption-p)) - (if (not (org-string-nw-p raw)) raw - (concat (format (org-html--translate "Figure %d:" info) - (org-export-get-ordinal - link info nil 'org-html-standalone-image-p)) - " " raw)))) - (label (org-element-property :name parent))) - ;; Return proper string, depending on DISPOSITION. - (org-html-format-inline-image - path info caption label - (org-html--make-attribute-string - (org-export-read-attribute :attr_html parent)) - (org-html-standalone-image-p link info)))) +(defun org-html-inline-image-p (link info) + "Non-nil when LINK stands for an inline image. +INFO is a plist used as a communication channel. LINK is an +inline image when it has no description and targets an image +file (see `org-html-inline-image-rules' for more information), or +if its description is a single link targeting an image file." + (if (not (org-element-contents link)) + (org-export-inline-image-p link org-html-inline-image-rules) + (not + (let ((link-count 0)) + (org-element-map (org-element-contents link) + (cons 'plain-text org-element-all-objects) + (lambda (obj) + (case (org-element-type obj) + (plain-text (org-string-nw-p obj)) + (link (if (= link-count 1) t + (incf link-count) + (not (org-export-inline-image-p + obj org-html-inline-image-rules)))) + (otherwise t))) + info t))))) (defvar org-html-standalone-image-predicate) -(defun org-html-standalone-image-p (element info &optional predicate) +(defun org-html-standalone-image-p (element info) "Test if ELEMENT is a standalone image for the purpose HTML export. INFO is a plist holding contextual information. @@ -2570,34 +2556,29 @@ whitespaces. Return nil, otherwise. -Bind `org-html-standalone-image-predicate' to constrain -paragraph further. For example, to check for only captioned -standalone images, do the following. +Bind `org-html-standalone-image-predicate' to constrain paragraph +further. For example, to check for only captioned standalone +images, set it to: - \(setq org-html-standalone-image-predicate - \(lambda \(paragraph\) - \(org-element-property :caption paragraph\)\)\)" + \(lambda (paragraph) (org-element-property :caption paragraph))" (let ((paragraph (case (org-element-type element) (paragraph element) - (link (and (org-export-inline-image-p - element org-html-inline-image-rules) - (org-export-get-parent element))) - (t nil)))) - (when (eq (org-element-type paragraph) 'paragraph) - (when (or (not (and (boundp 'org-html-standalone-image-predicate) - (functionp org-html-standalone-image-predicate))) - (funcall org-html-standalone-image-predicate paragraph)) - (let ((contents (org-element-contents paragraph))) - (loop for x in contents - with inline-image-count = 0 - always (cond - ((eq (org-element-type x) 'plain-text) - (not (org-string-nw-p x))) - ((eq (org-element-type x) 'link) - (when (org-export-inline-image-p - x org-html-inline-image-rules) - (= (incf inline-image-count) 1))) - (t nil)))))))) + (link (and (org-html-inline-image-p element info) + (org-export-get-parent element)))))) + (and (eq (org-element-type paragraph) 'paragraph) + (or (not (and (boundp 'org-html-standalone-image-predicate) + (functionp org-html-standalone-image-predicate))) + (funcall org-html-standalone-image-predicate paragraph)) + (not (let ((link-count 0)) + (org-element-map (org-element-contents paragraph) + (cons 'plain-text org-element-all-objects) + (lambda (obj) (case (org-element-type obj) + (plain-text (org-string-nw-p obj)) + (link + (or (> (incf link-count) 1) + (not (org-html-inline-image-p obj info)))) + (otherwise t))) + info 'first-match 'link)))))) (defun org-html-link (link desc info) "Transcode a LINK object from Org to HTML. @@ -2656,22 +2637,17 @@ INFO is a plist holding contextual information. See ;; Extract attributes from parent's paragraph. HACK: Only do ;; this for the first link in parent. This is needed as long ;; as attributes cannot be set on a per link basis. - (attributes + (attributes-plist (let ((parent (org-export-get-parent-element link))) - (if (not (eq (org-element-map parent 'link 'identity info t) link)) - "" - (let ((att (org-html--make-attribute-string - (org-export-read-attribute :attr_html parent)))) - (cond ((not (org-string-nw-p att)) "") - ((and desc (string-match (regexp-quote att) desc)) "") - (t (concat " " att))))))) + (and (eq (org-element-map parent 'link 'identity info t) link) + (org-export-read-attribute :attr_html parent)))) + (attributes (org-html--make-attribute-string attributes-plist)) protocol) (cond ;; Image file. - ((and (or (eq t org-html-inline-images) - (and org-html-inline-images (not desc))) + ((and org-html-inline-images (org-export-inline-image-p link org-html-inline-image-rules)) - (org-html-link--inline-image link desc info)) + (org-html--format-image path attributes-plist info)) ;; Radio target: Transcode target's contents and use them as ;; link's description. ((string= type "radio") @@ -2791,11 +2767,26 @@ the plist used as a communication channel." ((and (eq (org-element-type parent) 'item) (= (org-element-property :begin paragraph) (org-element-property :contents-begin parent))) - ;; leading paragraph in a list item have no tags + ;; Leading paragraph in a list item have no tags. contents) ((org-html-standalone-image-p paragraph info) - ;; standalone image - contents) + ;; Standalone image. + (let ((caption + (let ((raw (org-export-data + (org-export-get-caption paragraph) info)) + (org-html-standalone-image-predicate + 'org-html--has-caption-p)) + (if (not (org-string-nw-p raw)) raw + (concat + (format (org-html--translate "Figure %d:" info) + (org-export-get-ordinal + (org-element-map paragraph 'link + 'identity info t) + info nil 'org-html-standalone-image-p)) + " " raw)))) + (label (org-element-property :name paragraph))) + (org-html--wrap-image contents info caption label))) + ;; Regular paragraph. (t (format "\n%s

" extra contents))))) ;;;; Plain List -- 1.8.3.2 --=-=-=-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kodi Arfer Subject: Re: Standalone hyperlinked images in HTML export Date: Mon, 01 Jul 2013 17:26:05 -0400 Message-ID: <51D1F3ED.6080606@arfer.net> References: <51D08FF7.3020002@arfer.net> <87hageq9j9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Utlbw-0002wJ-N2 for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 17:26:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Utlbr-0002Ta-KJ for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 17:26:12 -0400 Received: from mxout-08.mxes.net ([216.86.168.183]:56788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Utlbr-0002R5-F0 for emacs-orgmode@gnu.org; Mon, 01 Jul 2013 17:26:07 -0400 In-Reply-To: <87hageq9j9.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org On 2013 Jul 01 Mon 5:01:46 PM -0400, Nicolas Goaziou wrote: > Hello, > > Kodi Arfer writes: > >> 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 'src' and highres.jpg becomes the >> '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 >> >> > alt="b.png" /> >> >> in the output, but the exporter doesn't regard the image as standalone, >> so it doesn't get put in a
(or, in HTML5 mode,
) like the >> others, and if you add a #+CAPTION, no caption will be included. > > Indeed. Would you mind testing the following patch against master? It > should fix the issues. I tried it with captions, :html5-fancy, and paths to images as well as path to non-images. All looks good. You're awesome. I see your patch also affects math export somehow, but I haven't tested that. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Standalone hyperlinked images in HTML export Date: Tue, 02 Jul 2013 21:13:16 +0200 Message-ID: <87k3l8ojw3.fsf@gmail.com> References: <51D08FF7.3020002@arfer.net> <87hageq9j9.fsf@gmail.com> <51D1F3ED.6080606@arfer.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu60g-0001C6-2l for emacs-orgmode@gnu.org; Tue, 02 Jul 2013 15:13:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uu60e-0007cL-I0 for emacs-orgmode@gnu.org; Tue, 02 Jul 2013 15:13:06 -0400 Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:34875) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uu60e-0007cA-Bw for emacs-orgmode@gnu.org; Tue, 02 Jul 2013 15:13:04 -0400 Received: by mail-wg0-f47.google.com with SMTP id l18so4971104wgh.26 for ; Tue, 02 Jul 2013 12:13:03 -0700 (PDT) In-Reply-To: <51D1F3ED.6080606@arfer.net> (Kodi Arfer's message of "Mon, 01 Jul 2013 17:26:05 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Kodi Arfer Cc: emacs-orgmode@gnu.org Hello, Kodi Arfer writes: > On 2013 Jul 01 Mon 5:01:46 PM -0400, Nicolas Goaziou wrote: > I tried it with captions, :html5-fancy, and paths to images as well as > path to non-images. All looks good. You're awesome. > > I see your patch also affects math export somehow, but I haven't > tested that. Applied to master. Thank you for the feedback. Regards, -- Nicolas Goaziou