v0.5.3
Example document / build (push) Has been cancelled
Python application / build (push) Has been cancelled

- Мелкие исправления увеличивающие работу конвертера
This commit is contained in:
Igor20264
2026-09-10 10:50:15 +03:00
parent 510f7e7adf
commit e6b58efeb3
95 changed files with 7165 additions and 8771 deletions
+17 -4
View File
@@ -79,6 +79,7 @@ class Image(Renderable, RequiresNumbering):
logging.warning("SVG blip attach failed (%s): %s", svg_path, exc)
self._number = None
self._caption: Caption | None = None
self.landscape = bool(caption_info and caption_info.landscape)
if caption_info and caption_info.unique_name:
self.unique_name = caption_info.unique_name
@@ -89,6 +90,21 @@ class Image(Renderable, RequiresNumbering):
def set_number(self, number: str):
self._number = number
self._caption = None
def _get_caption(self) -> Caption:
"""One caption object per figure.
Paragraph.render() lays a figure out once to learn its height and the
Renderer then renders it for real; a shared caption keeps the second
pass from re-measuring the same line.
"""
if self._caption is None:
self._caption = Caption(
self._parent, "Рисунок", self._caption_info, self._number, False
)
self._caption.center()
return self._caption
def _reset_native_size(self) -> None:
if self._image is None or self._native_width is None or self._native_height is None:
@@ -142,7 +158,4 @@ class Image(Renderable, RequiresNumbering):
layout_state.add_height(rendered_image.height)
caption = Caption(self._parent, "Рисунок", self._caption_info, self._number, False)
caption.center()
yield from caption.render(rendered_image, copy(layout_state))
yield from self._get_caption().render(rendered_image, copy(layout_state))