3

I’m using Spacemacs with markdown-mode and I’ve configured it according to Jason Blevins’ guide.

Other things I’ve tried

  • Pandoc works pretty well except when I set the —lua-filter=task-list.lua flag and I don’t have chackboxes to render (but it only fails with certain files and I have no idea why). This doesn’t give me a live preview though.

  • I love the mume-cli package, which uses the mume library on which markdown-preview-enhanced is based, but I can’t configure it the way I can in VSCode. (I can modify a js file in Linux, but I can’t find that file in any of the directories inside of the node_modules directories). It does generate an html file that I can open in the browser, but whenever I export, Emacs asks if I want to overwrite my html file twice. I have to answer yes, then no in order to get it to render successfully. I also have to manually reload the page in my browser each time.

  • livedown, flyit-md, and vue do not do what I’m asking.

I know a simple solution is to use VSCode for Markdown editing, but I don’t like how the Vim extension works (or doesn’t).

Limitations

  • I don’t know how to configure a node.js package without rebuilding it (and it doesn’t look like I can build a package before publishing it...). The npm sites have these configurations people can make, but no comments on where to put the text snippets they offer as examples.

  • I don’t know or have much time to learn Lisp or JavaScript/TypeScript. I want to use a package someone else has written and configure markdown-mode to call it.

  • I want a live preview that renders math (MathJax and KaTeX) as well as checkboxes. This is a good set of capabilities I’d like.

  • I want to do this with Emacs.

  • I do not want to configure/build anything each time I have a file with different Mardown features. Just one command for whatever file I have open in the current buffer.

  • It sounds like you have a "How do I do X?" question, where X has a list of criteria. Could you please state the question explicitly? Q&A here works best for narrow, concrete, specific questions. Broad, exploratory questions are typically less useful (and some questions are simply closed as too broad). – Drew Oct 27 '18 at 19:22
  • I'm not sure if your criteria require that your solution be *within* emacs. But if you're using windows or macOS [marked 2](http://marked2app.com) is probably your best bet. It integrates nicely with markdown-mode using `markdown-open-command`. You can read about it in the [customization](https://github.com/jrblevin/markdown-mode#customization) section of markdown-mode. – mclear Jan 28 '19 at 00:27
  • IWe're in an Emacs-specific site, so the reference to other editors just make the question less clear (since most of us don't know how those editors behave). I'd recommend to rephrase the question along the lines of "using Emacs and markdown-mode, when I try to do live preview on via M-x `` the math (or ) is all garbled (). How do I make it so it's properly rendered?" – Stefan Jan 23 '20 at 13:26

3 Answers3

0

I think I can edit in Emacs and use Markdown Preview Enhanced to view a live preview. It updates the preview every time I save the file. It wasn't working when I first tried it for some reason.

  • 1
    If anyone has a solution that doesn't involve Atom/VSCode or adds the GitLab capabilities (adding CSS elements without inserting HTML code into the Markdown file), that would be even better. – masterBuilderBenny Oct 29 '18 at 17:35
0

Markdown mode has the function markdown-live-preview-mode which will allow preview in a split window of your markdown buffer. If you use a version of emacs with xwidget support you can have a full html preview of your markdown doc. Just use this function:

  (defun cpm--markdown-live-preview-window-xwidget (file)
    "Preview file with xwidget browser"
    (xwidget-webkit-browse-url (concat "file://" file))
    (let ((buf (xwidget-buffer (xwidget-webkit-current-session))))
      (when (buffer-live-p buf)
        (and (eq buf (current-buffer)) (quit-window))
        (pop-to-buffer buf))))

and then (setq markdown-live-preview-window-function 'cpm--markdown-live-preview-window-xwidget)

mclear
  • 1,525
  • 9
  • 17
0

To preview markdown documents in realtime, I'm a fan of using vmd-mode. It's a minor mode that can be used alongside markdown-mode, and it'll spawn an external program called vmd to render the markdown. It's particularly nice, because it understands github-flavored markdown.

Since you're using Spacemacs, it's already part of the markdown layer. Add the following to your dotspacemacs-configuration-layers.

(markdown :variables
          markdown-live-preview-engine 'vmd)

Then, in your terminal, type this to install vmd.

npm i -g vmd

This is presuming you have node.js installed already. Once that's done, restart Spacemacs and open up a markdown file to try it out. The keyboard sequence is , c P to start vmd-mode. You can also M-x vmd-mode or SPC SPC vmd-mode or :vmd-mode.

g-gundam
  • 1,096
  • 1
  • 3
  • 13