Markdown link format conversion on iOS

I was chatting with Gabe Weatherhead yesterday about turning SearchLink into a Python script that could then run on Pythonista. That would allow you to copy text from an iOS editor, open Pythonista and run the script, then go back to your editor and paste with your links converted. I’m not sure it’s going to be possible, yet, because I don’t know how iOS and Pythonista handle network connections from scripts. I have a lot to learn.

That being said, it made me start thinking about turning some of my other Markdown Services into scripts I could run on my iPad and iPhone. I searched for a decent Ruby equivalent to Pythonista, but thus far haven’t found anything workable. So, Python it is.

I started the experiment with an existing Python script by Seth Brown called formd. It’s what I’ve been using lately to convert inline Markdown links to references, and vice versa.

I made some adjustments to the script to work with Pythonista, and made a version that takes clipboard input, runs the “flip” routine on it (flips link format depending existing links detected) and puts it back on the clipboard. Here’s a gist of my revised script. If you have Pythonista, you can just paste it into a new script, copy some Markdown to your clipboard and run it. The content of your clipboard should have its link format switched between inline and reference.

I’ll be trudging through converting a few more of my more useful Ruby scripts to Python now. I’m excited about the possibilities of bringing some added convenience to iOS Markdown writing, I just have to figure out what all the limitations are going to be. Time will tell.

Brett Terpstra

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff on Twitter, GitHub, and Mastodon. Keep up with this blog by subscribing in your favorite news reader.

This content is supported by readers like you.