There was some good response to the last post (in which Markdown was introduced and we were shown how to install and process Markdown from within TextWrangler). So let’s keep this Markdown train a’rollin’ by discussing how to get back to Markdown from HTML.
Conceptually speaking, the Markdown script simply takes a specially formatted text document (that’s the Markdown, duh!) and converts it to HTML, right? So conceptually speaking, it should be possible to take HTML and convert it back to Markdown, right? Conceptually speaking, of course. This script, html2text by Aaron Swartz does just that: it converts HTML to Markdown. And you install it in TextWrangler in the same way as we did with the Markdown script. Need a refresher?
- First, download it:
https://github.com/aaronsw/html2text/zipball/master - Then, unzip it.
- Next, take the file,
html2text.pyand put it here:/Users/YOU/Library/Application Support/TextWrangler/Unix Support/Unix Filters/(replace YOU with the name of your OS X user account). - Now slap some HTML into TextWrangler and, in the menubar, navigate to
#! > Unix Filters > html2text.py. And behold! Your HTML becomes Markdown!
Brilliant, right? Now you can bounce from Markdown to HTML and then back to Markdown…
Worth noting, the Markdown that you’ll get from the html2text script has a specific formatting style associated with it. Some things are tabbed in, the links are at the bottom of the document, etc… No need to worry though, it’s all valid Markdown.
Also worth noting, the developer of html2text has added a few user modifiable parameters to the script (wasn’t that nice of him?). If you crack it open in TextWrangler (or the plain text editor of your choice), you’ll see the parameter settings start at around line 38. I’d suggest changing BODY_WIDTH to 0 to disable hard wrapping long lines at a set character position (this setting can be found on line 45).
You’re becoming quite the web writing ninja… ain’tchya?






