diff options
author | thibault <thibault.marin@gmx.com> | 2017-10-20 22:20:35 -0500 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-10-22 12:42:05 +0200 |
commit | 1613153aac84a183a9b91f7fde788f6552bc2954 (patch) | |
tree | bca048ed3875482b57f69d25e4d15096b4dc8114 | |
parent | 3df62457beee95a8244c674891bec4a06e9c6098 (diff) | |
download | org-mode-1613153aac84a183a9b91f7fde788f6552bc2954.tar.gz |
Fix tangling of org block with nested source block
* lisp/ob-tangle.el (org-babel-tangle-single-block): Prevent double unescaping
of source block by removing unnecessary call to `org-unescape-code-in-string'.
* testing/lisp/test-ob-tangle.el (ob-tangle/nested-block) New function.
-rw-r--r-- | lisp/ob-tangle.el | 7 | ||||
-rw-r--r-- | testing/lisp/test-ob-tangle.el | 25 |
2 files changed, 28 insertions, 4 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index adc6806..09d011f 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -494,10 +494,9 @@ non-nil, return the full association list to be used by link) source-name params - (org-unescape-code-in-string - (if org-src-preserve-indentation - (org-trim body t) - (org-trim (org-remove-indentation body)))) + (if org-src-preserve-indentation + (org-trim body t) + (org-trim (org-remove-indentation body))) comment))) (if only-this-block (list (cons src-lang (list result))) diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index 06a73f0..73b7532 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/testing/lisp/test-ob-tangle.el @@ -197,6 +197,31 @@ another block (org-babel-tangle-jump-to-org) (buffer-string))))))) +(ert-deftest ob-tangle/nested-block () + "Test tangling of org file with nested block." + (should + (string= + "#+begin_src org +,#+begin_src emacs-lisp +1 +,#+end_src +#+end_src +" + (org-test-with-temp-text-in-file + "#+header: :tangle \"test-ob-tangle.org\" +#+begin_src org +,#+begin_src org +,,#+begin_src emacs-lisp +1 +,,#+end_src +,#+end_src +#+end_src" + (unwind-protect + (progn (org-babel-tangle) + (with-temp-buffer (insert-file-contents "test-ob-tangle.org") + (buffer-string))) + (delete-file "test-ob-tangle.org")))))) + (provide 'test-ob-tangle) ;;; test-ob-tangle.el ends here |