Is there a Live Preview (of Asciidoc) for Emacs or Vim?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there a Live Preview (of Asciidoc) for Emacs or Vim?

Ibn Saeed
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Is there a Live Preview (of Asciidoc) for Emacs or Vim?

mojavelinux
Administrator
One approach is the Guard plugin. Guard is a file monitor that can trigger an arbitrary action upon file change. See:


(these projects need to be merged because they are providing the same thing).

I also found the following project promising enhanced AsciiDoc support for VIM. It appears to have integration with Asciidoctor. I haven't tried it myself yet.


There seem to be no shortage of efforts to bring better AsciiDoc support in VIM. Unfortunately, no one seems to be working together on the problem :P

-Dan

On Sun, Feb 21, 2016 at 2:15 AM, Ibn Saeed [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Is there a Live Preview (of Asciidoc) plugin for Emacs or Vim?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Is-there-a-Live-Preview-of-Asciidoc-for-Emacs-or-Vim-tp4367.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Is there a Live Preview (of Asciidoc) for Emacs or Vim?

hyperscope
This post was updated on .
In reply to this post by Ibn Saeed
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)