v0.5.2
Python application / build (push) Waiting to run

Что то сделал
This commit is contained in:
Igor20264
2026-09-08 19:37:54 +03:00
parent 1a5b35eb54
commit 510f7e7adf
90 changed files with 11720 additions and 5547 deletions
+8 -3
View File
@@ -46,7 +46,8 @@ class Converter:
table_continuation: str = DEFAULT_TABLE_CONTINUATION,
listing_continuation: str = DEFAULT_LISTING_CONTINUATION,
hr_pagebreak: bool = False,
styles_path: str | None = None):
styles_path: str | None = None,
markdown_text: str | None = None):
if heading_numbering not in HEADING_NUMBERING_MODES:
raise ValueError(
f"heading_numbering must be one of {HEADING_NUMBERING_MODES}, "
@@ -79,6 +80,7 @@ class Converter:
self._document: Document = docx.Document(template_path)
self._document._body.clear_content()
md_dir = os.path.dirname(os.path.abspath(input_path)) or "."
os.environ["WORKING_DIR"] = md_dir
self._style_config = apply_document_styles(
self._document,
self._profile.style_preset,
@@ -86,8 +88,11 @@ class Converter:
styles_path=styles_path,
)
self._debugger = Debugger(self._document) if debug else None
with open(input_path, encoding="utf-8") as f:
raw = f.read()
if markdown_text is not None:
raw = markdown_text
else:
with open(input_path, encoding="utf-8") as f:
raw = f.read()
self._raw_markdown = raw
self._preprocessed = preprocess_markdown(raw, emdash_to_hyphen=emdash_to_hyphen)
self.parser = Parser(self._document, self._preprocessed, hr_pagebreak=hr_pagebreak)