Hooking Markdown into the browser, and in fact into any application that has text input widgets at all, is actually more simple than might at first appear: you just need xclip (or some equivalent, I suppose, if you.re not on X11). This little tool can dump any of the X11 selections, such as the clipboard, to its stdout or slurp its stdin into one of the selections.
Thus, I have this shell oneliner bound to a keyboard shortcut in my window manager:
xclip -o -sel clip | Markdown | SmartyPants -2 | xclip -sel clipWith that in place, I simply write my entries in a natural format, then I copy, hit a key, and paste, and there they are, turned to HTML and typographically smartened. Presto.
Anyone know of a Windows analogue of xclip?
* Well, at work I support the damn OS, and at home I just enjoy the eye-candy…
Update: Jim pointed me to UnxUtils and the programs pclip.exe and gclip.exe. Here’s Jim’s post on how to use these with PyTextile, and here’s my version for Markdown + SmartyPants
c:\cygwin\usr\local\bin\pclip.exe | \
c:\cygwin\bin\perl.exe c:\cygwin\usr\local\bin\Markdown.pl | \
c:\cygwin\bin\perl.exe c:\cygwin\usr\local\bin\SmartyPants.pl | \
c:\cygwin\usr\local\bin\gclip.exe
The gnarly code is due to my choice of paths in Windows.
The code works, sorta, but it doesn’t return DOS line endings
(\r\n). I guess you could hack Markdown to do this.