all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] ox-html.el ox.el: added list of figures support in html backend
@ 2015-11-09 10:46 Joost Helberg
  2015-11-12 22:46 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Joost Helberg @ 2015-11-09 10:46 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

Hi,

this patch adds the list of figures to the html export backend. It also
includes a translation entry-point for the label "List of Figures" with
already one translation in: dutch.


[-- Attachment #2: 0001-ox-html.el-added-list-of-figures-support-in-html-bac.patch --]
[-- Type: text/x-diff, Size: 3305 bytes --]

From fab9105d04e5cb9f923c17d322d84a25527ec27a Mon Sep 17 00:00:00 2001
From: Joost Helberg <joost@snow.nl>
Date: Sun, 8 Nov 2015 14:34:11 +0100
Subject: [PATCH] ox-html.el: added list of figures support in html backend

* lisp/ox-html.el (org-html-list-of-figures): new, similar to
org-html-list-of-tables but with tables replaced by figures.
(org-html-list-of-tables): added mapping keyword "figures"
to new function org-html-list-of-figures.

ox.el: added label for "list of figures"

* lisp/ox.el (org-export-dictionary): Added label for List of
Figures with dutch translation
---
 lisp/ox-html.el | 36 ++++++++++++++++++++++++++++++++++++
 lisp/ox.el      |  2 ++
 2 files changed, 38 insertions(+)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index effd387..3a7d7a1 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2251,6 +2251,41 @@ of listings as a string, or nil if it is empty."
 		 lol-entries "\n"))
 	      "\n</ul>\n</div>\n</div>"))))
 
+(defun org-html-list-of-figures (info)
+  "Build a list of figures.
+INFO is a plist used as a communication channel.  Return the list
+of figures as a string, or nil if it is empty."
+  (let ((lol-entries (org-export-collect-figures info nil)))
+    (when lol-entries
+      (concat "<div id=\"list-of-tables\">\n"
+	      (format "<h%d>%s</h%d>\n"
+		      org-html-toplevel-hlevel
+		      (org-html--translate "List of Figures" info)
+		      org-html-toplevel-hlevel)
+	      "<div id=\"text-list-of-figures\">\n<ul>\n"
+	      (let ((count 0)
+		    (initial-fmt (format "<span class=\"figure-number\">%s</span>"
+					 (org-html--translate "Figure %d:" info))))
+		(mapconcat
+		 (lambda (entry)
+		   (let ((label (org-element-property :name entry))
+			 (title (org-trim
+				 (org-export-data
+				  (or (org-export-get-caption entry t)
+				      (org-export-get-caption entry))
+				  info))))
+		     (concat
+		      "<li>"
+		      (if (not label)
+			  (concat (format initial-fmt (incf count)) " " title)
+			(format "<a href=\"#%s\">%s %s</a>"
+				(org-export-solidify-link-text label)
+				(format initial-fmt (incf count))
+				title))
+		      "</li>")))
+		 lol-entries "\n"))
+	      "\n</ul>\n</div>\n</div>"))))
+
 (defun org-html-list-of-tables (info)
   "Build a list of tables.
 INFO is a plist used as a communication channel.  Return the list
@@ -2654,6 +2689,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 		(localp (org-string-match-p "\\<local\\>" value)))
 	    (org-html-toc depth info (and localp keyword))))
 	 ((string= "listings" value) (org-html-list-of-listings info))
+	 ((string= "figures" value) (org-html-list-of-figures info))
 	 ((string= "tables" value) (org-html-list-of-tables info))))))))
 
 ;;;; Latex Environment
diff --git a/lisp/ox.el b/lisp/ox.el
index a37de04..f00469f 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -5561,6 +5561,8 @@ them."
       :utf-8 "Примітки")
      ("zh-CN" :html "&#33050;&#27880;" :utf-8 "脚注")
      ("zh-TW" :html "&#33139;&#35387;" :utf-8 "腳註"))
+    ("List of Figures"
+     ("nl" :default "Figuren"))
     ("List of Listings"
      ("da" :default "Programmer")
      ("de" :default "Programmauflistungsverzeichnis")
-- 
1.9.1


[-- Attachment #3: Type: text/plain, Size: 32 bytes --]


regards,

Joost

-- 
Snow B.V.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ox-html.el ox.el: added list of figures support in html backend
  2015-11-09 10:46 [PATCH] ox-html.el ox.el: added list of figures support in html backend Joost Helberg
@ 2015-11-12 22:46 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2015-11-12 22:46 UTC (permalink / raw)
  To: Joost Helberg; +Cc: emacs-orgmode

Hello,

Joost Helberg <joost@snow.nl> writes:

> this patch adds the list of figures to the html export backend. It also
> includes a translation entry-point for the label "List of Figures" with
> already one translation in: dutch.

Thank you.

> From fab9105d04e5cb9f923c17d322d84a25527ec27a Mon Sep 17 00:00:00 2001
> From: Joost Helberg <joost@snow.nl>
> Date: Sun, 8 Nov 2015 14:34:11 +0100
> Subject: [PATCH] ox-html.el: added list of figures support in html
> backend

It should be

  ox-html: Add list of figures

> * lisp/ox-html.el (org-html-list-of-figures): new, similar to
> org-html-list-of-tables but with tables replaced by figures.

This is, indeed, almost the same as `org-html-list-of-tables' and
`org-html-list-of-listings'. I suggest to refactor the 3 functions to
use a generic one.

Also please use a recent version of `org-html-list-of-tables' since
yours contain deprecated code (e.g., `org-export-solidify-link-text').

> (org-html-list-of-tables): added mapping keyword "figures"
> to new function org-html-list-of-figures.

You can remove this.

> ox.el: added label for "list of figures"

Ditto.

> * lisp/ox.el (org-export-dictionary): Added label for List of
> Figures with dutch translation

You need to add TINYCHANGE at the end of the commit message, if you
haven't signed FSF papers yet.

> +(defun org-html-list-of-figures (info)
> +  "Build a list of figures.
> +INFO is a plist used as a communication channel.  Return the list
> +of figures as a string, or nil if it is empty."
> +  (let ((lol-entries (org-export-collect-figures info nil)))

  (org-export-collect-figures info nil)

is rather sloppy. It collects all paragraphs with a caption. Is it
a proper definition for "figures"?


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-12 22:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-09 10:46 [PATCH] ox-html.el ox.el: added list of figures support in html backend Joost Helberg
2015-11-12 22:46 ` Nicolas Goaziou

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.