- update документация - промт для ии полу конфигурируемый
This commit is contained in:
+16
-2
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
import docx
|
||||
from docx.document import Document
|
||||
|
||||
@@ -43,7 +45,8 @@ class Converter:
|
||||
toc_mode: str = DEFAULT_TOC_MODE,
|
||||
table_continuation: str = DEFAULT_TABLE_CONTINUATION,
|
||||
listing_continuation: str = DEFAULT_LISTING_CONTINUATION,
|
||||
hr_pagebreak: bool = False):
|
||||
hr_pagebreak: bool = False,
|
||||
styles_path: str | None = None):
|
||||
if heading_numbering not in HEADING_NUMBERING_MODES:
|
||||
raise ValueError(
|
||||
f"heading_numbering must be one of {HEADING_NUMBERING_MODES}, "
|
||||
@@ -71,10 +74,17 @@ class Converter:
|
||||
self._table_continuation = table_continuation
|
||||
self._listing_continuation = listing_continuation
|
||||
self._hr_pagebreak = hr_pagebreak
|
||||
self._styles_path = styles_path
|
||||
self._profile = get_profile(doc_type)
|
||||
self._document: Document = docx.Document(template_path)
|
||||
self._document._body.clear_content()
|
||||
apply_document_styles(self._document, self._profile.style_preset)
|
||||
md_dir = os.path.dirname(os.path.abspath(input_path)) or "."
|
||||
self._style_config = apply_document_styles(
|
||||
self._document,
|
||||
self._profile.style_preset,
|
||||
md_dir=md_dir,
|
||||
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()
|
||||
@@ -123,6 +133,10 @@ class Converter:
|
||||
def document(self) -> Document:
|
||||
return self._document
|
||||
|
||||
@property
|
||||
def style_config(self):
|
||||
return self._style_config
|
||||
|
||||
@property
|
||||
def raw_markdown(self) -> str:
|
||||
return self._raw_markdown
|
||||
|
||||
Reference in New Issue
Block a user