From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoshinari Nomura Subject: Re: Add figure/table numbers to HTML captions Date: Fri, 28 Jun 2013 10:15:30 +0900 (JST) Message-ID: <20130628.101530.1683355082328893107.nom@quickhack.net> References: <20130627.195226.131243714189666347.nom@cs.okayama-u.ac.jp> <87li5vsjb8.fsf@gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsNJc-0004qt-Vc for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 21:17:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsNJa-0007a6-Cy for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 21:17:32 -0400 Received: from vintage.swlab.cs.okayama-u.ac.jp ([150.46.8.117]:62976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsNJZ-0007Ze-Jf for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 21:17:30 -0400 Received: from localhost (unknown [172.21.23.5]) by vintage.swlab.cs.okayama-u.ac.jp (Postfix) with ESMTPSA id 1AB602F962BB for ; Fri, 28 Jun 2013 10:17:26 +0900 (JST) In-Reply-To: <87li5vsjb8.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: emacs-orgmode@gnu.org Hi Nicolas, = On Thu, 27 Jun 2013 16:46:19 +0200, Nicolas Goaziou said: > Sure. Here are a few comments in addition to those suggested by Rasmu= s > 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=3D 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 t= o 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 informati= on. 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 "図" :utf-8 "=E5=9B=B3")) >> + ("Figure %d:" >> + ("de" :default "Abbildung %d:") >> + ("es" :default "Figura %d:") >> + ("ja" :html "図%d:" :utf-8 "=E5=9B=B3%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 ``j= a'' entry like: ("ja" :default "=E5=9B=B3" :html "図" :utf-8 "=E5=9B=B3= ")? In this case, is the `:utf-8' meaning-less? Also, can I put UTF-8 word in `:def= ault'? > Also, I think it belong to a different patch. Would you mind splittin= g > them? Indeed. I'll revise my patch in this weekend. thanks. Regards, -- Yoshinari Nomura https://github.com/yoshinari-nomura