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)) -- 1.8.5.1