Quellcode durchsuchen

don't always replace <<noweb>> references when :exports both

* lisp/ob-exp.el (org-babel-exp-results): Alter a copy of info.
* testing/examples/babel.org (an): Example data for test behavior.
* testing/lisp/test-ob-exp.el (ob-exp/noweb-no-export-and-exports-both):
  Confirm proper behavior.
Eric Schulte vor 13 Jahren
Ursprung
Commit
94f10ddfd7
3 geänderte Dateien mit 28 neuen und 1 gelöschten Zeilen
  1. 2 1
      lisp/ob-exp.el
  2. 19 0
      testing/examples/babel.org
  3. 7 0
      testing/lisp/test-ob-exp.el

+ 2 - 1
lisp/ob-exp.el

@@ -251,7 +251,8 @@ 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 (nth 1 info))
+	  (info (copy-sequence info)))
       ;; skip code blocks which we can't evaluate
       (when (fboundp (intern (concat "org-babel-execute:" lang)))
 	(org-babel-eval-wipe-error-buffer)

+ 19 - 0
testing/examples/babel.org

@@ -288,3 +288,22 @@ exporting a code block with a name
 #+begin_src sh :foo "baz"
   echo bar
 #+end_src
+* noweb no-export and exports both
+  :PROPERTIES:
+  :ID:       8a820f6c-7980-43db-8a24-0710d33729c9
+  :END:
+Weird interaction.
+
+here is one block
+
+#+name: noweb-no-export-and-exports-both-1
+#+BEGIN_SRC sh :exports none
+  echo 1
+#+END_SRC
+
+and another
+
+#+BEGIN_SRC sh :noweb no-export :exports both
+  # I am inside the code block
+  <<noweb-no-export-and-exports-both-1>>
+#+END_SRC

+ 7 - 0
testing/lisp/test-ob-exp.el

@@ -217,6 +217,13 @@ elements in the final html."
 	(should (string-match "baz" ascii))
 	(should (string-match "replace" ascii))))))
 
+(ert-deftest ob-exp/noweb-no-export-and-exports-both ()
+  (org-test-at-id "8a820f6c-7980-43db-8a24-0710d33729c9"
+    (org-narrow-to-subtree)
+    (let ((html (org-export-as-html nil nil nil 'string 'body-only)))
+      (should (string-match (regexp-quote "noweb-no-export-and-exports-both-1")
+			    html)))))
+
 (provide 'test-ob-exp)
 
 ;;; test-ob-exp.el ends here