Teh Code and other details
import urllib.request as request import json print('This is "XKCD comic markdownifier for Stack Exchange."') print('(Note that I\'m not affiliated with XKCD or Stack Exchange in anyway.)') print('The posting of the code is at http://meta.stackexchange.com/q/263514/177681.') print('This code will format an XKCD comic so it may be posted to Stack Exchange.') num = input('What is the number of the comic?') req = request.urlopen('https://xkcd.com/%s/info.0.json' % num) str_response = req.read() obj = json.loads(str_response) print('[![%(title)s](%(img)s "%(alt)s")](https://www.xkcd.com/%(num)s)' % obj)
The current format is
[![Title](imageUrl "Title Text")](comicUrl)].
This for example, when given
[![Barrel - Part 1](https://imgs.xkcd.com/comics/barrel_cropped_(1).jpg "Don't we all.")](https://www.xkcd.com/1).
You can fork it here.
At the moment, you need to manually escape parentheses and such in the markdown. Luckily, this is usually unnecessary. Also, when run on bad input, it will through a syntax error (somehow.)
What do you guys think? Is it a good format? If you have any modifications, feel free to post it (although make sure it works as a runnable snippet. trinket.io is finky). String escaping would be nice. Error checking would also be nice.