BigUpdate 0.5.0
Python application / build (push) Has been cancelled

- add Local Render Mermaid
- add page-starе для указания смещения страниц
- add Гиперссылки в документе на списки литературы
This commit is contained in:
Igor20264
2026-09-07 09:54:33 +03:00
parent ac0aa33399
commit 1a5b35eb54
29 changed files with 4118 additions and 69 deletions
+35
View File
@@ -156,3 +156,38 @@ def ensure_continuous_page_numbers(document) -> None:
# Keep continuous: remove start attribute if present
if child.get(qn("w:start")) is not None:
del child.attrib[qn("w:start")]
def set_section_page_start(section, start: int) -> None:
"""Set w:pgNumType/@w:start so PAGE field begins at ``start`` in this section."""
if start < 1:
return
sect_pr = section._sectPr
pg = sect_pr.find(qn("w:pgNumType"))
if pg is None:
sect_pr.append(create_element("w:pgNumType", {"w:start": str(int(start))}))
else:
pg.set(qn("w:start"), str(int(start)))
def apply_page_number_start(
document,
start: int | None,
*,
front_sections: int = 0,
) -> None:
"""
Apply page-number offset for the body.
``start`` is None / <1 — leave continuous numbering (strip explicit starts).
``start`` >= 1 — first section after front matter restarts PAGE at that number;
later body sections stay continuous from there.
"""
ensure_continuous_page_numbers(document)
if start is None or int(start) < 1:
return
sections = list(document.sections)
idx = max(0, int(front_sections))
if idx >= len(sections):
return
set_section_page_start(sections[idx], int(start))