mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-29 20:35:02 +00:00
org-export: Follow EXPORT_TITLE property when exporting subtree
* contrib/lisp/org-export.el (org-export-get-subtree-options): Make sure point is at an headline and buffer isn't narrowed before looking for EXPORT_TITLE property. * testing/lisp/test-org-export.el: Add test.
This commit is contained in:
parent
a975751527
commit
04ad4ab417
@ -1111,29 +1111,29 @@ specific items to read, if any."
|
||||
|
||||
(defun org-export-get-subtree-options ()
|
||||
"Get export options in subtree at point.
|
||||
|
||||
Assume point is at subtree's beginning.
|
||||
|
||||
Return options as a plist."
|
||||
(let (prop plist)
|
||||
(when (setq prop (progn (looking-at org-todo-line-regexp)
|
||||
(or (save-match-data
|
||||
(org-entry-get (point) "EXPORT_TITLE"))
|
||||
(org-match-string-no-properties 3))))
|
||||
(setq plist
|
||||
(plist-put
|
||||
plist :title
|
||||
(org-element-parse-secondary-string
|
||||
prop (org-element-restriction 'keyword)))))
|
||||
(when (setq prop (org-entry-get (point) "EXPORT_TEXT"))
|
||||
(setq plist (plist-put plist :text prop)))
|
||||
(when (setq prop (org-entry-get (point) "EXPORT_AUTHOR"))
|
||||
(setq plist (plist-put plist :author prop)))
|
||||
(when (setq prop (org-entry-get (point) "EXPORT_DATE"))
|
||||
(setq plist (plist-put plist :date prop)))
|
||||
(when (setq prop (org-entry-get (point) "EXPORT_OPTIONS"))
|
||||
(setq plist (org-export-add-options-to-plist plist prop)))
|
||||
plist))
|
||||
(org-with-wide-buffer
|
||||
(let (prop plist)
|
||||
;; Make sure point is at an heading.
|
||||
(unless (org-at-heading-p) (org-back-to-heading t))
|
||||
(when (setq prop (progn (looking-at org-todo-line-regexp)
|
||||
(or (save-match-data
|
||||
(org-entry-get (point) "EXPORT_TITLE"))
|
||||
(org-match-string-no-properties 3))))
|
||||
(setq plist
|
||||
(plist-put
|
||||
plist :title
|
||||
(org-element-parse-secondary-string
|
||||
prop (org-element-restriction 'keyword)))))
|
||||
(when (setq prop (org-entry-get (point) "EXPORT_TEXT"))
|
||||
(setq plist (plist-put plist :text prop)))
|
||||
(when (setq prop (org-entry-get (point) "EXPORT_AUTHOR"))
|
||||
(setq plist (plist-put plist :author prop)))
|
||||
(when (setq prop (org-entry-get (point) "EXPORT_DATE"))
|
||||
(setq plist (plist-put plist :date prop)))
|
||||
(when (setq prop (org-entry-get (point) "EXPORT_OPTIONS"))
|
||||
(setq plist (org-export-add-options-to-plist plist prop)))
|
||||
plist)))
|
||||
|
||||
(defun org-export-get-inbuffer-options (&optional backend files)
|
||||
"Return current buffer export options, as a plist.
|
||||
|
@ -253,6 +253,7 @@ text
|
||||
(should (equal (org-export-as 'test nil 'visible) "* Head1\n"))
|
||||
;; Body only.
|
||||
(flet ((org-test-template (body info) (format "BEGIN\n%sEND" body)))
|
||||
(push '(template . org-test-template) org-test-translate-alist)
|
||||
(should (equal (org-export-as 'test nil nil 'body-only)
|
||||
"* Head1\n** Head2\ntext\n*** Head3\n"))
|
||||
(should (equal (org-export-as 'test)
|
||||
@ -277,7 +278,20 @@ text
|
||||
#+END_SRC"
|
||||
(org-test-with-backend test
|
||||
(forward-line 1)
|
||||
(should (equal (org-export-as 'test 'subtree) ": 3\n")))))
|
||||
(should (equal (org-export-as 'test 'subtree) ": 3\n"))))
|
||||
;; Subtree's EXPORT_TITLE property.
|
||||
(org-test-with-backend test
|
||||
(flet ((org-test-template (body info)
|
||||
(org-export-data (plist-get info :title) info)))
|
||||
(push '(template . org-test-template) org-test-translate-alist)
|
||||
(org-test-with-temp-text "
|
||||
* Headline
|
||||
:PROPERTIES:
|
||||
:EXPORT_TITLE: subtree-title
|
||||
:END:
|
||||
Paragraph"
|
||||
(forward-line)
|
||||
(should (equal "subtree-title" (org-export-as 'test 'subtree)))))))
|
||||
|
||||
(ert-deftest test-org-export/export-snippet ()
|
||||
"Test export snippets transcoding."
|
||||
|
Loading…
Reference in New Issue
Block a user