Skip to content

Instantly share code, notes, and snippets.

@fredRos
Last active March 9, 2023 14:22
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save fredRos/0e3a845de95ec654538f to your computer and use it in GitHub Desktop.
Save fredRos/0e3a845de95ec654538f to your computer and use it in GitHub Desktop.
Setup emacs with github markdown and pandoc offline rendering

Based on this blog.

This guide shows you how to setup emacs to render a README.md very similarly to how github will do it; except it also works offline. There are no dependencies that can't be easily installed via the package manager on ubuntu.

  1. Install emacs24, the markdown mode, and pandoc. You may need the packages emacs, emacs-goodies-el, and pandoc.
  2. Get a style sheet that resembles the github style from this gist and store it. I put it in ~/emacs.d/github-pandoc.css.
  3. Configure emacs: in .emacs, add
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
(setq markdown-command "pandoc -c file:///home/beaujean/.emacs.d/github-pandoc.css --from markdown_github -t html5 --mathjax --highlight-style pygments --standalone")

Now test the setup. Create a markdown file, enter these lines

Hello world

Save, then select Export & view from the Markdown menu within emacs. Your result should look like

Hello world

When editing in emacs, I find it comfortable to regularly export via C-c C-c e and have firefox reload the page on demand using the Auto Reload extension

@NimoTh
Copy link

NimoTh commented Aug 10, 2015

I like it, thanks. Only for some reason, I just cannot get checkboxes in lists to work. Found nowhere how to do this with emacs. Any clue?

Copy link

ghost commented Jan 20, 2018

also, you can add a <meta http-equiv="refresh" content="3" > tag to html for auto refresh :)

@stefanavey
Copy link

Tried this and like the formatting but can't get LaTeX equations to show up. I'm using tex syntax in dollar signs like:
$\alpha{}$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment