Skip to content

Commit

Permalink
Fix #10121: html: <div> tag for admonition is not closed w/ docutils-…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
tk0miya committed Jan 26, 2022
1 parent 2be0630 commit 5be4f47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sphinx/writers/html.py
Expand Up @@ -14,7 +14,7 @@
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
Expand Down Expand Up @@ -285,6 +285,9 @@ def visit_admonition(self, node: Element, name: str = '') -> None:
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')

Expand Down
5 changes: 4 additions & 1 deletion sphinx/writers/html5.py
Expand Up @@ -13,7 +13,7 @@
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
Expand Down Expand Up @@ -259,6 +259,9 @@ def visit_admonition(self, node: Element, name: str = '') -> None:
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')

Expand Down

0 comments on commit 5be4f47

Please sign in to comment.