From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [BUG] [ODT] Subtree export gives wrong footnote style Date: Fri, 29 Mar 2013 23:15:04 +0100 Message-ID: <87y5d5vonr.fsf@gmail.com> References: <87zjxmweqf.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:40246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULhZp-0004Kg-FV for Emacs-orgmode@gnu.org; Fri, 29 Mar 2013 18:15:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULhZn-0006hT-SX for Emacs-orgmode@gnu.org; Fri, 29 Mar 2013 18:15:13 -0400 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:53781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULhZn-0006gw-J1 for Emacs-orgmode@gnu.org; Fri, 29 Mar 2013 18:15:11 -0400 Received: by mail-wi0-f182.google.com with SMTP id hi18so232479wib.9 for ; Fri, 29 Mar 2013 15:15:10 -0700 (PDT) In-Reply-To: (Christian Moe's message of "Fri, 29 Mar 2013 15:22:02 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Christian Moe Cc: Emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hello, Christian Moe 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-odt-Fix-export-of-footnotes-outside-subtree-durin.patch Content-Description: footnotes outside scope >From efd1d46bc3c92e8821cf6156eaf6910444381e02 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou 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 @@ + + + @@ -298,6 +301,9 @@ + + + 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%s" "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%s" 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 --=-=-=--