Regarding Markdown

Using nvALT to Convert HTML to Markdown

Recorded on February 26th, 2016

I thought I had a good Workflow action in place to convert web pages to Markdown for storing as text files. But then I tried using it on this article from Medium and it barfed. All it generated was the [Title](URL) construction of the hyperlink.

screenshot of what should be an Medium article converted to Markdown

Then I ran across Macdrifter’s old article about a couple of key tricks nvALT can do, one of which is to convert web pages to Markdown. If you have a URL in your clipboard and press Shift-Command-V, nvALT will create a new note, with the text being a Markdown conversion of the web page from the URL you copied.

screenshot of nvALT's proper Markdown conversion of a Medium web page


The difference is weird, because the Workflow action above uses Brett Terpstra’s awesome heckyesmarkdown service to do the actual conversion, and Brett is one of the creators of nvALT. But I blame Medium because Brett’s service works great almost everywhere else, and we’re all just lucky nvALT exists and has this feature. Since I don’t have a bulletproof way to do this on iOS, I’d rather do all of it on the Mac and know that it’ll work every time than wonder if the Workflow version on iOS is missing something.

I Don’t Get Text Encoding in Editorial/Python

Recorded on February 11th, 2016

For a week, I was using the Editorial FTP Upload workflow from Macdrifter, and then realized yesterday that the text encoding it was doing in this section was converting “>” characters to > entities.

encode_string = cgi.escape(postContent).encode('ascii', 'xmlcharrefreplace')

I think this is what messes up Markdown blockquotes when Statamic renders a page. It also prevents passing any HTML through Markdown, which you’re supposed to be able to do if you need to.

I tried a bunch of stuff, changing the encoding from xmlcharrefreplace to replace or ignore, but I had no idea what I was doing, and tampering with encoding when you don’t know Python seems like a bad idea. In the end, I switched to Gabe’s alternative SFTP Upload, since it accomplishes the same thing but doesn’t confuse Statamic with the encoding.