contrib/lisp/org-export: Fix subtree export
* contrib/lisp/org-export.el (org-export-get-subtree-options): Correctly get `:title: from headline when no "EXPORT_TITLE" property is defined. Also assume point is at subtree beginning. (org-export-as): Fix subtree parsing. The subtree starts at point or at first heading above. Contents do not include the first headline.
This commit is contained in:
parent
938f126511
commit
a496c3af47
|
@ -913,23 +913,25 @@ BACKEND is a symbol specifying the back-end to use."
|
||||||
|
|
||||||
(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.
|
||||||
Return the options as a plist."
|
|
||||||
(org-with-wide-buffer
|
Assume point is at subtree's beginning.
|
||||||
(when (ignore-errors (org-back-to-heading t))
|
|
||||||
(let (prop plist)
|
Return options as a plist."
|
||||||
(when (setq prop (progn (looking-at org-todo-line-regexp)
|
(let (prop plist)
|
||||||
(or (org-entry-get (point) "EXPORT_TITLE")
|
(when (setq prop (progn (looking-at org-todo-line-regexp)
|
||||||
(org-match-string-no-properties 3))))
|
(or (save-match-data
|
||||||
(setq plist (plist-put plist :title prop)))
|
(org-entry-get (point) "EXPORT_TITLE"))
|
||||||
(when (setq prop (org-entry-get (point) "EXPORT_TEXT"))
|
(org-match-string-no-properties 3))))
|
||||||
(setq plist (plist-put plist :text prop)))
|
(setq plist (plist-put plist :title prop)))
|
||||||
(when (setq prop (org-entry-get (point) "EXPORT_AUTHOR"))
|
(when (setq prop (org-entry-get (point) "EXPORT_TEXT"))
|
||||||
(setq plist (plist-put plist :author prop)))
|
(setq plist (plist-put plist :text prop)))
|
||||||
(when (setq prop (org-entry-get (point) "EXPORT_DATE"))
|
(when (setq prop (org-entry-get (point) "EXPORT_AUTHOR"))
|
||||||
(setq plist (plist-put plist :date prop)))
|
(setq plist (plist-put plist :author prop)))
|
||||||
(when (setq prop (org-entry-get (point) "EXPORT_OPTIONS"))
|
(when (setq prop (org-entry-get (point) "EXPORT_DATE"))
|
||||||
(setq plist (org-export-add-options-to-plist plist prop)))
|
(setq plist (plist-put plist :date prop)))
|
||||||
plist))))
|
(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 (buffer-string backend files)
|
(defun org-export-get-inbuffer-options (buffer-string backend files)
|
||||||
"Return in-buffer options as a plist.
|
"Return in-buffer options as a plist.
|
||||||
|
@ -1954,28 +1956,28 @@ Return code as a string."
|
||||||
(save-restriction
|
(save-restriction
|
||||||
;; Narrow buffer to an appropriate region for parsing.
|
;; Narrow buffer to an appropriate region for parsing.
|
||||||
(when (org-region-active-p)
|
(when (org-region-active-p)
|
||||||
(narrow-to-region (region-beginning) (region-end)))
|
(narrow-to-region (region-beginning) (region-end))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min)))
|
||||||
(when subtreep
|
(when (and subtreep (not (org-at-heading-p)))
|
||||||
(unless (org-at-heading-p)
|
;; Ensure point is at sub-tree's beginning.
|
||||||
(org-with-limited-levels (outline-next-heading)))
|
(org-with-limited-levels (org-back-to-heading (not visible-only))))
|
||||||
(let ((end (save-excursion (org-end-of-subtree t)))
|
|
||||||
(begin (progn (forward-line)
|
|
||||||
(org-skip-whitespace)
|
|
||||||
(point-at-bol))))
|
|
||||||
(narrow-to-region begin end)))
|
|
||||||
;; Retrieve export options (INFO) and parsed tree (RAW-DATA).
|
;; Retrieve export options (INFO) and parsed tree (RAW-DATA).
|
||||||
;; Buffer isn't parsed directly. Instead, a temporary copy is
|
;; Buffer isn't parsed directly. Instead, a temporary copy is
|
||||||
;; created, where all code blocks are evaluated. RAW-DATA is
|
;; created, where all code blocks are evaluated. RAW-DATA is
|
||||||
;; the parsed tree of the buffer resulting from that process.
|
;; the parsed tree of the buffer resulting from that process.
|
||||||
;; Eventually call `org-export-filter-parse-tree-functions'..
|
;; Eventually call `org-export-filter-parse-tree-functions'..
|
||||||
(let ((info (org-export-collect-options backend subtreep ext-plist))
|
(let ((info (org-export-collect-options backend subtreep ext-plist))
|
||||||
(raw-data (org-export-filter-apply-functions
|
(raw-data (progn
|
||||||
org-export-filter-parse-tree-functions
|
(when subtreep ; Only parse subtree contents.
|
||||||
(org-export-with-current-buffer-copy
|
(let ((end (save-excursion (org-end-of-subtree t))))
|
||||||
(org-export-blocks-preprocess)
|
(narrow-to-region
|
||||||
(org-element-parse-buffer nil visible-only))
|
(progn (forward-line) (point)) end)))
|
||||||
backend)))
|
(org-export-filter-apply-functions
|
||||||
|
org-export-filter-parse-tree-functions
|
||||||
|
(org-export-with-current-buffer-copy
|
||||||
|
(org-export-blocks-preprocess)
|
||||||
|
(org-element-parse-buffer nil visible-only))
|
||||||
|
backend))))
|
||||||
;; Initialize the communication system and combine it to INFO.
|
;; Initialize the communication system and combine it to INFO.
|
||||||
(setq info
|
(setq info
|
||||||
(org-combine-plists
|
(org-combine-plists
|
||||||
|
|
Loading…
Reference in New Issue