I would like to use Emacs in batch mode to export a number of org
files to HTML from the command-line. And I would like to get the same result than interactively using C-cC-eh, in particular:
- honor file-local variables (such as
org-export-publishing-directory
) - honor all options specified through
#+KEYWORD:
headlines
Starting from the example given in org-export-as-html-batch
, I got to this point:
emacs --batch \
--visit=/tmp/foo.org \
--eval "(defun safe-local-variable-p (sym val) t)" \
--funcall hack-local-variables \
--eval "(setq org-export-headline-levels 4)" \
--funcall org-export-as-html-batch
However, some problems remain:
I need to explicitly specify the headline level and I fail to see why all other
#+OPTIONS
are honored (liketoc:nil
) but not this oneI had to manually trigger file-local variables parsing using
hack-local-variables
(I guess it is not automatically done in batch mode) but more importantly I had to resort to a hack to mark all local variables as safe (I'm sure there is much space for improvement here).
NB:
In case it matters, I'm using emacs 23.2.1 (Debian Squeeze flavour)
Here is a sample org
file on which I tested this:
#+TITLE: Foo
#+OPTIONS: H:4 toc:nil author:nil
* 1
** 2
*** 3
**** 4
# Local Variables:
# org-export-publishing-directory: "/some/where";
# End: