Skip to content

Commit

Permalink
pep2html: New Post-History handling
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Mar 8, 2022
1 parent bb0368a commit ec9a9f5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pep2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ec9a9f5

Please sign in to comment.