Fix #10121: html: <div> tag for admonition is not closed w/ docutils-0.18

Since v0.18, docutils has output <aside> tag to represent admonitions.
On the other hand, our custom HTML Writer overrides the handler for
admonition nodes halfly.  As a result, the opening and closing tags
become mismatched.  This fully overrides the handler to use <div> tag to
represent admonitions.
This commit is contained in:
Takeshi KOMIYA 2022-01-26 21:09:48 +09:00
parent 2be0630951
commit 5be4f47d85
2 changed files with 8 additions and 2 deletions

View File

@ -14,7 +14,7 @@ import posixpath
import re
import urllib.parse
import warnings
from typing import TYPE_CHECKING, Iterable, Tuple, cast
from typing import TYPE_CHECKING, Iterable, Optional, Tuple, cast
from docutils import nodes
from docutils.nodes import Element, Node, Text
@ -285,6 +285,9 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
node.insert(0, nodes.title(name, admonitionlabels[name]))
self.set_first_last(node)
def depart_admonition(self, node: Optional[Element] = None) -> None:
self.body.append('</div>\n')
def visit_seealso(self, node: Element) -> None:
self.visit_admonition(node, 'seealso')

View File

@ -13,7 +13,7 @@ import posixpath
import re
import urllib.parse
import warnings
from typing import TYPE_CHECKING, Iterable, Set, Tuple, cast
from typing import TYPE_CHECKING, Iterable, Optional, Set, Tuple, cast
from docutils import nodes
from docutils.nodes import Element, Node, Text
@ -259,6 +259,9 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
if name:
node.insert(0, nodes.title(name, admonitionlabels[name]))
def depart_admonition(self, node: Optional[Element] = None) -> None:
self.body.append('</div>\n')
def visit_seealso(self, node: Element) -> None:
self.visit_admonition(node, 'seealso')