These few functions may help Asciidoctor editors to enable live preview in Emacs Editor.
These functions have been isolated from my package RCD Utilities.
(defun rcd-command-output-from-input (program input &rest args)
"Returns output from PROGRAM INPUT with optional ARGS"
(let* ((output (with-temp-buffer
(insert input)
(apply #'call-process-region nil nil program t t nil args)
(buffer-string))))
output))
(defun rcd-asciidoctor (string &rest args)
"Returns plain text from Markdown by using pandoc"
(apply 'rcd-command-output-from-input "asciidoctor" string "-" args))
(defun rcd-asciidoctor-preview ()
"Preview asciidoctor"
(interactive)
(let* ((output (rcd-asciidoctor (buffer-string)))
(file (concat (or (getenv "TMPDIR") "/tmp/") "asciidoctor.html")))
(with-temp-file file (insert output))
(browse-url file)))
Tip
|
I recommend setting it up on a user key such as C-c a :
|
(global-set-key (kbd "C-c a") 'rcd-asciidoctor-preview)