From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: html export Date: Sat, 19 Jun 2010 23:58:04 -0400 Message-ID: <4967.1277006284@gamaville.dokosmarshall.org> References: <871vc28js3.fsf@gmail.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from [140.186.70.92] (port=48410 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQBfe-0006j5-5Y for emacs-orgmode@gnu.org; Sat, 19 Jun 2010 23:58:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OQBfb-0006ZV-CN for emacs-orgmode@gnu.org; Sat, 19 Jun 2010 23:58:10 -0400 Received: from vms173015pub.verizon.net ([206.46.173.15]:57038) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OQBfb-0006Ye-8p for emacs-orgmode@gnu.org; Sat, 19 Jun 2010 23:58:07 -0400 Received: from gamaville.dokosmarshall.org ([unknown] [173.76.32.106]) by vms173015.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0L4A004DCOCSKA90@vms173015.mailsrvcs.net> for emacs-orgmode@gnu.org; Sat, 19 Jun 2010 22:58:05 -0500 (CDT) In-reply-to: Message from "Eric Schulte" of "Sat, 19 Jun 2010 20:28:28 PDT." <871vc28js3.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: nicholas.dokos@hp.com, Org Mode Eric Schulte wrote: > Hi Tom, > > "Thomas S. Dye" writes: > > > Aloha all, > > > > Exporting this small file to html here doesn't put a caption on the > > figure. > > > > * No caption > > > > #+CAPTION: Histogram of adze weights on a logarithmic scale > > #+LABEL: fig:wt-log > > > > [[file:~/Public/projects/903_adzes/r/sr-nb-scatter.png]] > > > > Does anyone else see this? > > > > Try removing the empty line between the #+LABEL:... line and the > [[file:... line, that worked for me. or rather the following worked for > me > > * No caption > > #+CAPTION: Histogram of adze weights on a logarithmic scale > #+LABEL: fig:wt-log > [[file:graph.png]] > > > also, if the file doesn't exist, then neither the file, nor the label or > caption will export. > I can't get it to work with or without the empty line: Org-mode version 6.36trans (release_6.36.264.g74d3) Be that as it may, I compared the html export code with the latex export code and it seems to me that the caption is calculated too late in the html code: it's done in org-export-html-format-image by looking for the org-caption text property on its ``src'' argument, but afaict, the argument is just a string - no text properties. I tried the following patch, which makes the html caption handling look a bit more like what the latex exporter does, and it seems to work in this case, but I have not tested it any further. Thanks, Nick diff --git a/lisp/org-html.el b/lisp/org-html.el index d5809ab..73cba14 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -621,7 +621,8 @@ MAY-INLINE-P allows inlining it as an image." opt-plist components-1) components-1)) (type (first components-2)) - (thefile (second components-2))) + (thefile (second components-2)) + (caption (org-find-text-property-in-string 'org-caption path))) ;;Third pass. Build final link except for leading type @@ -651,7 +652,7 @@ MAY-INLINE-P allows inlining it as an image." (not fragment)) (progn (message "image %s %s" thefile org-par-open) - (org-export-html-format-image thefile org-par-open)) + (org-export-html-format-image thefile caption org-par-open)) (concat "" (org-export-html-format-desc desc) @@ -1674,14 +1675,13 @@ lang=\"%s\" xml:lang=\"%s\"> (org-html-do-expand s)) s)) -(defun org-export-html-format-image (src par-open) +(defun org-export-html-format-image (src caption par-open) "Create image tag with source and attributes." (save-match-data (if (string-match "^ltxpng/" src) (format "\"%s\"/" src (org-find-text-property-in-string 'org-latex-src src)) - (let* ((caption (org-find-text-property-in-string 'org-caption src)) - (attr (org-find-text-property-in-string 'org-attributes src)) + (let* ((attr (org-find-text-property-in-string 'org-attributes src)) (label (org-find-text-property-in-string 'org-label src))) (setq caption (and caption (org-html-do-expand caption))) (concat