Skip to content

Commit

Permalink
Fix bundle/sect names leaking into file-based exp aftr subtree-based
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Feb 22, 2018
1 parent bddc6fd commit 8c14700
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions ox-hugo.el
Expand Up @@ -888,14 +888,19 @@ is in progress. See `org-hugo--before-export-function' and
;; (message "[ox-hugo ob-exp] ret: %S" ret)
ret))

(defun org-hugo--before-export-function ()
(defun org-hugo--before-export-function (subtreep)
"Function to be run before an ox-hugo export.
This function is called in the very beginning of
`org-hugo-export-to-md', `org-hugo-export-as-md' and
`org-hugo-publish-to-md'.
SUBTREEP is non-nil for subtree-based exports.
This is an internal function."
(unless subtreep
;; Reset the variables that are used only for subtree exports.
(setq org-hugo--subtree-coord nil))
(advice-add 'org-babel-exp-code :around #'org-hugo--org-babel-exp-code))

(defun org-hugo--after-export-function ()
Expand All @@ -906,6 +911,8 @@ This function is called in the very end of
`org-hugo-publish-to-md'.
This is an internal function."
(setq org-hugo--section nil)
(setq org-hugo--bundle nil)
(advice-remove 'org-babel-exp-code #'org-hugo--org-babel-exp-code))

;;;; HTMLized section number for headline
Expand Down Expand Up @@ -3086,10 +3093,7 @@ is non-nil.
Return the buffer the export happened to."
(interactive)
(org-hugo--before-export-function)
(unless subtreep
;; Reset the variables that are used only for subtree exports.
(setq org-hugo--subtree-coord nil))
(org-hugo--before-export-function subtreep)
;; Allow certain `ox-hugo' properties to be inherited.
(let ((org-use-property-inheritance (org-hugo--selective-property-inheritance)))
(prog1
Expand Down Expand Up @@ -3119,7 +3123,7 @@ contents of hidden elements.
Return output file's name."
(interactive)
(org-hugo--before-export-function)
(org-hugo--before-export-function subtreep)
;; Allow certain `ox-hugo' properties to be inherited. It is
;; important to set the `org-use-property-inheritance' before
;; setting the `info' var so that properties like
Expand Down Expand Up @@ -3150,12 +3154,7 @@ Return output file's name."
(setq matched-exclude-tag exclude-tag)
(setq do-export nil))))
(if do-export
(progn
;; Reset the variables that are used only for subtree exports.
(setq org-hugo--subtree-coord nil)
(setq org-hugo--section nil)
(setq org-hugo--bundle nil)
(message "[ox-hugo] Exporting `%s' (%s)" title fname))
(message "[ox-hugo] Exporting `%s' (%s)" title fname)
(message "[ox-hugo] %s was not exported as it is tagged with an exclude tag `%s'"
fname matched-exclude-tag))))
(when do-export
Expand All @@ -3173,7 +3172,7 @@ Return output file's name."
;; publishing directory.

;; Return output file name."
;; (org-hugo--before-export-function)
;; (org-hugo--before-export-function subtreep)
;; ;; Allow certain `ox-hugo' properties to be inherited.
;; (let ((org-use-property-inheritance (org-hugo--selective-property-inheritance)))
;; (prog1
Expand Down

0 comments on commit 8c14700

Please sign in to comment.