emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Bastien <bzg@altern.org>
Cc: Emacs-orgmode@gnu.org, Christian Moe <mail@christianmoe.com>
Subject: Re: [BUG] [ODT] Annotations break paragraphs
Date: Mon, 25 Mar 2013 23:15:25 +0100	[thread overview]
Message-ID: <87ip4fxh1e.fsf@gmail.com> (raw)
In-Reply-To: <87r4j35ejb.fsf@bzg.ath.cx> (Bastien's message of "Mon, 25 Mar 2013 22:56:56 +0100")

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

Hello,

Bastien <bzg@altern.org> 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_<lang>{...} 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix annotate blocks --]
[-- Type: text/x-patch, Size: 3855 bytes --]

From 502e29c49a1d95eb853550f157567ffc328403c6 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
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<text:p text:style-name=\"%s\">%s</text:p>" 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 "<text:p text:style-name=\"%s\">" 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"))))
+       "</text:p>"))))
 
 
 ;;;; 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<text:p>%s</text:p>"
-		(format "<office:annotation>\n%s\n</office:annotation>"
-			(concat
-			 (and author
-			      (format "<dc:creator>%s</dc:creator>" author))
-			 (and date
-			      (format "<dc:date>%s</dc:date>"
-				      (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))))
+	     "<text:p text:style-name=\"Text_20_body\">"))
+	 (format "<office:annotation>\n%s\n</office:annotation>"
+		 (concat
+		  (and author
+		       (format "<dc:creator>%s</dc:creator>" author))
+		  (and date
+		       (format "<dc:date>%s</dc:date>"
+			       (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))
+	   "</text:p>"))))
      ;; Textbox.
      ((string= type "textbox")
       (let ((width (plist-get attributes :width))
-- 
1.8.2


  reply	other threads:[~2013-03-25 22:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-21 21:18 [BUG] [ODT] Annotations break paragraphs Christian Moe
2013-03-25  5:59 ` Samuel Wales
2013-03-25 10:29   ` Christian Moe
2013-03-25 10:40     ` Achim Gratz
2013-03-25 15:12 ` Bastien
2013-03-25 16:12   ` Christian Moe
2013-03-25 16:17     ` Bastien
2013-03-25 16:27     ` Achim Gratz
2013-03-25 17:39       ` Christian Moe
2013-03-25 18:54         ` Bastien
2013-03-25 20:26           ` Christian Moe
2013-03-25 17:05     ` Bastien
2013-03-25 17:13       ` Achim Gratz
2013-03-25 20:10         ` Nicolas Goaziou
2013-03-25 21:12           ` Christian Moe
2013-03-25 20:00       ` Christian Moe
2013-03-25 21:56         ` Bastien
2013-03-25 22:15           ` Nicolas Goaziou [this message]
2013-03-26  6:28             ` Achim Gratz
2013-03-27 15:48               ` Nicolas Goaziou
2013-03-28  6:24                 ` Achim Gratz
2013-03-28 14:41                   ` Nicolas Goaziou
2013-03-28 19:12                     ` Achim Gratz
2013-03-28 20:58                     ` Christian Moe
2013-03-28 23:04                       ` Christian Moe
2013-03-26  9:38             ` Christian Moe
2013-03-27 22:33               ` Nicolas Goaziou
2013-03-28  8:40                 ` Christian Moe
2013-03-28  9:46                   ` Christian Moe
2013-03-25 22:36           ` 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=87ip4fxh1e.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=Emacs-orgmode@gnu.org \
    --cc=bzg@altern.org \
    --cc=mail@christianmoe.com \
    /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).