From ec9a9f5f2cfd222b74427bdcea7d8fa18572cc30 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 2 Mar 2022 12:34:32 +0000 Subject: [PATCH] pep2html: New Post-History handling --- pep2html.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pep2html.py b/pep2html.py index ba0ec100ba9..5f2f565a90f 100755 --- a/pep2html.py +++ b/pep2html.py @@ -493,6 +493,25 @@ def apply(self): para[:] = [nodes.reference('', pep_type, refuri=uri)] elif name == 'version' and len(body): utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions) + elif name == 'post-history': + new_nodes = [] + for pair in body.astext().split(","): + pair = pair.strip() + try: + # if Post-History has no links, ``pair.split(maxsplit=1)`` + # will raise ValueError + date, uri = pair.split(maxsplit=1) + node = nodes.reference("", + date.strip(), + refuri=uri.strip(" \n\r\t><"), + internal=False, + ) + except ValueError: + node = nodes.Text(pair) + + new_nodes += [node, nodes.Text(", ")] + + body[0][:] = new_nodes[:-1] # remove final ', ' class PEPFooter(Transform):