Skip to content

Commit

Permalink
Merge pull request #9724 from tk0miya/support_PreBibliographic_nodes
Browse files Browse the repository at this point in the history
Support docutils-0.18: allow PreBibliographic nodes before docinfo
  • Loading branch information
tk0miya committed Oct 22, 2021
2 parents cc85aef + 8118f97 commit cf96c93
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sphinx/environment/collectors/metadata.py
Expand Up @@ -33,9 +33,12 @@ def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
Keep processing minimal -- just return what docutils says.
"""
if len(doctree) > 0 and isinstance(doctree[0], nodes.docinfo):
index = doctree.first_child_not_matching_class(nodes.PreBibliographic)
if index is None:
return
elif isinstance(doctree[index], nodes.docinfo):
md = app.env.metadata[app.env.docname]
for node in doctree[0]:
for node in doctree[index]: # type: ignore
# nodes are multiply inherited...
if isinstance(node, nodes.authors):
authors = cast(List[nodes.author], node)
Expand All @@ -58,7 +61,7 @@ def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
value = 0
md[name] = value

doctree.pop(0)
doctree.pop(index)


def setup(app: Sphinx) -> Dict[str, Any]:
Expand Down

0 comments on commit cf96c93

Please sign in to comment.