Skip to content

Commit

Permalink
Partially revert Docutils' [r9562] to fix epubcheck (#12271)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Apr 12, 2024
1 parent 5d98553 commit 6419d31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ Bugs fixed
* #11970: singlehtml builder: make target URIs to be same-document references in
the sense of :rfc:`RFC 3986, §4.4 <3986#section-4.4>`, e.g., ``index.html#foo``
becomes ``#foo``. Patch by eanorige.
* #12271: Partially revert Docutils' r9562__ to fix EPUB files.
Patch by Adam Turner.

__ https://sourceforge.net/p/docutils/code/9562/

Testing
-------
Expand Down
11 changes: 11 additions & 0 deletions sphinx/writers/html5.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,17 @@ def visit_title(self, node: Element) -> None:
self.add_fignumber(node.parent)
if isinstance(node.parent, nodes.table):
self.body.append('<span class="caption-text">')
# Partially revert https://sourceforge.net/p/docutils/code/9562/
if (
isinstance(node.parent, nodes.topic)
and self.settings.toc_backlinks
and 'contents' in node.parent['classes']
and self.body[-1].startswith('<a ')
# TODO: only remove for EPUB
):
# remove <a class="reference internal" href="#top">
self.body.pop()
self.context[-1] = '</p>\n'

def depart_title(self, node: Element) -> None:
close_tag = self.context[-1]
Expand Down

0 comments on commit 6419d31

Please sign in to comment.