Ver Fonte

separate noweb handling for code and results on export
* lisp/ob-exp.el (org-babel-exp-src-block): Remove noweb handling from
the top level.
(org-babel-exp-code): Noweb handling for code export.
(org-babel-exp-results): Noweb handling for results export.

Eric Schulte há 13 anos atrás
pai
commit
cb77b49774
1 ficheiros alterados com 12 adições e 10 exclusões
  1. 12 10
      lisp/ob-exp.el

+ 12 - 10
lisp/ob-exp.el

@@ -113,15 +113,6 @@ none ----- do not display either code or results upon export"
 		    (if (boundp lang-headers) (eval lang-headers) nil)
 		    raw-params))))
 	  (setf hash (org-babel-sha1-hash info)))
-	;; expand noweb references in the original file
-	(setf (nth 1 info)
-	      (if (string= "strip-export" (cdr (assoc :noweb (nth 2 info))))
-		  (replace-regexp-in-string
-		   (org-babel-noweb-wrap) "" (nth 1 info))
-		(if (org-babel-noweb-p (nth 2 info) :export)
-		    (org-babel-expand-noweb-references
-                     info (org-babel-exp-get-export-buffer))  
-		  (nth 1 info))))
 	(org-babel-exp-do-export info 'block hash)))))
 
 (defcustom org-babel-exp-call-line-template
@@ -260,6 +251,14 @@ replaced with its value."
 
 (defun org-babel-exp-code (info)
   "Return the original code block formatted for export."
+  (setf (nth 1 info)
+	(if (string= "strip-export" (cdr (assoc :noweb (nth 2 info))))
+	    (replace-regexp-in-string
+	     (org-babel-noweb-wrap) "" (nth 1 info))
+	  (if (org-babel-noweb-p (nth 2 info) :export)
+	      (org-babel-expand-noweb-references
+	       info (org-babel-exp-get-export-buffer))  
+	    (nth 1 info))))
   (org-fill-template
    org-babel-exp-code-template
    `(("lang"  . ,(nth 0 info))
@@ -280,7 +279,10 @@ inhibit insertion of results into the buffer."
   (when (and org-export-babel-evaluate
 	     (not (and hash (equal hash (org-babel-current-result-hash)))))
     (let ((lang (nth 0 info))
-	  (body (nth 1 info))
+	  (body (if (org-babel-noweb-p (nth 2 info) :eval)
+		    (org-babel-expand-noweb-references
+		     info (org-babel-exp-get-export-buffer))  
+		  (nth 1 info)))
 	  (info (copy-sequence info)))
       ;; skip code blocks which we can't evaluate
       (when (fboundp (intern (concat "org-babel-execute:" lang)))