File tree Expand file tree Collapse file tree
pep_sphinx_extensions/pep_processor/transforms Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ def apply(self) -> None:
9292 elif name in {"last-modified" , "content-type" , "version" }:
9393 # Mark unneeded fields
9494 fields_to_remove .append (field )
95+ elif name in {"post-history" }:
96+ body [0 ][:] = _process_post_history (body )
9597
9698 # Remove unneeded fields
9799 for field in fields_to_remove :
@@ -115,3 +117,24 @@ def _pretty_thread(text: nodes.Text) -> nodes.Text:
115117 except ValueError :
116118 # archives and pipermail not in list, e.g. PEP 245
117119 return text
120+
121+
122+ def _process_post_history (body : nodes .field_body ) -> list [nodes .Text | nodes .reference ]:
123+ new_nodes = []
124+ for pair in body .astext ().split ("," ):
125+ pair = pair .strip ()
126+ try :
127+ # if Post-History has no links, ``pair.split(maxsplit=1)``
128+ # will raise ValueError
129+ date , uri = pair .split (maxsplit = 1 )
130+ node = nodes .reference ("" ,
131+ date .strip (),
132+ refuri = uri .strip (" \f \n \r \t ><" ),
133+ internal = False
134+ )
135+ except ValueError :
136+ node = nodes .Text (pair )
137+
138+ new_nodes += [node , nodes .Text (", " )]
139+
140+ return new_nodes [:- 1 ] # remove final ', '
You can’t perform that action at this time.
0 commit comments