summaryrefslogtreecommitdiff
path: root/sphinx/writers/manpage.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-07-07 02:09:50 +0900
committerGitHub <noreply@github.com>2021-07-07 02:09:50 +0900
commit5e5bca98f752cb61c36afc7955183e79a6095cf2 (patch)
tree66fc9448a4bbab736469fdad514dfa970787d495 /sphinx/writers/manpage.py
parent988a79de65737e403cd27721ce091760cf62b97f (diff)
parentf0fef96906d80d89e290a780767a92ba85977733 (diff)
downloadsphinx-git-5e5bca98f752cb61c36afc7955183e79a6095cf2.tar.gz
Merge branch '4.x' into 6525_linkcheck_warn_redirects
Diffstat (limited to 'sphinx/writers/manpage.py')
-rw-r--r--sphinx/writers/manpage.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py
index 3f0eea5eb..95e0f5658 100644
--- a/sphinx/writers/manpage.py
+++ b/sphinx/writers/manpage.py
@@ -59,13 +59,16 @@ class NestedInlineTransform:
for node in self.document.traverse(matcher): # type: TextElement
if any(matcher(subnode) for subnode in node):
pos = node.parent.index(node)
- for subnode in reversed(node[1:]):
+ for subnode in reversed(list(node)):
node.remove(subnode)
if matcher(subnode):
node.parent.insert(pos + 1, subnode)
else:
newnode = node.__class__('', '', subnode, **node.attributes)
node.parent.insert(pos + 1, newnode)
+ # move node if all children became siblings of the node
+ if not len(node):
+ node.parent.remove(node)
class ManualPageTranslator(SphinxTranslator, BaseTranslator):