From b7be665ef3bb935a0532fb299ce17653e3eb21f4 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Sun, 8 Jul 2012 00:50:47 +0530 Subject: [PATCH] org-e-html.el: Introduced `org-e-html-allow-name-attribute-in-anchors' Apparently helps with creating epub formats. See http://lists.gnu.org/archive/html/emacs-orgmode/2011-12/msg00391.html --- contrib/lisp/org-e-html.el | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/contrib/lisp/org-e-html.el b/contrib/lisp/org-e-html.el index 360f8198c..d2d88c604 100644 --- a/contrib/lisp/org-e-html.el +++ b/contrib/lisp/org-e-html.el @@ -195,6 +195,14 @@ Intended to be locally bound around a call to `org-export-as-html'." ) :group 'org-export-e-html :type 'boolean) +;;;; HTML-specific + +(defcustom org-e-html-allow-name-attribute-in-anchors t + "When nil, do not set \"name\" attribute in anchors. +By default, anchors are formatted with both \"id\" and \"name\" +attributes, when appropriate." + :group 'org-export-e-html + :type 'boolean) ;;;; Document @@ -1379,9 +1387,10 @@ Replaces invalid characters with \"_\"." (defun org-e-html-format-footnote-reference (n def refcnt) (let ((extra (if (= refcnt 1) "" (format ".%d" refcnt)))) (format org-e-html-footnote-format - (format - "%s" - n extra n n)))) + (let* ((id (format "fnr.%s%s" n extra)) + (href (format " href=\"#fn.%s\"" n)) + (attributes (concat " class=\"footref\"" href))) + (org-e-html--anchor id n attributes))))) (defun org-e-html-format-footnotes-section (section-name definitions) (if (not definitions) "" @@ -1391,10 +1400,12 @@ Replaces invalid characters with \"_\"." (let ((n (car fn)) (def (cdr fn))) (format "\n%s\n%s\n\n" - (format - (format org-e-html-footnote-format - "%s") - n n n) def))) + (format org-e-html-footnote-format + (let* ((id (format "fn.%s" n)) + (href (format " href=\"#fnr.%s\"" n)) + (attributes (concat " class=\"footnum\"" href))) + (org-e-html--anchor id n attributes))) + def))) (defun org-e-html-footnote-section (info) (let* ((fn-alist (org-export-collect-footnote-definitions @@ -1621,7 +1632,7 @@ This function shouldn't be used for floats. See (concat (when (plist-get info :time-stamp-file) (format " -

%s: %s

" (nth 2 lang-words) date)) +

%s: %s

" (nth 2 lang-words) date)) (when (and (plist-get info :with-author) author) (format "

%s : %s

" (nth 1 lang-words) author)) @@ -1734,6 +1745,15 @@ original parsed data. INFO is a plist holding export options." ;;; Transcode Helpers +;;;; Anchor + +(defun org-e-html--anchor (&optional id desc attributes) + (let* ((name (and org-e-html-allow-name-attribute-in-anchors id)) + (attributes (concat (and id (format " id=\"%s\"" id)) + (and name (format " name=\"%s\"" name)) + attributes))) + (format "%s" attributes (or desc "")))) + ;;;; Todo (defun org-e-html--todo (todo) @@ -2157,7 +2177,7 @@ holding contextual information." (let ((id (org-solidify-link-text (if (org-uuidgen-p x) (concat "ID-" x) x)))) - (format "" id id))) + (org-e-html--anchor id))) extra-ids "") full-text level1) @@ -2837,7 +2857,7 @@ TEXT is the text of the target. INFO is a plist holding contextual information." (let ((id (org-export-solidify-link-text (org-element-property :value radio-target)))) - (format "%s" id id text))) + (org-e-html--anchor id text))) ;;;; Special Block @@ -3077,7 +3097,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (let ((id (org-export-solidify-link-text (org-element-property :value target)))) - (format "" id id))) + (org-e-html--anchor id))) ;;;; Timestamp -- 2.11.4.GIT