v0.5.6
This commit is contained in:
+18
-3
@@ -17,6 +17,7 @@ from docx import Document
|
||||
from . import package_dir
|
||||
from .checker import check_markdown, format_report
|
||||
from .converter import Converter
|
||||
from .office import DEFAULT_OFFICE_ENGINE
|
||||
from .profiles import (
|
||||
DEFAULT_HEADING_NUMBERING,
|
||||
DEFAULT_TABLE_CONTINUATION,
|
||||
@@ -60,6 +61,7 @@ class ConvertRequest:
|
||||
open_when_done: bool = False
|
||||
check_pages: bool = False
|
||||
table_repeat_header: bool = False
|
||||
office_engine: str = DEFAULT_OFFICE_ENGINE
|
||||
# PAGE field start on body section; None = continuous from document start.
|
||||
page_number_start: int | None = None
|
||||
# DOCX File → Info; None = take from md2gost.user.json (see doc_metadata).
|
||||
@@ -425,12 +427,16 @@ def convert(req: ConvertRequest, log: LogFn | None = None) -> ConvertResult:
|
||||
abs_out = os.path.abspath(output)
|
||||
emit(f"Generated document: {abs_out}")
|
||||
|
||||
split_engine: str | None = None
|
||||
split_install = None
|
||||
if req.table_continuation == "word" or req.listing_continuation == "word":
|
||||
from .word_fix import fix_continuations
|
||||
from .office import fix_continuations_with_engine, resolve_office_engine
|
||||
from .page_geometry import patch_docx_page_starts
|
||||
|
||||
fix = fix_continuations(
|
||||
split_engine, split_install = resolve_office_engine(req.office_engine)
|
||||
fix = fix_continuations_with_engine(
|
||||
abs_out,
|
||||
engine=req.office_engine,
|
||||
tables=(req.table_continuation == "word"),
|
||||
listings=(req.listing_continuation == "word"),
|
||||
repeat_header=bool(req.table_repeat_header),
|
||||
@@ -463,7 +469,16 @@ def convert(req: ConvertRequest, log: LogFn | None = None) -> ConvertResult:
|
||||
|
||||
if req.debug or req.open_when_done:
|
||||
try:
|
||||
open_document(abs_out)
|
||||
if split_engine in ("word", "libre", "openoffice"):
|
||||
from .office.open_doc import open_document_with_engine
|
||||
|
||||
open_document_with_engine(
|
||||
abs_out,
|
||||
engine=split_engine,
|
||||
install=split_install,
|
||||
)
|
||||
else:
|
||||
open_document(abs_out)
|
||||
except Exception as exc:
|
||||
emit(f"Не удалось открыть файл: {exc}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user