diff --git a/link-peps.py b/link-peps.py new file mode 100755 index 0000000..03765ab --- /dev/null +++ b/link-peps.py @@ -0,0 +1,51 @@ +#! /usr/bin/env python +"""Destructively* link PEPs in the given Markdown document. + +"PEP nnnn" or "PEP nnnn (title)" are converted to "[PEP nnnn](url) (title)". + +* The document is changed "destructively". Make a backup (e.g. `git add`) + before runnig the tool. + +This is just a simple helper for simple cases. Always check its work. +""" + +import re +import fileinput +import urllib.request +import json + +PEP_RE = re.compile( + r''' + (?\d+) # PEP number + \s* # Optional whitespace + ( # Optionally: + \( # parenthesized + (?P