Eric Schulte <schulte.e...@gmail.com> wrote: > Hi Tom, > > "Thomas S. Dye" <t...@tsdye.com> 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 "<a href=\"" thefile "\"" attr ">" (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 "<img src=\"%s\" alt=\"%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 _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode