Re: [O] Add figure/table numbers to HTML captions
Hello, Yoshinari Nomura writes: > I just want to update you on my completion of the assignment/disclaimer > process with FSF. Thank you. I added you to the list of FSF signed contributors. Regards, -- Nicolas Goaziou
Re: [O] Add figure/table numbers to HTML captions
Hello, I just want to update you on my completion of the assignment/disclaimer process with FSF. Regards, On Sat, 29 Jun 2013 22:48:04 +0900 (JST), Yoshinari Nomura said: >> I applied your patches and added you to the list of contributors without >> FSF papers. Please consider signing them if you want to provide more >> patches to Org mode. > > Thank you so much. I'll go on the FSF procedure. Subject: [gnu.org #839264] Yoshinari Nomura - EMACS ORG-MODE Assignment Date: Wed, 07 Aug 2013 09:24:58 -0400 > Hello, > > Your assignment/disclaimer process with the FSF is currently > complete; your fully executed PDF will be sent to you in a separate > email immediately following this one. (snip) > ___ > INFORMATION FOR THE MAINTAINER(S) > > Here's how the contributor answered the question, “ Did you copy any > files or text written by someone else in these changes?” > > no > > [Which files have you changed so far, and which new files have you written > so far?] > > Org-mode staffs: > lisp/ox.el > lisp/ox-html.el
Re: [O] Add figure/table numbers to HTML captions
Hi Nicolas, >> OK. Sorry for bothering you. > > You're not bothering me. > > I applied your patches and added you to the list of contributors without > FSF papers. Please consider signing them if you want to provide more > patches to Org mode. Thank you so much. I'll go on the FSF procedure. -- Yoshinari Nomura https://github.com/yoshinari-nomura
Re: [O] Add figure/table numbers to HTML captions
Yoshinari Nomura writes: > OK. Sorry for bothering you. You're not bothering me. I applied your patches and added you to the list of contributors without FSF papers. Please consider signing them if you want to provide more patches to Org mode. Thank you again. Regards, -- Nicolas Goaziou
Re: [O] Add figure/table numbers to HTML captions
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 >From 45eadd6308db8f0ec8646d7e23ce17b46d1f93fe Mon Sep 17 00:00:00 2001 From: Yoshinari Nomura 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 "%s" "%s") - (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 >From 26b004825a1ac9337f9e677040cc934dcbeb878f Mon Sep 17 00:00:00 2001 From: Yoshinari Nomura 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
Re: [O] Add figure/table numbers to HTML captions
Hello, Yoshinari Nomura writes: > I've split my work into these three commits: > 0001-ox-html-add-figure-and-table-numbers-to-HTML-caption.patch > 0002-ox-add-dictionary-entry-for-numbered-figures.patch > 0003-ox-add-Japanese-translations-for-figures-and-tables.patch > (enclosed in the attachments) Thanks for your work. Some minor comments below. > commit a82e712c3d60d8b58e2cffe13d5cbcdfa25ede24 > Author: Yoshinari Nomura > Date: Sat Jun 29 15:06:49 2013 +0900 > > 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. > -(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. Otherwise, the patch looks good. Could you send the files as an attachment? It will be easier for me to apply them. Regards, -- Nicolas Goaziou
Re: [O] Add figure/table numbers to HTML captions
Hello Nicolas, >> I'll revise my patch in this weekend. thanks. I've split my work into these three commits: 0001-ox-html-add-figure-and-table-numbers-to-HTML-caption.patch 0002-ox-add-dictionary-entry-for-numbered-figures.patch 0003-ox-add-Japanese-translations-for-figures-and-tables.patch (enclosed in the attachments) I've also pushed them to my github repository: g...@github.com:yoshinari-nomura/org-mode.git branch: tab-and-fig-number-to-ox-html Please check the commits. I'm willing to revise them again if needed. Thanks for your great effort to tidy-up my rough work. Regards, -- Yoshinari Nomura https://github.com/yoshinari-nomura commit a82e712c3d60d8b58e2cffe13d5cbcdfa25ede24 Author: Yoshinari Nomura Date: Sat Jun 29 15:06:49 2013 +0900 ox: add Japanese translations for figures and tables * lisp/ox.el: (org-export-dictionary): Add Japanese translations for figures and tables commit faced47cb6d049cbb4b6323556543bd86e32884d Author: Yoshinari Nomura Date: Sat Jun 29 15:02:41 2013 +0900 ox: add dictionary entry for numbered figures * lisp/ox.el: (org-export-dictionary): Add "Figure %d:" entry in the same manner with "Table %d:". commit 793f69627fa290c95d41c0af9792fdafdda98b06 Author: Yoshinari Nomura Date: Sat Jun 29 14:44:52 2013 +0900 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. >From 793f69627fa290c95d41c0af9792fdafdda98b06 Mon Sep 17 00:00:00 2001 From: Yoshinari Nomura 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 | 32 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index a996b40..30b23ca 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,19 @@ (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 + (caption-predicate + (if (org-html--has-caption-p destination) + 'org-html--has-caption-p)) + (org-html-standalone-image-predicate caption-predicate)) (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 caption-predicate (setq desc (when number (if (atom number) (number-to-string number) (mapconcat 'number-to-string number ".") @@ -3145,6 +3165,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 +3205,9 @@ (defun org-
Re: [O] Add figure/table numbers to HTML captions
Hi Nicolas, On Fri, 28 Jun 2013 11:23:41 +0200, Nicolas Goaziou said: > (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) > > I suggest to drop the "else" part. If destination hasn't got any > caption, numbering doesn't make much sense anyway. You can re-use > `org-html--has-caption-p'. Ah, you are right. I was a little bit paranoia. My intention was: if a destination of link hasn't got any destination, the link should express the *nth* non-caption figure. >> Let me confirm, do you mean I should have add :default value to the ``ja'' >> entry like: ("ja" :default "図" :html "図" :utf-8 "図")? In this >> case, is the `:utf-8' meaning-less? Also, can I put UTF-8 word in >> `:default'? > > :utf-8 will be used for ODT export and UTF-8 export. LaTeX export will > try to use, in this order, :latex, :default and "Figure %d:". Plain > ASCII will use, in this order, :ascii, :default and "Figure %d:". > > I suggest to use a simple entry for :default, maybe romanji, if it makes > sense. You can also use UTF-8 encoding as :default, and provide some > meaningful translation for :ascii. Thanks for your clear explanation. For many Japanese, :default value should be "Figure: %d:", even though we are not good at English :) I want this left blank. Regards, -- Yoshinari Nomura https://github.com/yoshinari-nomura
Re: [O] Add figure/table numbers to HTML captions
Hello, Yoshinari Nomura writes: > 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. ox-odt caption handling is more complex because it handles more elements (e.g., links to ODF files). ox-ascii provides the bare minimum wrt caption numbering. This is what your patch provides. > 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. Of course, you're right. I realized that just after sending the message. Though, in the following snippet, (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) I suggest to drop the "else" part. If destination hasn't got any caption, numbering doesn't make much sense anyway. You can re-use `org-html--has-caption-p'. > >>> - ("es" :default "Figura")) >>> + ("es" :default "Figura") >>> + ("ja" :html "図" :utf-8 "図")) >>> +("Figure %d:" >>> + ("de" :default "Abbildung %d:") >>> + ("es" :default "Figura %d:") >>> + ("ja" :html "図%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 "図" :utf-8 "図")? In this > case, is the `:utf-8' meaning-less? Also, can I put UTF-8 word in > `:default'? :utf-8 will be used for ODT export and UTF-8 export. LaTeX export will try to use, in this order, :latex, :default and "Figure %d:". Plain ASCII will use, in this order, :ascii, :default and "Figure %d:". I suggest to use a simple entry for :default, maybe romanji, if it makes sense. You can also use UTF-8 encoding as :default, and provide some meaningful translation for :ascii. > I'll revise my patch in this weekend. thanks. Thank you. Regards, -- Nicolas Goaziou
Re: [O] Add figure/table numbers to HTML captions
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 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 "図" :utf-8 "図")) >> +("Figure %d:" >> + ("de" :default "Abbildung %d:") >> + ("es" :default "Figura %d:") >> + ("ja" :html "図%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 "図" :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
Re: [O] Add figure/table numbers to HTML captions
Hi Rasmus, Thanks your good suggestion. > I'm not an expert on html, but how easy it is to enable/disable/alter > your solution locally compared to a html5/css solution? E.g. as here: > > > http://tympanus.net/codrops/2013/05/02/automatic-figure-numbering-with-css-counters/ > > Note, I don't know if this can be used for tables, or only figures, > but being able to change the style in css seems nice. I'm also not an expert on HTML, but I think we can add some HTML annotations such as id, class... That will help the HTML5 staffs to manipulate the ordinal-number part in captions. Besides the HTML matter, I might have to add some control variables to on/off the numbering feature. As for the ``automatic numbering with css'' concept, it might be difficult to work with ox-html. Because ox-html has to control all the ordinal numbers by itself to use the numbers in the anchor texts conforming with the numbers in captions. Also, TOC scheme might be suffered. >http://orgmode.org/worg/org-contribute.html > > You could use git format-patch and make sure that the commit message > is a change-log entry as described on Worg (C-x 4 a on your change in > the diff file should bring up the correct changelog mode). Thanks a lot! I've forgot the word RTFM :) -- Yoshinari Nomura https://github.com/yoshinari-nomura
Re: [O] Add figure/table numbers to HTML captions
Hello, Yoshinari Nomura writes: > I sometimes need to export an org document into both HTML and LaTeX. > In such case, I want HTML exporter to create numbered captions for > figures and tables. > > So, I've written a small patch to add figure/table numbers to HTML > captions. (see 0001-Add-figure-table-numbers-to-HTML-captions.patch) I hadn't noticed HTML export back-end didn't provide this feature already. I agree this should be implemented. Thank you for taking care of it. > I'll be very happy if this feature is merged into the master branch. Sure. Here are a few comments in addition to those suggested by Rasmus in this thread. > +(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. > + (setq caption > + (concat > +(format (org-html--translate "Figure %d:" info) number) > +" " caption I would move this in the first caption binding. Assuming you implemented `org-html--has-caption-p', you could use something like: (let (... (caption (let ((raw (org-export-data (org-export-get-caption parent) info))) (when (org-string-nw-p raw) (concat (format (org-html--translate "Figure %d:" info) (org-export-get-ordinal link info nil 'org-html--has-caption-p)) " " raw)) > ;; Return proper string, depending on DISPOSITION. > (org-html-format-inline-image > path info caption label > @@ -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. > (setq desc (when number > (if (atom number) (number-to-string number) > (mapconcat 'number-to-string number ".") > @@ -3145,6 +3163,9 @@ contextual information." > (t > (let* ((label (org-element-property :name table)) > (caption (org-export-get-caption table)) > + (number (org-export-get-ordinal > + table info nil > + (lambda (tbl info) (org-element-property :caption tbl See comment above. > - ("es" :default "Figura")) > + ("es" :default "Figura") > + ("ja" :html "図" :utf-8 "図")) > +("Figure %d:" > + ("de" :default "Abbildung %d:") > + ("es" :default "Figura %d:") > + ("ja" :html "図%d:" :utf-8 "図%d:")) Maybe you should also provide a :default value, otherwise it will use "Figure %d:" for latex, texinfo, ascii... Also, I think it belong to a different patch. Would you mind splitting them? > ("Footnotes" > ("ca" :html "Peus de pàgina") > ("cs" :default "Pozn\xe1mky pod carou") > @@ -5312,7 +5317,8 @@ them." > ("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 "表%d:" :utf-8 "表%d:")) Ditto. Regards, -- Nicolas Goaziou
Re: [O] Add figure/table numbers to HTML captions
Hi Yoshinari, > I sometimes need to export an org document into both HTML and LaTeX. > In such case, I want HTML exporter to create numbered captions for > figures and tables. I think many would appreciate that feature. > So, I've written a small patch to add figure/table numbers to HTML > captions. (see 0001-Add-figure-table-numbers-to-HTML-captions.patch) That's cool! I'm not an expert on html, but how easy it is to enable/disable/alter your solution locally compared to a html5/css solution? E.g. as here: http://tympanus.net/codrops/2013/05/02/automatic-figure-numbering-with-css-counters/ Note, I don't know if this can be used for tables, or only figures, but being able to change the style in css seems nice. > This is my first post to this list. > Please teach me if we have some better way to submit the patch. Check: http://orgmode.org/worg/org-contribute.html You could use git format-patch and make sure that the commit message is a change-log entry as described on Worg (C-x 4 a on your change in the diff file should bring up the correct changelog mode). –Rasmus -- Dung makes an excellent fertilizer
[O] Add figure/table numbers to HTML captions
Hi all, I sometimes need to export an org document into both HTML and LaTeX. In such case, I want HTML exporter to create numbered captions for figures and tables. So, I've written a small patch to add figure/table numbers to HTML captions. (see 0001-Add-figure-table-numbers-to-HTML-captions.patch) I'll be very happy if this feature is merged into the master branch. This is my first post to this list. Please teach me if we have some better way to submit the patch. Thanks. -- Yoshinari Nomura https://github.com/yoshinari-nomura Example: - #+TITLE: Add figure/table numbers to HTML captions #+LATEX_CLASS: article #+LANGUAGE: en #+OPTIONS: toc:nil * 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]] * Table Test Table[[tab:phone]] shows phone numbers. Table[[tab:age]] shows age list. #+caption: Phones #+name: tab:phone | Name | Phone | Age | |---+---+-| | Peter | 1234 | 17 | | Anna | 4321 | 25 | This is a plain table (no caption, excluded from ordinal list): | No. | Letter | |-+| | 1 | A | | 2 | B | #+caption: Ages #+name: tab:age | Name | Age | Phone | |---+-+---| | Peter | 17 | 1234 | | Anna | 25 | 4321 | - >From b406e083af930644017d84144554b992cf8a788f Mon Sep 17 00:00:00 2001 From: Yoshinari Nomura Date: Thu, 27 Jun 2013 18:15:36 +0900 Subject: [PATCH] Add figure/table numbers to HTML captions --- lisp/ox-html.el | 29 ++--- lisp/ox.el | 10 -- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index a996b40..7217eab 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2534,6 +2534,15 @@ Inline images can have these attributes: (parent (org-export-get-parent-element link)) (caption (org-export-data (org-export-get-caption parent) info)) (label (org-element-property :name parent))) +(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))) + (setq caption + (concat + (format (org-html--translate "Figure %d:" info) number) + " " caption ;; Return proper string, depending on DISPOSITION. (org-html-format-inline-image path info caption label @@ -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 (setq desc (when number (if (atom number) (number-to-string number) (mapconcat 'number-to-string number ".") @@ -3145,6 +3163,9 @@ contextual information." (t (let* ((label (org-element-property :name table)) (caption (org-export-get-caption table)) + (number (org-export-get-ordinal + table info nil + (lambda (tbl info) (org-element-property :caption tbl (attributes (if (org-html-html5-p info) "" (org-html--make-attribute-string @@ -3183,7 +3204,9 @@ contextual information." (format (if org-html-table-caption-above "%s" "%s") - (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) diff --git a/lisp/ox.el b/lisp/ox.el index fb56da4..1133f21 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5265,7 +5265,12 @@ them."