From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Christian Moe <christian.moe@hf.uio.no>
Cc: Emacs-orgmode@gnu.org
Subject: Re: [BUG] [ODT] Subtree export gives wrong footnote style
Date: Fri, 29 Mar 2013 23:15:04 +0100 [thread overview]
Message-ID: <87y5d5vonr.fsf@gmail.com> (raw)
In-Reply-To: <m2sj3ez3p9.fsf@christianmoe.com> (Christian Moe's message of "Fri, 29 Mar 2013 15:22:02 +0100")
[-- Attachment #1: Type: text/plain, Size: 473 bytes --]
Hello,
Christian Moe <christian.moe@hf.uio.no> writes:
> Maybe I'm being obtuse, but I don't understand the relevance of your
> question to the bug I pointed out. My example had two simple footnotes,
> neither of which contained any blocks.
I understood your problem, but I needed to know how deep I had to change
paragraph styles.
Would you mind testing the following patch? I added two new styles. Feel
free to correct them if needed.
Regards,
--
Nicolas Goaziou
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: footnotes outside scope --]
[-- Type: text/x-patch, Size: 5859 bytes --]
From efd1d46bc3c92e8821cf6156eaf6910444381e02 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Fri, 29 Mar 2013 23:09:11 +0100
Subject: [PATCH] ox-odt: Fix export of footnotes outside subtree during
subtree export
* etc/styles/OrgOdtStyles.xml: Define "OrgFootnoteCenter" and
"OrgFootnoteQuotations" styles.
* lisp/ox-odt.el (org-odt--format-paragraph): New function.
(org-odt-paragraph): Use new function to limit code duplication.
(org-odt-footnote-reference): Change default style for paragraphs when
transcoding a footnote definition.
---
etc/styles/OrgOdtStyles.xml | 6 ++++++
lisp/ox-odt.el | 46 +++++++++++++++++++++++++++++++--------------
2 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/etc/styles/OrgOdtStyles.xml b/etc/styles/OrgOdtStyles.xml
index 26d05f1..f41d984 100644
--- a/etc/styles/OrgOdtStyles.xml
+++ b/etc/styles/OrgOdtStyles.xml
@@ -256,6 +256,9 @@
<style:style style:name="Quotations" style:family="paragraph" style:parent-style-name="Standard" style:class="html">
<style:paragraph-properties fo:margin-left="1cm" fo:margin-right="1cm" fo:margin-top="0cm" fo:margin-bottom="0.499cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
</style:style>
+ <style:style style:name="OrgFootnoteQuotations" style:family="paragraph" style:parent-style-name="Footnote" style:class="html">
+ <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="1cm" fo:margin-top="0cm" fo:margin-bottom="0.499cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
+ </style:style>
<style:style style:name="Preformatted_20_Text" style:display-name="Preformatted Text" style:family="paragraph" style:parent-style-name="Standard" style:class="html">
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
<style:text-properties style:font-name="Courier New" fo:font-size="10pt" style:font-name-asian="NSimSun" style:font-size-asian="10pt" style:font-name-complex="Courier New" style:font-size-complex="10pt"/>
@@ -298,6 +301,9 @@
<style:style style:name="OrgCenter" style:family="paragraph" style:parent-style-name="Text_20_body">
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
</style:style>
+ <style:style style:name="OrgFootnoteCenter" style:family="paragraph" style:parent-style-name="Footnote">
+ <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+ </style:style>
<style:style style:name="OrgTableContents" style:family="paragraph" style:parent-style-name="Text_20_body"/>
<style:style style:name="OrgTableHeading" style:family="paragraph" style:parent-style-name="OrgTableContents" style:class="extra">
<style:paragraph-properties fo:text-align="center" style:justify-single-word="false" text:number-lines="false" text:line-number="0"/>
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 9dd8946..250aa33 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -1750,9 +1750,17 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;; Inline definitions are secondary strings.
;; Non-inline footnotes definitions are full Org data.
(t
- (let* ((raw (org-export-get-footnote-definition footnote-reference
- info))
- (def (let ((def (org-trim (org-export-data raw info))))
+ (let* ((raw (org-export-get-footnote-definition
+ footnote-reference info))
+ (translations
+ (cons (cons 'paragraph
+ (lambda (p c i)
+ (org-odt--format-paragraph
+ p c "Footnote" "OrgFootnoteCenter"
+ "OrgFootnoteQuotations")))
+ (org-export-backend-translate-table 'odt)))
+ (def (let ((def (org-trim (org-export-data-with-translations
+ raw translations info))))
(if (eq (org-element-type raw) 'org-data) def
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
"Footnote" def)))))
@@ -2872,27 +2880,37 @@ INFO is a plist holding contextual information. See
;;;; Paragraph
-(defun org-odt-paragraph (paragraph contents info)
- "Transcode a PARAGRAPH element from Org to ODT.
-CONTENTS is the contents of the paragraph, as a string. INFO is
-the plist used as a communication channel."
+(defun org-odt--format-paragraph (paragraph contents default center quote)
+ "Format paragraph according to given styles.
+PARAGRAPH is a paragraph type element. CONTENTS is the
+transcoded contents of that paragraph, as a string. DEFAULT,
+CENTER and QUOTE are, respectively, style to use when paragraph
+belongs to no special environment, a center block, or a quote
+block."
(let* ((parent (org-export-get-parent paragraph))
(parent-type (org-element-type parent))
(style (case parent-type
- (quote-block "Quotations")
- (center-block "OrgCenter")
- (footnote-definition "Footnote")
- (t (or (org-element-property :style paragraph)
- "Text_20_body")))))
+ (quote-block quote)
+ (center-block center)
+ (t default))))
;; If this paragraph is a leading paragraph in an item and the
;; item has a checkbox, splice the checkbox and paragraph contents
;; together.
(when (and (eq (org-element-type parent) 'item)
- (eq paragraph (car (org-element-contents parent))))
+ (eq paragraph (car (org-element-contents parent))))
(setq contents (concat (org-odt--checkbox parent) contents)))
- (assert style)
(format "\n<text:p text:style-name=\"%s\">%s</text:p>" style contents)))
+(defun org-odt-paragraph (paragraph contents info)
+ "Transcode a PARAGRAPH element from Org to ODT.
+CONTENTS is the contents of the paragraph, as a string. INFO is
+the plist used as a communication channel."
+ (org-odt--format-paragraph
+ paragraph contents
+ (or (org-element-property :style paragraph) "Text_20_body")
+ "OrgCenter"
+ "Quotations"))
+
;;;; Plain List
--
1.8.2
next prev parent reply other threads:[~2013-03-29 22:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-28 12:05 [BUG] [ODT] Subtree export gives wrong footnote style Christian Moe
2013-03-29 12:51 ` Nicolas Goaziou
2013-03-29 14:22 ` Christian Moe
2013-03-29 22:15 ` Nicolas Goaziou [this message]
2013-03-30 8:11 ` Christian Moe
2013-04-01 8:02 ` Nicolas Goaziou
2013-04-01 12:02 ` Christian Moe
2013-04-01 15:35 ` Nicolas Goaziou
2013-04-01 18:37 ` Christian Moe
2013-04-01 22:09 ` Nicolas Goaziou
2013-04-02 7:09 ` Christian Moe
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=87y5d5vonr.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=Emacs-orgmode@gnu.org \
--cc=christian.moe@hf.uio.no \
/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).