From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [BUG] [ODT] Annotations break paragraphs Date: Mon, 25 Mar 2013 23:15:25 +0100 Message-ID: <87ip4fxh1e.fsf@gmail.com> References: <871ub3o6mn.fsf@bzg.ath.cx> <87ip4f9zqa.fsf@bzg.ath.cx> <87r4j35ejb.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:45396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKFg0-0005fN-L5 for Emacs-orgmode@gnu.org; Mon, 25 Mar 2013 18:15:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKFfz-0003FG-23 for Emacs-orgmode@gnu.org; Mon, 25 Mar 2013 18:15:36 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:64815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKFfy-0003F5-Ml for Emacs-orgmode@gnu.org; Mon, 25 Mar 2013 18:15:34 -0400 Received: by mail-wi0-f171.google.com with SMTP id hn17so10784551wib.10 for ; Mon, 25 Mar 2013 15:15:33 -0700 (PDT) In-Reply-To: <87r4j35ejb.fsf@bzg.ath.cx> (Bastien's message of "Mon, 25 Mar 2013 22:56:56 +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: Bastien Cc: Emacs-orgmode@gnu.org, Christian Moe --=-=-= Content-Type: text/plain Hello, Bastien writes: > okay, I reverted my wrong fixes. I'll let Nicolas have a look. I attach a patch (hardly tested) for that. Does it work as expected? > I would not favor a solution that allows more #+begin_ blocks to > be inlined. Neither would I. Blocks are containers. > The proper way to handle this is to introduce a new syntax for > inlined annotations and to treat them appropriately in exporters. > > Since we have both #+begin_src and src_{...} I'd suggest > having annotation_{...} or something similar. I would suggest [annotation:label] or [note:label] a dedicated section for contents, much like footnotes (aren't they just special footnotes, after all?). That way, they can be inlined while still being able to contain paragraphs. > The LaTeX exporter could use \marginpar{...} and the HTML back-end > could make them appear when hovering with the mouse on the annotated > parts (just an idea.) > > Maybe we will have to live with the current "regression" for 8.0 > and implement the new syntax for 8.1. Or for 8.0, if Nicolas thinks > the change is okay and not too error prone. Regards, -- Nicolas Goaziou --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-odt-Properly-handle-ANNOTATE-special-blocks.patch Content-Description: fix annotate blocks >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 --=-=-=--