This script is a little untidy, but it works. You can try it out on existing markdown files in the repo.