From 776972cfe83ef79fd76dee79398351797f8cf9ff Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 24 Jul 2014 14:48:47 +0200 Subject: [PATCH] ox-odt: Fix handling of quoted and centered paragraphs * lisp/ox-odt.el (org-odt--paragraph-style): New function. (org-odt--format-paragraph): Use new function to get proper style to apply. Thanks to Baptiste for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/88798 --- lisp/ox-odt.el | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 772017cdd..e390c3497 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -2832,6 +2832,17 @@ INFO is a plist holding contextual information. See ;;;; Paragraph +(defun org-odt--paragraph-style (paragraph) + "Return style of PARAGRAPH. +Style is a symbol among `quoted', `centered' and nil." + (let ((up paragraph)) + (while (and (setq up (org-element-property :parent up)) + (not (memq (org-element-type up) + '(center-block quote-block section))))) + (case (org-element-type up) + (center-block 'centered) + (quote-block 'quoted)))) + (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 @@ -2839,19 +2850,19 @@ 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 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)))) - (setq contents (concat (org-odt--checkbox parent) contents))) - (format "\n%s" style contents))) + (format "\n%s" + (case (org-odt--paragraph-style paragraph) + (quoted quote) + (centered center) + (otherwise default)) + ;; If PARAGRAPH is a leading paragraph in an item that has + ;; a checkbox, splice checkbox and paragraph contents + ;; together. + (concat (let ((parent (org-element-property :parent paragraph))) + (and (eq (org-element-type parent) 'item) + (not (org-export-get-previous-element paragraph info)) + (org-odt--checkbox parent))) + contents))) (defun org-odt-paragraph (paragraph contents info) "Transcode a PARAGRAPH element from Org to ODT. -- 2.11.4.GIT