emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Yoshinari Nomura <nom@quickhack.net>
To: emacs-orgmode@gnu.org
Subject: Re: Add figure/table numbers to HTML captions
Date: Fri, 28 Jun 2013 10:15:30 +0900 (JST)	[thread overview]
Message-ID: <20130628.101530.1683355082328893107.nom@quickhack.net> (raw)
In-Reply-To: <87li5vsjb8.fsf@gmail.com>

Hi Nicolas, 

On Thu, 27 Jun 2013 16:46:19 +0200,
	Nicolas Goaziou <n.goaziou@gmail.com> said:

> Sure. Here are a few comments in addition to those suggested by Rasmus
> in this thread.

Thanks for your to-the-point advice. I've hesitated to add some
functions at the top level and split commits. I'll follow your advice.

>> +    (unless (string= caption "")
>> +      (let* ((org-html-standalone-image-predicate
>> +	      (lambda (img) (org-element-property :caption img)))
>> +	     (number (org-export-get-ordinal
>> +		      link info nil 'org-html-standalone-image-p)))
> 
> You should put this function at the top level instead, since another
> transcoder use it. See `org-ascii--has-caption-p' in ascii export
> back-end. You can also use a lambda each time. Your call.

Thanks, you encouraged me. Also, while I made this patch, I was in
the mood for consolidating some exporter-local functions around the
captions. Especially, ox-odt and ox-ascii seem to have rich functions to
add ordinal numbers to captions. It might be over-killing, though.

Anyway, I'll add `org-html--has-caption-p' for this time.

>> @@ -2725,14 +2734,23 @@ INFO is a plist holding contextual information.  See
>>  		     (org-export-solidify-link-text href) attributes desc)))
>>  	  ;; Fuzzy link points to a target.  Do as above.
>>  	  (t
>> -	   (let ((path (org-export-solidify-link-text path)) number)
>> +	   (let ((path (org-export-solidify-link-text path)) number
>> +		 caption-predicate org-html-standalone-image-predicate)
>>  	     (unless desc
>> +	       (setq caption-predicate
>> +		     (if (org-element-property :caption destination)
>> +			 (lambda (elem &optional info)
>> +			   (org-element-property :caption elem))
>> +		       (lambda (elem &optional info)
>> +			 (not (org-element-property :caption elem)))))
>> +	       (setq org-html-standalone-image-predicate caption-predicate)
>>  	       (setq number (cond
>>  			     ((org-html-standalone-image-p destination info)
>>  			      (org-export-get-ordinal
>>  			       (assoc 'link (org-element-contents destination))
>>  			       info 'link 'org-html-standalone-image-p))
>> -			     (t (org-export-get-ordinal destination info))))
>> +			     (t (org-export-get-ordinal
>> +				 destination info nil
>> caption-predicate))))
> 
> You don't need to change `org-html-link'. I think it already DTRT.

I'm afraid I made some misunderstand, but without this hunk,
Tables/Figures without captions are mistakenly counted as a part of
numbered staffs. As shown below, Figure[[fig:manual]] makes Figure3
instead of Figure2.

* Figure Test
  See Figure[[fig:screenshot]] for screenshot.
  See Figure[[fig:manual]] for printed version of Org's manual.

  #+CAPTION: Org mode screen shot
  #+name: fig:screenshot
  [[http://orgmode.org/img/main.jpg]]

  This is org-mode logo: [[http://orgmode.org/img/org-mode-unicorn-logo.png]]
  (no caption, excluded from ordinal list).

  #+CAPTION: Org mode manual
  #+name: fig:manual
  [[http://orgmode.org/img/org-mode-7-network-theory.jpg]]


>> -     ("es" :default "Figura"))
>> +     ("es" :default "Figura")
>> +     ("ja" :html "&#22259;" :utf-8 "図"))
>> +    ("Figure %d:"
>> +     ("de" :default "Abbildung %d:")
>> +     ("es" :default "Figura %d:")
>> +     ("ja" :html "&#22259;%d:" :utf-8 "図%d:"))
> 
> Maybe you should also provide a :default value, otherwise it will use
> "Figure %d:" for latex, texinfo, ascii...

Let me confirm, do you mean I should have add :default value to the ``ja''
entry like: ("ja" :default "図" :html "&#22259;" :utf-8 "図")? In this
case, is the `:utf-8' meaning-less? Also, can I put UTF-8 word in `:default'?

> Also, I think it belong to a different patch. Would you mind splitting
> them?

Indeed.

I'll revise my patch in this weekend. thanks.
Regards,
--
Yoshinari Nomura
https://github.com/yoshinari-nomura

  reply	other threads:[~2013-06-28  1:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-27 10:52 Add figure/table numbers to HTML captions Yoshinari Nomura
2013-06-27 11:34 ` Rasmus
2013-06-27 23:37   ` Yoshinari Nomura
2013-06-27 14:46 ` Nicolas Goaziou
2013-06-28  1:15   ` Yoshinari Nomura [this message]
2013-06-28  9:23     ` Nicolas Goaziou
2013-06-28 11:51       ` Yoshinari Nomura
2013-06-29  7:01       ` Yoshinari Nomura
2013-06-29  8:02         ` Nicolas Goaziou
2013-06-29 10:00           ` Yoshinari Nomura
2013-06-29 12:09             ` Nicolas Goaziou
2013-06-29 13:48               ` Yoshinari Nomura
     [not found]                 ` <rt-3.4.5-3864-1375881898-1936.839264-5-0@rt.gnu.org>
2013-08-08  0:43                   ` Yoshinari Nomura
2013-08-08 12:22                     ` Nicolas Goaziou

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=20130628.101530.1683355082328893107.nom@quickhack.net \
    --to=nom@quickhack.net \
    --cc=emacs-orgmode@gnu.org \
    /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).