forked from mirrors/org-mode
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 ()
|
(defun org-export-get-subtree-options ()
|
||||||
"Get export options in subtree at point.
|
"Get export options in subtree at point.
|
||||||
|
|
||||||
Assume point is at subtree's beginning.
|
|
||||||
|
|
||||||
Return options as a plist."
|
Return options as a plist."
|
||||||
(let (prop plist)
|
(org-with-wide-buffer
|
||||||
(when (setq prop (progn (looking-at org-todo-line-regexp)
|
(let (prop plist)
|
||||||
(or (save-match-data
|
;; Make sure point is at an heading.
|
||||||
(org-entry-get (point) "EXPORT_TITLE"))
|
(unless (org-at-heading-p) (org-back-to-heading t))
|
||||||
(org-match-string-no-properties 3))))
|
(when (setq prop (progn (looking-at org-todo-line-regexp)
|
||||||
(setq plist
|
(or (save-match-data
|
||||||
(plist-put
|
(org-entry-get (point) "EXPORT_TITLE"))
|
||||||
plist :title
|
(org-match-string-no-properties 3))))
|
||||||
(org-element-parse-secondary-string
|
(setq plist
|
||||||
prop (org-element-restriction 'keyword)))))
|
(plist-put
|
||||||
(when (setq prop (org-entry-get (point) "EXPORT_TEXT"))
|
plist :title
|
||||||
(setq plist (plist-put plist :text prop)))
|
(org-element-parse-secondary-string
|
||||||
(when (setq prop (org-entry-get (point) "EXPORT_AUTHOR"))
|
prop (org-element-restriction 'keyword)))))
|
||||||
(setq plist (plist-put plist :author prop)))
|
(when (setq prop (org-entry-get (point) "EXPORT_TEXT"))
|
||||||
(when (setq prop (org-entry-get (point) "EXPORT_DATE"))
|
(setq plist (plist-put plist :text prop)))
|
||||||
(setq plist (plist-put plist :date prop)))
|
(when (setq prop (org-entry-get (point) "EXPORT_AUTHOR"))
|
||||||
(when (setq prop (org-entry-get (point) "EXPORT_OPTIONS"))
|
(setq plist (plist-put plist :author prop)))
|
||||||
(setq plist (org-export-add-options-to-plist plist prop)))
|
(when (setq prop (org-entry-get (point) "EXPORT_DATE"))
|
||||||
plist))
|
(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)
|
(defun org-export-get-inbuffer-options (&optional backend files)
|
||||||
"Return current buffer export options, as a plist.
|
"Return current buffer export options, as a plist.
|
||||||
|
|
|
@ -253,6 +253,7 @@ text
|
||||||
(should (equal (org-export-as 'test nil 'visible) "* Head1\n"))
|
(should (equal (org-export-as 'test nil 'visible) "* Head1\n"))
|
||||||
;; Body only.
|
;; Body only.
|
||||||
(flet ((org-test-template (body info) (format "BEGIN\n%sEND" body)))
|
(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)
|
(should (equal (org-export-as 'test nil nil 'body-only)
|
||||||
"* Head1\n** Head2\ntext\n*** Head3\n"))
|
"* Head1\n** Head2\ntext\n*** Head3\n"))
|
||||||
(should (equal (org-export-as 'test)
|
(should (equal (org-export-as 'test)
|
||||||
|
@ -277,7 +278,20 @@ text
|
||||||
#+END_SRC"
|
#+END_SRC"
|
||||||
(org-test-with-backend test
|
(org-test-with-backend test
|
||||||
(forward-line 1)
|
(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 ()
|
(ert-deftest test-org-export/export-snippet ()
|
||||||
"Test export snippets transcoding."
|
"Test export snippets transcoding."
|
||||||
|
|
Loading…
Reference in New Issue