8

Platform: Windows 7, Emacs 24.2, Pandoc 1.17.2

Scenario: I am writing a markdown file in Emacs. I need to use pandoc to render the output, because it supports citations (using pandoc-citeproc).

Question: How can I preview a pandoc-rendered version (probably html) in another buffer simultaneously?

henning
  • 82
  • 2
  • 16

1 Answers1

9

After a while, I found the answer myself:

In a nutshell: Use a combination of Eww and markdown mode, and configure markdown mode to render markdown with pandoc.

Alas, easier said than done.

  • Update to Emacs 24.5
  • Eww is the built-in browser since Emacs 24.5 It can be used to display html output. Eww does not run out of the box in Emacs 24.5 for windows. The libxml2 library has to be downloaded and copied manually into Emacs' bin folder.
  • In order to install markdown mode through the built-in package-manager, you first need to fix the package manager. It relies on TLS. However, Emacs' 24.5 TLS implementation does not work out of the box in windows. To make it work:
  • Now you can install markdown mode by invoking M-x install-package markdown-mode.
  • Configure the rendering engine by invonking M-x customize-mode in the active markdown buffer. Set this to pandoc with your preferred flags and options.
  • Press C-C-l inside the markdown buffer to see the rendered results in a Eww buffer next to your markdown file.

...et voilà.

henning
  • 82
  • 2
  • 16
  • 1
    I wonder if you can use this customization with other modes that permit easy live preview: http://wikemacs.org/wiki/Markdown#Live_preview_as_you_type – Ehvince Sep 16 '16 at 17:16
  • @Ehvince Nice pointer, but from the description, neither of these tools seem to be configureable to use pandoc. – henning Sep 17 '16 at 17:19
  • 1
    To be more specific about the **Configure** step: find `Markdown Command` in the list and select on the triangle at the left margin. Then select `Value Menu` > `Shell command` and insert `pandoc` in to box. At the top, select `Apply and Save`. This has the effect of setting the variable `markdown-command` to `"pandoc"` in your `init.el` file, which is alternative way of setting it. – Liam Jan 26 '20 at 14:11