I want use emacsclient -e "command"
to covert org mode file to html file, such as:
emacsclient -e "(org-html-export-as-html ./mynote.org)" > ./mynote.html
hope it will be save output to mynote.html file.
But I'm not familiar with elisp yet. Actually, org-html-export-as-html
has many parameter I don't know how to use it.
A/ You can do it "yourself" with:
emacsclient -e "(progn (find-file \"file.org\") (org-html-export-to-html) (kill-buffer))"
Caveat: to make it works you should have started Emacs with
emacs --daemon
or if you already have an Emacs running, type M-x server-start
B/ use a github package
https://github.com/nhoffman/org-export
which creates some compiled lisp executables:
However my personnal experience is that the command line approach is faster.
C/ Bonus, tangling file
You can tangle files with the same command line approach:
emacsclient -e "(org-babel-tangle-file \"file.org\")"
Update, gives more details about C/
"tangling" is a term coined from literate programming
Literate programming (LP) tools are used to obtain two representations from a literate source file: one suitable for further compilation or execution by a computer, the "tangled" code, and another for viewing as formatted documentation, which is said to be "woven" from the literate source.[3] While the first generation of literate programming tools were computer language-specific, the later ones are language-agnostic and exist above the programming languages.
You have a unique file:
#+TITLE: My Org file
* Configuration
#+BEGIN_SRC bash :tangle yes :tangle "tangled.sh" :shebang "#!/bin/bash"
echo "This is my configuration script"
echo "..do something interesting here.."
#+END_SRC
You can html export it (parts A/ or B/), but but can also export the code it contains, here a shell script. From Emacs this can be done with C-c C-v t
or, from shell, using the command I provided in C/ part. The result is the automatic generation of the tangled.sh
file.
You can have a look here: Babel: active code in Org-mode for further details.