I write my blog in Markdown. While there are good other alternatives, like CommonMark, I like to stick to the original. Most of the time there is no difference either way. This post works for both.
John Gruber made the format easily editable in an editor on purpose. For me this editor is Emacs. Still the default markdown-mode lacks some author features, I would like to have, without changing the environment I use. Some of those things are style support, and good spellchecking.
After some digging I stumbled upon Marked 2. It is just a Markdown preview app, that has a lot of settings. For example author support and tweaking the rendering to your needs. What I like is that they did not even try to build a crappy WYSIWYG editor, they just added the missing features, so you can still use your own setup.
Why is this important? Jekyll, the framework for this blog, has a bunch of assumptions about the blog files. At the start of each file you have metadata, that I do not want shown in the preview. Sure, I could use a Jekyll server with a browser to show the real result, but then I do not see what has changed in every iteration.
Let’s say I write a long article and want to see how it looks like. I open a browser and go to my article. Then I decide to add another paragraph at the end. I save the file and refresh the page just to find that I am at the top of the page again. It is annoing to scroll down all the time.
Here the authoring tools from Marked 2 come in handy. Upon saving the page gets updated automatically with all changes highlighted. Additionally the app diagnoses many common writing style problems and colors them depending on severity.
Back to the original problem. How do I integrate Marked 2 in my workflow? Easy, I just had to add this snippet to my Emacs configuration and that’s it.
(defun markdown-preview-file ()
"open Markdown preview on current file"
(interactive)
(shell-command
(format "open -a /Applications/Marked\\ 2.app %s"
(shell-quote-argument (buffer-file-name))))
)
As the comment suggest this opens the current file in Marked 2. Then I just need to arrange my windows. I like Slate for this and everything works like a charm.
Another possible workflow is to open the file with Marked 2, configure the preferred editor in the settings and press command + e
. Either way you get two applications opening the same file. One for editing and the second for reading. Give it a try.