瀏覽代碼

ob: strip *single* trailing newline from code block bodies

Eric Schulte 13 年之前
父節點
當前提交
8834bde39f
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      lisp/ob.el

+ 5 - 1
lisp/ob.el

@@ -957,7 +957,11 @@ may be specified in the current buffer."
 	 (lang (org-babel-clean-text-properties (match-string 2)))
          (lang-headers (intern (concat "org-babel-default-header-args:" lang)))
 	 (switches (match-string 3))
-         (body (org-babel-clean-text-properties (match-string 5)))
+         (body (org-babel-clean-text-properties
+		(let* ((body (match-string 5))
+		       (sub-length (- (length body) 1)))
+		  (when (string= "\n" (substring body sub-length))
+		    (substring body 0 sub-length)))))
 	 (preserve-indentation (or org-src-preserve-indentation
 				   (string-match "-i\\>" switches))))
     (list lang