emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Joost Helberg <joost@snow.nl>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] ox-html.el ox.el: added list of figures support in html backend
Date: Mon, 09 Nov 2015 11:46:49 +0100	[thread overview]
Message-ID: <87611btppi.fsf@snow.nl> (raw)

[-- 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.

             reply	other threads:[~2015-11-09 10:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09 10:46 Joost Helberg [this message]
2015-11-12 22:46 ` [PATCH] ox-html.el ox.el: added list of figures support in html backend 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=87611btppi.fsf@snow.nl \
    --to=joost@snow.nl \
    --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).