# Convert Markdown to HTML Within Emacs Using Pandoc

Originally published: 2014-11-24
Canonical URL: /2014/Nov/convert-markdown-to-html-within-emacs-using-pandoc/

Okay, so there actually is a [pandoc-mode](http://joostkremers.github.io/pandoc-mode/), but I couldn't figure out how to configure and use it, so it was easier to just write the one command that I wanted—

```elisp
(defun markdown-to-html ()
  (interactive)
  (let* ((basename (file-name-sans-extension (buffer-file-name)))
         (html-filename (format "%s.html" basename)))
    (shell-command (format "pandoc -o %s %s"
                           html-filename (buffer-file-name)))
    (find-file-other-window html-filename)))
```
