emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Andreas Leha <andreas.leha@med.uni-goettingen.de>
Cc: emacs-orgmode@gnu.org, Eric Schulte <schulte.eric@gmail.com>
Subject: Re: [BUG] inline source breaks paragraphs
Date: Fri, 13 Dec 2013 21:47:25 +0100	[thread overview]
Message-ID: <877gb87a1u.fsf@gmail.com> (raw)
In-Reply-To: <87mwkb7ziz.fsf@med.uni-goettingen.de> (Andreas Leha's message of "Sun, 08 Dec 2013 23:23:32 +0100")

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

Hello,

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> inline source -- when on its own line -- breaks the paragraph, which is
> unexpected.
>
> Here is a test file:
>
> * Test
>
> This is a broken
> src_R[:exports results :results raw]{10}
> paragraph.
>
>
> Here is (the relevant part of) the output of the LaTeX export:
>
> ,----
> | \section{Test}
> | \label{sec-1}
> | 
> | This is a broken
> | 10
> | 
> | paragraph.
> `----

The attached patch solves the problem. It may be a bit intrusive,
though.

Eric, what do you think?


Regards,

-- 
Nicolas Goaziou

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-core-Preserve-paragraph-when-evaluating-inline-bl.patch --]
[-- Type: text/x-diff, Size: 1461 bytes --]

From 8ec02a2fa79b8601565ca7b226b8c1e4790f3439 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Fri, 13 Dec 2013 21:40:33 +0100
Subject: [PATCH] ob-core: Preserve paragraph when evaluating inline blocks

* lisp/ob-core.el (org-babel-insert-result): Trim whitespaces around
  results from inline source blocks.
---
 lisp/ob-core.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 84caed7..a6945e4 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2048,12 +2048,14 @@ code ---- the results are extracted in the syntax of the source
 				   (or (> visible-beg existing-result)
 				       (<= visible-end existing-result))))
 	     beg end)
-	(when (and (stringp result)  ; ensure results end in a newline
-		   (not inlinep)
-		   (> (length result) 0)
-		   (not (or (string-equal (substring result -1) "\n")
-			    (string-equal (substring result -1) "\r"))))
-	  (setq result (concat result "\n")))
+	;; Ensure inline results never end with a newline, but regular
+	;; results always do.
+	(cond ((not (stringp result)))
+	      (inlinep (setq result (org-babel-trim result)))
+	      ((and (> (length result) 0)
+		    (not (or (string-equal (substring result -1) "\n")
+			     (string-equal (substring result -1) "\r"))))
+	       (setq result (concat result "\n"))))
 	(unwind-protect
 	    (progn
 	      (when outside-scope-p (widen))
-- 
1.8.5.1


  parent reply	other threads:[~2013-12-13 20:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-08 22:23 [BUG] inline source breaks paragraphs Andreas Leha
2013-12-08 22:25 ` Andreas Leha
2013-12-13 20:47 ` Nicolas Goaziou [this message]
2013-12-13 23:30   ` Eric Schulte
2013-12-14 11:27     ` Nicolas Goaziou
2013-12-14 11:53     ` Andreas Leha

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=877gb87a1u.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=andreas.leha@med.uni-goettingen.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=schulte.eric@gmail.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).