branch: externals-release/org
commit a52d0f09181d8d21170717c3ad5e4a4b3908b22e
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>
org-export-as: Fix subtree export when metadata ends right before heading
* lisp/ox.el (org-export-as): Only include first newline after heading
line when the metadata is non-empty.
* testing/lisp/test-ox.el (test-org-export/export-scope): Add test.
Reported-by: Kaushal Modi <[email protected]>
Link:
https://orgmode.org/list/CAFyQvY1d=UEJ-6ZPG1X+st=fcfbantfgbvnhxyxh_xkclgg...@mail.gmail.com
---
lisp/ox.el | 2 +-
testing/lisp/test-ox.el | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/lisp/ox.el b/lisp/ox.el
index 12767267a7..a5f2249cad 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3040,7 +3040,7 @@ Return code as a string."
;; This way, we will be able to retrieve its export
;; options when calling
;; `org-export--get-subtree-options'.
- (backward-char)
+ (when (bolp) (backward-char))
(narrow-to-region (point) (point-max))))
;; Initialize communication channel with original buffer
;; attributes, unavailable in its copy.
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index cdb549df4b..99f5c0f0f7 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -1113,6 +1113,16 @@ Text"
(org-export-as (org-test-default-backend)
'subtree nil nil
'(:with-planning t :with-properties t)))))
+ (should
+ (equal ""
+ (org-test-with-temp-text "
+* H
+:PROPERTIES:
+:A: 1
+:END:<point>
+* H2"
+ (org-export-as (org-test-default-backend)
+ 'subtree))))
;; Visible.
(should
(equal "* H1\n"