I have set of Emacs utilities and recently I have been exploring Asciidoc. If I remember well, I have been using Asciidoc before Markdown appeared.
The function is part of
RCD Utilities for Emacs. Maybe for readers I would need to make it self-contained, that user does not need to load the whole package. It is very simple.
I have isolated few functions that will make preview in Emacs and the preview function may be bound to a key. It will open browser on the exported file, that will be located either in /tmp directory or user's $TMPDIR directory.
I will be updating functions on my website:
https://hyperscope.link/3/7/1/5/3/Asciidoctor-live-preview-functions-for-Emacs-37153.html
(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)))
(global-set-key (kbd "C-c a") 'rcd-asciidoctor-preview)