From 23e494dfe9510e0c0fea8c0fc87ace46917bb1b6 Mon Sep 17 00:00:00 2001 From: Jan Breuer Date: Tue, 2 Jan 2024 20:15:24 +0100 Subject: [PATCH] Add ability to localize figure caption Sphinx localization needs node source and line and if it is not present, lozalization step is skipped. --- src/sphinx_subfigure/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sphinx_subfigure/main.py b/src/sphinx_subfigure/main.py index d3b2539..377449c 100644 --- a/src/sphinx_subfigure/main.py +++ b/src/sphinx_subfigure/main.py @@ -79,7 +79,10 @@ def run(self) -> list[nodes.Element]: elif isinstance(child, nodes.paragraph): if has_caption: raise self.error("Invalid subfigure content (multiple captions)") - child.replace_self(nodes.caption(child.rawsource, *child.children)) + caption = nodes.caption(child.rawsource, *child.children) + caption.source = child.source + caption.line = child.line + child.replace_self(caption) has_caption = True else: raise self.error(