From 502e29c49a1d95eb853550f157567ffc328403c6 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 25 Mar 2013 23:07:04 +0100 Subject: [PATCH] ox-odt: Properly handle ANNOTATE special blocks * lisp/ox-odt.el (org-odt-paragraph, org-odt-special-block): Properly handle ANNOTATE special blocks associated to paragraphs. --- lisp/ox-odt.el | 59 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 9dd8946..5896d52 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -2888,10 +2888,29 @@ the plist used as a communication channel." ;; 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))) + (concat + ;; Open paragraph, unless it is preceded by an annotation with no + ;; blank line at its end. + (unless (let ((prev (org-export-get-previous-element paragraph info))) + (and (eq (org-element-type prev) 'special-block) + (equal (org-element-property :type prev) "ANNOTATION") + (let ((blank (org-element-property :post-blank prev))) + (or (not blank) (zerop blank))))) + (format "" style)) + ;; Paragraph's contents. + contents + ;; Close paragraph, unless it is followed by an annotation with + ;; no blank line in-between. + (unless (and (let ((blank (org-element-property :post-blank paragraph))) + (or (not blank) (zerop blank))) + (let ((next (org-export-get-next-element paragraph info))) + (and (eq (org-element-type next) 'special-block) + (equal (org-element-property :type next) + "ANNOTATION")))) + "")))) ;;;; Plain List @@ -3066,15 +3085,33 @@ holding contextual information." (date (or (plist-get attributes :date) ;; FIXME: Is `car' right thing to do below? (car (plist-get info :date))))) - (format "\n%s" - (format "\n%s\n" - (concat - (and author - (format "%s" author)) - (and date - (format "%s" - (org-odt--format-timestamp date nil 'iso-date))) - contents))))) + (concat + ;; Annotation starts a paragraph when there's no paragraph + ;; before it or the paragraph before ends with some blank + ;; lines. In that case, start a new paragraph. + (let ((prev (org-export-get-previous-element special-block info))) + (unless (and (eq (org-element-type prev) 'paragraph) + (let ((blank (org-element-property :post-blank prev))) + (or (not blank) (zerop blank)))) + "")) + (format "\n%s\n" + (concat + (and author + (format "%s" author)) + (and date + (format "%s" + (org-odt--format-timestamp date nil 'iso-date))) + contents)) + ;; Annotation ends a paragraph when it ends with blank lines + ;; or when no paragraph follows it. In that case, end + ;; current paragraph. + (unless (and (let ((blanks (org-element-property + :post-blank special-block))) + (or (not blanks) (zerop blanks))) + (eq (org-element-type + (org-export-get-next-element special-block info)) + 'paragraph)) + "")))) ;; Textbox. ((string= type "textbox") (let ((width (plist-get attributes :width)) -- 1.8.2