emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: nicholas.dokos@hp.com, Org Mode <emacs-orgmode@gnu.org>
Subject: Re: html export
Date: Sat, 19 Jun 2010 23:58:04 -0400	[thread overview]
Message-ID: <4967.1277006284@gamaville.dokosmarshall.org> (raw)
In-Reply-To: Message from "Eric Schulte" <schulte.eric@gmail.com> of "Sat, 19 Jun 2010 20:28:28 PDT." <871vc28js3.fsf@gmail.com>

Eric Schulte <schulte.eric@gmail.com> wrote:

> Hi Tom,
> 
> "Thomas S. Dye" <tsd@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

  reply	other threads:[~2010-06-20  3:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-20  1:50 html export Thomas S. Dye
2010-06-20  3:28 ` Eric Schulte
2010-06-20  3:58   ` Nick Dokos [this message]
2010-06-20 16:11   ` Thomas S. Dye
2010-06-20 18:14     ` Eric Schulte
2010-06-20 20:17       ` Nick Dokos
2010-06-20 20:54       ` Thomas S. Dye
  -- strict thread matches above, loose matches on Subject: below --
2010-05-27 16:37 Thomas S. Dye
2010-05-27 20:58 ` Carsten Dominik
2010-05-27 21:29   ` Sebastian Rose

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4967.1277006284@gamaville.dokosmarshall.org \
    --to=nicholas.dokos@hp.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=schulte.eric@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).