From: Suhail Shergill <suhailshergill@gmail.com>
To: Org mode <emacs-orgmode@gnu.org>
Subject: Re: org-html: subtree specific footnote references
Date: Sat, 07 Jul 2012 20:16:56 +0000 [thread overview]
Message-ID: <87zk7b72dj.fsf@chaos.shergill.su> (raw)
In-Reply-To: <87txxjuysd.fsf@chaos.shergill.su> (Suhail Shergill's message of "Sat, 07 Jul 2012 20:00:34 +0000")
[-- Attachment #1: Type: text/plain, Size: 56 bytes --]
oops. attached the wrong patch. amended patch follows.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2128 bytes --]
From b9192f5e9a3bbe9620d9f588313d7f62e33135a5 Mon Sep 17 00:00:00 2001
From: Suhail Shergill <suhailshergill@gmail.com>
Date: Sun, 8 Apr 2012 10:49:51 -0400
Subject: [PATCH] org-html.el: Make footnotes unique to an entry
* lisp/org-html.el (org-export-as-html): Assign unique ids to footnotes
if possible
If the entry (or its ancestor) has the CUSTOM_ID property defined, then
use that as part of the generated footnote references and definitions.
---
lisp/org-html.el | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lisp/org-html.el b/lisp/org-html.el
index c9c9d78..b9123a1 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1248,6 +1248,9 @@ PUB-DIR is set, use this as the publishing directory."
(org-export-have-math nil)
(org-export-footnotes-seen nil)
(org-export-footnotes-data (org-footnote-all-labels 'with-defs))
+ (custom-id (or (org-entry-get nil "CUSTOM_ID" t) ""))
+ (footnote-def-prefix (format "fn-%s" custom-id))
+ (footnote-ref-prefix (format "fnr-%s" custom-id))
(lines
(org-split-string
(org-export-preprocess-string
@@ -1685,7 +1688,7 @@ PUB-DIR is set, use this as the publishing directory."
(format
(concat "%s"
(format org-export-html-footnote-format
- (concat "<a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a>")))
+ (concat "<a class=\"footref\" name=\"" footnote-ref-prefix ".%s%s\" href=\"#" footnote-def-prefix ".%s\">%s</a>")))
(or (match-string 1 org-line) "") n extra n n)
;; If another footnote is following the
;; current one, add a separator.
@@ -1773,7 +1776,8 @@ PUB-DIR is set, use this as the publishing directory."
(format
(concat "<p class=\"footnote\">"
(format org-export-html-footnote-format
- "<a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a>"))
+ (concat
+ "<a class=\"footnum\" name=\"" footnote-def-prefix ".%s\" href=\"#" footnote-ref-prefix ".%s\">%s</a>")))
n n n) t t org-line)))))
;; Check if the line break needs to be conserved
(cond
--
1.7.10
[-- Attachment #3: Type: text/plain, Size: 2883 bytes --]
Suhail Shergill <suhailshergill@gmail.com> writes:
> running org-export-as-html on a subtree is currently problematic if the result
> is to be merged into a document which contains html-ized versions of other
> subtrees: the footnote references and definitions get clobbered.
>
> this patch uses the CUSTOM_ID property of the subtree to generate unique
> footnote references and definitions. if the subtree does not have the CUSTOM_ID
> property set the result is a nop.
>
>
> From 27f89f8bfff334810aba5c33af621e351fa0be79 Mon Sep 17 00:00:00 2001
> From: Suhail Shergill <suhailshergill@gmail.com>
> Date: Sun, 8 Apr 2012 10:49:51 -0400
> Subject: [PATCH] org-html.el: Make footnotes unique to an entry
>
> * lisp/org-html.el (org-export-as-html): Assign unique ids to footnotes
> if possible
>
> If the entry (or its ancestor) has the CUSTOM_ID property defined, then
> use that as part of the generated footnote references and definitions.
> ---
> lisp/org-html.el | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/lisp/org-html.el b/lisp/org-html.el
> index c9c9d78..8b79c39 100644
> --- a/lisp/org-html.el
> +++ b/lisp/org-html.el
> @@ -1248,6 +1248,9 @@ PUB-DIR is set, use this as the publishing directory."
> (org-export-have-math nil)
> (org-export-footnotes-seen nil)
> (org-export-footnotes-data (org-footnote-all-labels 'with-defs))
> + (custom-id (or (org-entry-get nil "CUSTOM_ID" t) ""))
> + (footnote-def-prefix (format "fn-%s" custom-id))
> + (footnote-ref-prefix (format "fnr-%s" custom-id))
> (lines
> (org-split-string
> (org-export-preprocess-string
> @@ -1685,8 +1688,8 @@ PUB-DIR is set, use this as the publishing directory."
> (format
> (concat "%s"
> (format org-export-html-footnote-format
> - (concat "<a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a>")))
> - (or (match-string 1 org-line) "") n extra n n)
> + (concat "<a class=\"footref\" name=\"" footnote-ref-prefix ".%s%s\" href=\"#" footnote-def-prefix ".%s\">%s</a>")))
> + (or (match-string 1 line) "") n extra n n)
> ;; If another footnote is following the
> ;; current one, add a separator.
> (if (save-match-data
> @@ -1773,8 +1776,9 @@ PUB-DIR is set, use this as the publishing directory."
> (format
> (concat "<p class=\"footnote\">"
> (format org-export-html-footnote-format
> - "<a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a>"))
> - n n n) t t org-line)))))
> + (concat
> + "<a class=\"footnum\" name=\"" footnote-def-prefix ".%s\" href=\"#" footnote-ref-prefix ".%s\">%s</a>")))
> + n n n) t t line)))))
> ;; Check if the line break needs to be conserved
> (cond
> ((string-match "\\\\\\\\[ \t]*$" org-line)
> --
> 1.7.10
--
Suhail
next prev parent reply other threads:[~2012-07-07 20:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-07 20:00 org-html: subtree specific footnote references Suhail Shergill
2012-07-07 20:16 ` Suhail Shergill [this message]
2012-07-10 3:48 ` Jambunathan K
2012-07-10 4:18 ` Suhail Shergill
2012-07-10 4:38 ` Jambunathan K
2012-07-10 5:03 ` Suhail Shergill
2012-07-10 5:20 ` Jambunathan K
2012-07-10 5:54 ` Jambunathan K
2012-07-16 17:31 ` Suhail Shergill
2012-08-02 16:26 ` Bastien
2012-08-04 0:17 ` Suhail Shergill
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=87zk7b72dj.fsf@chaos.shergill.su \
--to=suhailshergill@gmail.com \
--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).