A tool for downloading https://what-if.xkcd.com articles and converting
their contents to Markdown. Python 3.10 or newer is supported.
Create a virtual environment and install the dependencies:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txtpython what_if_parse.py [num]num is optional. If omitted, the latest article is downloaded. Pass all
to download every article, newest first.
See all options with python what_if_parse.py --help.
Generated HTML and Markdown files are written to the current directory and include a timestamp in their names.
Build the image and write generated files into a local output directory:
docker build -t what-if-parse .
mkdir -p output
docker run --rm -v "$PWD/output:/output" what-if-parse 1The container runs as an unprivileged user. On Linux, make sure the mounted directory is writable by that user.
python -m pip install -r requirements-dev.txt
python -m unittest --verbose
ruff check .
docker build -t what-if-parse:test .
docker run --rm what-if-parse:test --helpThe code, documentation and other repository content are in public domain.