2017-12-08 22:59:42 -05:00
|
|
|
;;; lang/org/+export.el -*- lexical-binding: t; -*-
|
2017-07-05 02:33:41 +02:00
|
|
|
|
2018-01-08 20:38:46 -05:00
|
|
|
(add-hook 'org-load-hook #'+org|init-export)
|
|
|
|
|
2017-07-05 02:33:41 +02:00
|
|
|
;; I don't have any beef with org's built-in export system, but I do wish it
|
2018-02-01 16:36:54 -05:00
|
|
|
;; would export to a central directory (by default), rather than
|
|
|
|
;; `default-directory'. This is because all my org files are usually in one
|
|
|
|
;; place, and I want to be able to refer back to old exports if needed.
|
2017-07-05 02:33:41 +02:00
|
|
|
|
|
|
|
(def-package! ox-pandoc
|
2017-12-08 22:59:42 -05:00
|
|
|
:defer t
|
2017-07-05 02:33:41 +02:00
|
|
|
:config
|
2018-02-01 16:36:54 -05:00
|
|
|
(push 'pandoc org-export-backends)
|
2017-07-05 02:33:41 +02:00
|
|
|
(setq org-pandoc-options
|
|
|
|
'((standalone . t)
|
2018-04-21 02:02:20 -04:00
|
|
|
(mathjax . t))))
|
2017-07-05 02:33:41 +02:00
|
|
|
|
|
|
|
;;
|
2018-01-08 20:38:46 -05:00
|
|
|
(defun +org|init-export ()
|
2018-02-01 16:36:54 -05:00
|
|
|
(setq org-export-backends '(ascii html latex md)
|
|
|
|
org-publish-timestamp-directory (concat doom-cache-dir "/org-timestamps/"))
|
2017-12-16 12:50:04 -05:00
|
|
|
|
2018-02-01 16:36:54 -05:00
|
|
|
(when (executable-find "pandoc")
|
|
|
|
(require 'ox-pandoc))
|
2017-07-05 02:33:41 +02:00
|
|
|
|
2018-02-01 16:36:54 -05:00
|
|
|
;; Export to a central location by default or if target isn't in `+org-dir'.
|
|
|
|
(setq org-export-directory (expand-file-name ".export" +org-dir))
|
2017-07-05 02:33:41 +02:00
|
|
|
(unless (file-directory-p org-export-directory)
|
|
|
|
(make-directory org-export-directory t))
|
2018-02-01 16:36:54 -05:00
|
|
|
|
2017-07-05 02:33:41 +02:00
|
|
|
(defun +org*export-output-file-name (args)
|
2018-02-01 16:36:54 -05:00
|
|
|
"Return a centralized export location unless one is provided or the current
|
|
|
|
file isn't in `+org-dir'."
|
|
|
|
(when (and (not (nth 2 args))
|
|
|
|
buffer-file-name
|
|
|
|
(file-in-directory-p (file-truename buffer-file-name) (file-truename +org-dir)))
|
2017-07-05 02:33:41 +02:00
|
|
|
(setq args (append args (list org-export-directory))))
|
|
|
|
args)
|
2018-02-01 16:36:54 -05:00
|
|
|
(advice-add #'org-export-output-file-name :filter-args #'+org*export-output-file-name))
|