emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Yoshinari Nomura <nom@quickhack.net>
To: n.goaziou@gmail.com
Cc: emacs-orgmode@gnu.org
Subject: Re: Add figure/table numbers to HTML captions
Date: Sat, 29 Jun 2013 19:00:22 +0900 (JST)	[thread overview]
Message-ID: <20130629.190022.261381241379739757.nom@quickhack.net> (raw)
In-Reply-To: <87zju9pcow.fsf@gmail.com>

[-- Attachment #1: Type: Text/Plain, Size: 941 bytes --]

Hi Nicolas,

>>     ox: add Japanese translations for figures and tables
>>     
>>     * lisp/ox.el: (org-export-dictionary): Add Japanese translations for
>>     figures and tables
> 
> You need to add TINYCHANGE at the end of your commit messages, since,
> AFAIK, you haven't signed FSF papers yet.

Yes.

>> -	   (let ((path (org-export-solidify-link-text path)) number)
>> +	   (let* ((path (org-export-solidify-link-text path)) number
>> +		  (caption-predicate
>> +		   (if (org-html--has-caption-p destination)
>> +		       'org-html--has-caption-p))
> 
> You can remove this. Just use `org-html--has-caption-p' and replaces
> references to `caption-predicate' below with it.

OK. Sorry for bothering you.

To tell the truth, I did not have enough confidence that any other
elements other than tables and figures are safe even if they were
impposed to have captions.

Regards,
--
Yoshinari Nomura
https://github.com/yoshinari-nomura

[-- Attachment #2: 0001-ox-html-add-figure-and-table-numbers-to-HTML-caption.patch --]
[-- Type: Text/X-Patch, Size: 3707 bytes --]

From 45eadd6308db8f0ec8646d7e23ce17b46d1f93fe Mon Sep 17 00:00:00 2001
From: Yoshinari Nomura <nom@quickhack.net>
Date: Sat, 29 Jun 2013 14:44:52 +0900
Subject: [PATCH 1/3] ox-html: add figure and table numbers to HTML captions

* lisp/ox-html.el: (org-html--has-caption-p): New function.
(org-html-link--inline-image),
(org-html-table): Prepend ordinal number to caption.
(org-html-link): Make numbered link by counting captioned figures and tables.
---
 lisp/ox-html.el | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index a996b40..0b8ca8d 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -1370,6 +1370,13 @@ (defun org-html--textarea-block (element)
 	    (or (plist-get attr :height) (org-count-lines code))
 	    code)))
 
+(defun org-html--has-caption-p (element &optional info)
+  "Non-nil when ELEMENT has a caption affiliated keyword.
+INFO is a plist used as a communication channel.  This function
+is meant to be used as a predicate for `org-export-get-ordinal' or
+a value to `org-html-standalone-image-predicate'."
+  (org-element-property :caption element))
+
 ;;;; Table
 
 (defun org-html-htmlize-region-for-paste (beg end)
@@ -2532,7 +2539,15 @@ (defun org-html-link--inline-image (link desc info)
 		      (expand-file-name raw-path))
 		     (t raw-path)))
 	 (parent (org-export-get-parent-element link))
-	 (caption (org-export-data (org-export-get-caption parent) info))
+	 (caption
+	  (let ((raw (org-export-data (org-export-get-caption parent) info))
+		(org-html-standalone-image-predicate 'org-html--has-caption-p))
+	    (if (org-string-nw-p raw)
+		(concat (format (org-html--translate "Figure %d:" info)
+				(org-export-get-ordinal
+				 link info nil 'org-html-standalone-image-p))
+			" " raw)
+	      raw)))
 	 (label (org-element-property :name parent)))
     ;; Return proper string, depending on DISPOSITION.
     (org-html-format-inline-image
@@ -2725,14 +2740,16 @@ (defun org-html-link (link desc info)
 		     (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
+		 (org-html-standalone-image-predicate 'org-html--has-caption-p))
 	     (unless desc
 	       (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 'org-html--has-caption-p))))
 	       (setq desc (when number
 			    (if (atom number) (number-to-string number)
 			      (mapconcat 'number-to-string number ".")))))
@@ -3145,6 +3162,8 @@ (defun org-html-table (table contents info)
     (t
      (let* ((label (org-element-property :name table))
 	    (caption (org-export-get-caption table))
+	    (number (org-export-get-ordinal
+		     table info nil 'org-html--has-caption-p))
 	    (attributes
 	     (if (org-html-html5-p info) ""
 	       (org-html--make-attribute-string
@@ -3183,7 +3202,9 @@ (defun org-html-table (table contents info)
 		 (format (if org-html-table-caption-above
 			     "<caption align=\"above\">%s</caption>"
 			   "<caption align=\"bottom\">%s</caption>")
-			 (org-export-data caption info)))
+			 (concat
+			  (format (org-html--translate "Table %d:" info) number)
+			  " " (org-export-data caption info))))
 	       (funcall table-column-specs table info)
 	       contents)))))
 
-- 
1.8.2.1


[-- Attachment #3: 0002-ox-add-dictionary-entry-for-numbered-figures.patch --]
[-- Type: Text/X-Patch, Size: 838 bytes --]

From 26b004825a1ac9337f9e677040cc934dcbeb878f Mon Sep 17 00:00:00 2001
From: Yoshinari Nomura <nom@quickhack.net>
Date: Sat, 29 Jun 2013 15:02:41 +0900
Subject: [PATCH 2/3] ox: add dictionary entry for numbered figures

* lisp/ox.el: (org-export-dictionary): Add "Figure %d:" entry
in the same manner with "Table %d:".

TINYCHANGE
---
 lisp/ox.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/ox.el b/lisp/ox.el
index fb56da4..e50e888 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -5266,6 +5266,9 @@ (defconst org-export-dictionary
     ("Figure"
      ("de" :default "Abbildung")
      ("es" :default "Figura"))
+    ("Figure %d:"
+     ("de" :default "Abbildung %d:")
+     ("es" :default "Figura %d:"))
     ("Footnotes"
      ("ca" :html "Peus de p&agrave;gina")
      ("cs" :default "Pozn\xe1mky pod carou")
-- 
1.8.2.1


[-- Attachment #4: 0003-ox-add-Japanese-translations-for-figures-and-tables.patch --]
[-- Type: Text/X-Patch, Size: 1553 bytes --]

From ad140620eee6cdb2f3b1a485eaaddce99aac4fe6 Mon Sep 17 00:00:00 2001
From: Yoshinari Nomura <nom@quickhack.net>
Date: Sat, 29 Jun 2013 15:06:49 +0900
Subject: [PATCH 3/3] ox: add Japanese translations for figures and tables

* lisp/ox.el: (org-export-dictionary): Add Japanese translations for
figures and tables

TINYCHANGE
---
 lisp/ox.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index e50e888..1133f21 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -5265,10 +5265,12 @@ (defconst org-export-dictionary
      ("fr" :ascii "Equation" :default "Équation"))
     ("Figure"
      ("de" :default "Abbildung")
-     ("es" :default "Figura"))
+     ("es" :default "Figura")
+     ("ja" :html "&#22259;" :utf-8 "図"))
     ("Figure %d:"
      ("de" :default "Abbildung %d:")
-     ("es" :default "Figura %d:"))
+     ("es" :default "Figura %d:")
+     ("ja" :html "&#22259;%d:" :utf-8 "図%d:"))
     ("Footnotes"
      ("ca" :html "Peus de p&agrave;gina")
      ("cs" :default "Pozn\xe1mky pod carou")
@@ -5315,7 +5317,8 @@ (defconst org-export-dictionary
      ("de" :default "Tabelle %d")
      ("es" :default "Tabla %d")
      ("fr"
-      :ascii "Tableau %d :" :default "Tableau nº %d :" :latin1 "Tableau %d :"))
+      :ascii "Tableau %d :" :default "Tableau nº %d :" :latin1 "Tableau %d :")
+     ("ja" :html "&#34920;%d:" :utf-8 "表%d:"))
     ("Table of Contents"
      ("ca" :html "&Iacute;ndex")
      ("cs" :default "Obsah")
-- 
1.8.2.1


  reply	other threads:[~2013-06-29 10:00 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
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 [this message]
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=20130629.190022.261381241379739757.nom@quickhack.net \
    --to=nom@quickhack.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@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).