Revert "Fix c9a52787c14c3a7429bcd3c8975350525e0baa04"
This reverts commit 359572d37e
.
COMMENT headlines are expected to be ignored completely during export.
This commit is contained in:
parent
2e9a1d9c84
commit
fa0cc0ab70
|
@ -83,31 +83,28 @@ Return an alist containing all macro templates found."
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward
|
(while (re-search-forward
|
||||||
"^[ \t]*#\\+\\(MACRO\\|SETUPFILE\\):" nil t)
|
"^[ \t]*#\\+\\(MACRO\\|SETUPFILE\\):" nil t)
|
||||||
(if (org-in-commented-heading-p) (outline-next-heading)
|
(let ((element (org-element-at-point)))
|
||||||
(let ((element (org-element-at-point)))
|
(when (eq (org-element-type element) 'keyword)
|
||||||
(when (eq (org-element-type element) 'keyword)
|
(let ((val (org-element-property :value element)))
|
||||||
(let ((val (org-element-property :value element)))
|
(if (equal (org-element-property :key element) "MACRO")
|
||||||
(if (equal (org-element-property :key element) "MACRO")
|
;; Install macro in TEMPLATES.
|
||||||
;; Install macro in TEMPLATES.
|
(when (string-match
|
||||||
(when (string-match
|
"^\\(.*?\\)\\(?:\\s-+\\(.*\\)\\)?\\s-*$" val)
|
||||||
"^\\(.*?\\)\\(?:\\s-+\\(.*\\)\\)?\\s-*$"
|
(let* ((name (match-string 1 val))
|
||||||
val)
|
(template (or (match-string 2 val) ""))
|
||||||
(let* ((name (match-string 1 val))
|
(old-cell (assoc name templates)))
|
||||||
(template (or (match-string 2 val) ""))
|
(if old-cell (setcdr old-cell template)
|
||||||
(old-cell (assoc name templates)))
|
(push (cons name template) templates))))
|
||||||
(if old-cell (setcdr old-cell template)
|
;; Enter setup file.
|
||||||
(push (cons name template) templates))))
|
(let ((file (expand-file-name
|
||||||
;; Enter setup file.
|
(org-remove-double-quotes val))))
|
||||||
(let ((file (expand-file-name
|
(unless (member file files)
|
||||||
(org-remove-double-quotes val))))
|
(with-temp-buffer
|
||||||
(unless (member file files)
|
(org-mode)
|
||||||
(with-temp-buffer
|
(insert (org-file-contents file 'noerror))
|
||||||
(org-mode)
|
(setq templates
|
||||||
(insert (org-file-contents file 'noerror))
|
(funcall collect-macros (cons file files)
|
||||||
(setq templates
|
templates)))))))))))
|
||||||
(funcall collect-macros
|
|
||||||
(cons file files)
|
|
||||||
templates))))))))))))
|
|
||||||
templates))))
|
templates))))
|
||||||
(funcall collect-macros nil nil)))
|
(funcall collect-macros nil nil)))
|
||||||
|
|
||||||
|
|
130
lisp/ox.el
130
lisp/ox.el
|
@ -1479,7 +1479,7 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
|
||||||
(and backend (org-export-get-all-options backend))
|
(and backend (org-export-get-all-options backend))
|
||||||
org-export-options-alist))
|
org-export-options-alist))
|
||||||
(regexp (format "^[ \t]*#\\+%s:"
|
(regexp (format "^[ \t]*#\\+%s:"
|
||||||
(regexp-opt (nconc (delq nil (mapcar #'cadr options))
|
(regexp-opt (nconc (delq nil (mapcar 'cadr options))
|
||||||
org-export-special-keywords))))
|
org-export-special-keywords))))
|
||||||
(find-properties
|
(find-properties
|
||||||
(lambda (keyword)
|
(lambda (keyword)
|
||||||
|
@ -1496,67 +1496,62 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
|
||||||
(org-with-wide-buffer
|
(org-with-wide-buffer
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward regexp nil t)
|
(while (re-search-forward regexp nil t)
|
||||||
(if (org-in-commented-heading-p) (outline-next-heading)
|
(let ((element (org-element-at-point)))
|
||||||
(let ((element (org-element-at-point)))
|
(when (eq (org-element-type element) 'keyword)
|
||||||
(when (eq (org-element-type element) 'keyword)
|
(let ((key (org-element-property :key element))
|
||||||
(let ((key (org-element-property :key element))
|
(val (org-element-property :value element)))
|
||||||
(val (org-element-property :value element)))
|
(cond
|
||||||
(cond
|
;; Options in `org-export-special-keywords'.
|
||||||
;; Options in `org-export-special-keywords'.
|
((equal key "SETUPFILE")
|
||||||
((equal key "SETUPFILE")
|
(let ((file (expand-file-name
|
||||||
(let ((file (expand-file-name
|
(org-remove-double-quotes (org-trim val)))))
|
||||||
(org-remove-double-quotes
|
;; Avoid circular dependencies.
|
||||||
(org-trim val)))))
|
(unless (member file files)
|
||||||
;; Avoid circular dependencies.
|
(with-temp-buffer
|
||||||
(unless (member file files)
|
(insert (org-file-contents file 'noerror))
|
||||||
(with-temp-buffer
|
(let ((org-inhibit-startup t)) (org-mode))
|
||||||
(insert (org-file-contents file 'noerror))
|
(setq plist (funcall get-options
|
||||||
(let ((org-inhibit-startup t)) (org-mode))
|
(cons file files) plist))))))
|
||||||
(setq plist
|
((equal key "OPTIONS")
|
||||||
(funcall get-options
|
(setq plist
|
||||||
(cons file files) plist))))))
|
(org-combine-plists
|
||||||
((equal key "OPTIONS")
|
plist
|
||||||
(setq plist
|
(org-export--parse-option-keyword val backend))))
|
||||||
(org-combine-plists
|
((equal key "FILETAGS")
|
||||||
plist
|
(setq plist
|
||||||
(org-export--parse-option-keyword
|
(org-combine-plists
|
||||||
val backend))))
|
plist
|
||||||
((equal key "FILETAGS")
|
(list :filetags
|
||||||
(setq plist
|
(org-uniquify
|
||||||
(org-combine-plists
|
(append (org-split-string val ":")
|
||||||
plist
|
(plist-get plist :filetags)))))))
|
||||||
(list :filetags
|
(t
|
||||||
(org-uniquify
|
;; Options in `org-export-options-alist'.
|
||||||
(append (org-split-string val ":")
|
(dolist (property (funcall find-properties key))
|
||||||
(plist-get plist :filetags)))))))
|
(let ((behaviour (nth 4 (assq property options))))
|
||||||
(t
|
(setq plist
|
||||||
;; Options in `org-export-options-alist'.
|
(plist-put
|
||||||
(dolist (property (funcall find-properties key))
|
plist property
|
||||||
(let ((behaviour (nth 4 (assq property options))))
|
;; Handle value depending on specified
|
||||||
(setq plist
|
;; BEHAVIOR.
|
||||||
(plist-put
|
(case behaviour
|
||||||
plist property
|
(space
|
||||||
;; Handle value depending on
|
(if (not (plist-get plist property))
|
||||||
;; specified BEHAVIOUR.
|
(org-trim val)
|
||||||
(case behaviour
|
(concat (plist-get plist property)
|
||||||
(space
|
" "
|
||||||
(if (not (plist-get plist property))
|
(org-trim val))))
|
||||||
(org-trim val)
|
(newline
|
||||||
(concat (plist-get plist property)
|
(org-trim
|
||||||
" "
|
(concat (plist-get plist property)
|
||||||
(org-trim val))))
|
"\n"
|
||||||
(newline
|
(org-trim val))))
|
||||||
(org-trim
|
(split `(,@(plist-get plist property)
|
||||||
(concat (plist-get plist property)
|
,@(org-split-string val)))
|
||||||
"\n"
|
('t val)
|
||||||
(org-trim val))))
|
(otherwise
|
||||||
(split `(,@(plist-get plist property)
|
(if (not (plist-member plist property)) val
|
||||||
,@(org-split-string val)))
|
(plist-get plist property))))))))))))))
|
||||||
((t) val)
|
|
||||||
(otherwise
|
|
||||||
(if (plist-member plist property)
|
|
||||||
(plist-get plist property)
|
|
||||||
val))))))))))))))
|
|
||||||
;; Return final value.
|
;; Return final value.
|
||||||
plist))))
|
plist))))
|
||||||
;; Read options in the current buffer.
|
;; Read options in the current buffer.
|
||||||
|
@ -2670,6 +2665,16 @@ The function assumes BUFFER's major mode is `org-mode'."
|
||||||
(overlays-in (point-min) (point-max)))
|
(overlays-in (point-min) (point-max)))
|
||||||
ov-set)))))
|
ov-set)))))
|
||||||
|
|
||||||
|
(defun org-export--delete-commented-subtrees ()
|
||||||
|
"Delete commented subtrees or inlinetasks in the buffer."
|
||||||
|
(org-with-wide-buffer
|
||||||
|
(goto-char (point-min))
|
||||||
|
(let ((regexp (concat org-outline-regexp-bol org-comment-string)))
|
||||||
|
(while (re-search-forward regexp nil t)
|
||||||
|
(delete-region
|
||||||
|
(line-beginning-position)
|
||||||
|
(org-element-property :end (org-element-at-point)))))))
|
||||||
|
|
||||||
(defun org-export--prune-tree (data info)
|
(defun org-export--prune-tree (data info)
|
||||||
"Prune non exportable elements from DATA.
|
"Prune non exportable elements from DATA.
|
||||||
DATA is the parse tree to traverse. INFO is the plist holding
|
DATA is the parse tree to traverse. INFO is the plist holding
|
||||||
|
@ -2860,6 +2865,7 @@ Return code as a string."
|
||||||
(run-hook-with-args 'org-export-before-processing-hook
|
(run-hook-with-args 'org-export-before-processing-hook
|
||||||
(org-export-backend-name backend))
|
(org-export-backend-name backend))
|
||||||
(org-export-expand-include-keyword)
|
(org-export-expand-include-keyword)
|
||||||
|
(org-export--delete-commented-subtrees)
|
||||||
;; Update macro templates since #+INCLUDE keywords might have
|
;; Update macro templates since #+INCLUDE keywords might have
|
||||||
;; added some new ones.
|
;; added some new ones.
|
||||||
(org-macro-initialize-templates)
|
(org-macro-initialize-templates)
|
||||||
|
|
|
@ -48,6 +48,7 @@ body to execute. Parse tree is available under the `tree'
|
||||||
variable, and communication channel under `info'."
|
variable, and communication channel under `info'."
|
||||||
(declare (debug (form body)) (indent 1))
|
(declare (debug (form body)) (indent 1))
|
||||||
`(org-test-with-temp-text ,data
|
`(org-test-with-temp-text ,data
|
||||||
|
(org-export--delete-commented-subtrees)
|
||||||
(let* ((tree (org-element-parse-buffer))
|
(let* ((tree (org-element-parse-buffer))
|
||||||
(info (org-export-get-environment)))
|
(info (org-export-get-environment)))
|
||||||
(org-export--prune-tree tree info)
|
(org-export--prune-tree tree info)
|
||||||
|
|
Loading…
Reference in New Issue