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 <kaushal.modi@gmail.com>
Link: https://orgmode.org/list/CAFyQvY1d=UEJ-6ZPG1X+st=fCfBAnTfgbVNhxyxH_xKcLGG4cQ@mail.gmail.com
This commit is contained in:
Ihor Radchenko 2023-01-12 12:20:08 +03:00
parent 89d13998bd
commit a52d0f0918
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 11 additions and 1 deletions

View File

@ -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.

View File

@ -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"