From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [BUG] inline source breaks paragraphs Date: Fri, 13 Dec 2013 16:30:13 -0700 Message-ID: <87sitwcor6.fsf@gmail.com> References: <87mwkb7ziz.fsf@med.uni-goettingen.de> <877gb87a1u.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrcDO-0000J9-So for emacs-orgmode@gnu.org; Fri, 13 Dec 2013 18:32:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrcDK-00035s-Bt for emacs-orgmode@gnu.org; Fri, 13 Dec 2013 18:32:14 -0500 Received: from mail-pb0-x233.google.com ([2607:f8b0:400e:c01::233]:40675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrcDK-00035j-3s for emacs-orgmode@gnu.org; Fri, 13 Dec 2013 18:32:10 -0500 Received: by mail-pb0-f51.google.com with SMTP id up15so3183421pbc.24 for ; Fri, 13 Dec 2013 15:32:09 -0800 (PST) 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: Nicolas Goaziou Cc: Andreas Leha , emacs-orgmode@gnu.org Nicolas Goaziou writes: > Hello, > > Andreas Leha 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? > Invariably someone would then ask why the newline is being stripped from their inline code block. I think this is only necessary because the R code block is returning "10\n" instead of 10. Ideally this should be fixed in ob-R.el. Best, > > > Regards, > > -- > Nicolas Goaziou > > From 8ec02a2fa79b8601565ca7b226b8c1e4790f3439 Mon Sep 17 00:00:00 2001 > From: Nicolas Goaziou > 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)) -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D