From xradiograph

Programming: Mark Down

a small markup format

I use markdown so much for github readmes, on Stack Exchange and Discourse that I’m really, really getting used to it.


I wish I could use it as an alternate markup here in PmWiki; not main markup, as so many other markups are possible here in the wiki. But for simple things like headings, lists, links, &c I am very VERY happy with it.


PageDown is the Java Script Markdown previewer used on Stack Overflow and the rest of the Stack Exchange network.


in-browser editor can save locally



Emacs integration


For rendering, I used node’s markdown-preview, for which I contributed a bug-fix the day I started using it.




(autoload 'markdown-mode "markdown-mode"
   "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

(setq markdown-command "markdown-preview")
(setq markdown-command-needs-filename t)


And that should do it. I had no luck setting markdown-open-command to use markdown-preview



NOTE: markdown-mode.el runs a shell-command, which waits for a return value.
This ties up the buffer (actually, ALL of Emacs) preventing further changes.
Which is a shame, since markdown-preview watches the file and performs live-updates.


I did get the below to work in *scratch* via emacs’ Asynchronous Processes notes:


(add-to-list 'exec-path (concat (file-name-as-directory (getenv "APPDATA")) "npm"))
(start-process "markdown-preview" "*scratch*" "markdown-preview.cmd" "d:/Dropbox/projects/NaNoGenMo.yawp/ngram/")

;; so then this should work:
(defun markdown-preview-buffer ()
  "open current buffer with markdown-preview (node.js)"
  (start-process "markdown-preview" nil "markdown-preview.cmd" (buffer-file-name)))

;;; redefine the keymapping in markdown-mode only
(define-key markdown-mode-map (kbd "C-c C-c p") 'markdown-preview-buffer)


cf notes on start and cmd


The second parameter "*scratch*" associated that buffer with the process, appending stdout to the buffer -- to see errors, in particular. Remove for other uses.


BUT how to get markdown-mode.el to use this?
Or just skip the mode entirely, and wire up my own thing?


The docs on markdown-mode.el speak of markdown as a program you’d just find lying about, ready to do all sorts of things. While I haven’t been able to find it at all for Win32 or Gnu.



See Also

Git - used on github, amongst other locations for editing



Category tags

Retrieved from
Page last modified on November 21, 2014, at 08:58 AM