emacsorphanage / ox-pandoc

Another org-mode exporter via pandoc.
GNU General Public License v2.0
48 stars 13 forks source link

Change data-dir using org-pandoc-options #30

Closed pdehne closed 1 year ago

pdehne commented 1 year ago

I am trying to set the data-dir option to a folder in the users home directory. When I try to determine the folder using lisp, the provided lisp code is directly copied to the executed pandoc command.

I tried a few ways to set data-dir:

(use-package ox-pandoc
  :ensure t
  :after (:any org)
  :custom
  (org-pandoc-options '((standalone . t)
            (data-dir . (expand-file-name "~/.pandoc")))))

I see in the Messages buffer:

Running pandoc with args: (-f org -t html5 -o /Users/patrick/ownCloud/Org/index.html --data-dir=expand-file-name --data-dir=~/.pandoc --standalone /Users/patrick/ownCloud/Org/index.t

This is also not working, the ~ is not substituted with the home directory when the pandoc command is run:

(use-package ox-pandoc
  :ensure t
  :after (:any org)
  :custom
  (org-pandoc-options '((standalone . t)
            (data-dir . "~/.pandoc"))))

I see in the Messages buffer:

Running pandoc with args: (-f org -t html5 -o /Users/patrick/ownCloud/Org/index.html --data-dir=~/.pandoc --standalone /Users/patrick/ownCloud/Org/index.tmpBycdLs.org)

The following is working, but I would rather not hardcode the folder if at all possible:

(use-package ox-pandoc
  :ensure t
  :after (:any org)
  :custom
  (org-pandoc-options '((standalone . t)
            (data-dir . "/Users/patrick/.pandoc"))))

I see in the Messages buffer:

Running pandoc with args: (-f org -t html5 -o /Users/patrick/ownCloud/Org/index.html --data-dir=/Users/patrick/.pandoc --standalone /Users/patrick/ownCloud/Org/index.tmpYndorp.org)
pdehne commented 1 year ago

The following is working. It forces pandoc-data-dir to be evaluated to a literal string in org-pandoc-options. I am not sure why this is needed, but that is not your problem :-) Feel free to close the issue!

(use-package ox-pandoc
  :ensure t
  :after (:any org)
  :config
  (setq org-pandoc-options '((standalone . t)))
  (let ((pandoc-data-dir (expand-file-name "~/.pandoc")))
    (setq org-pandoc-options (append org-pandoc-options `((data-dir . ,pandoc-data-dir))))))
yantar92 commented 1 year ago

Patrick Dehne @.***> writes:

(org-pandoc-options '((standalone . t) (data-dir . (expand-file-name "~/.pandoc")))))

You use literal quote here. So "(expand-file-name ...)" is not evaluated, but instead used as is. You may instead use backquote for selective evaluation:

((standalone . t) (data-dir . ,(expand-file-name "~/.pandoc"))).

-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92