Update 0.4.0
Python application / build (push) Has been cancelled

- Add\Rework UI
- Add Split Table and Listing
- Add Support Customazeble schems
This commit is contained in:
Igor20264
2026-09-04 22:28:39 +03:00
parent 516abe7b83
commit b38661f588
70 changed files with 69532 additions and 413 deletions
+20 -3
View File
@@ -15,7 +15,9 @@ from .profiles import (
DEFAULT_TOC_MODE,
TOC_MODES,
DEFAULT_TABLE_CONTINUATION,
DEFAULT_LISTING_CONTINUATION,
TABLE_CONTINUATION_MODES,
LISTING_CONTINUATION_MODES,
)
from .label_pass import (
assign_numbers,
@@ -26,6 +28,8 @@ from .label_pass import (
from .renderable.heading import Heading
from .renderable.toc import ToC
from .renderable.table import Table
from .renderable.listing import Listing
from .renderable.diagram import DiagramFigure
class Converter:
@@ -33,11 +37,13 @@ class Converter:
def __init__(self, input_path: str, output_path: str,
template_path: str = None, debug: bool = False,
doc_type: str = "coursework",
doc_type: str = "practice",
heading_numbering: str = DEFAULT_HEADING_NUMBERING,
emdash_to_hyphen: bool = False,
toc_mode: str = DEFAULT_TOC_MODE,
table_continuation: str = DEFAULT_TABLE_CONTINUATION):
table_continuation: str = DEFAULT_TABLE_CONTINUATION,
listing_continuation: str = DEFAULT_LISTING_CONTINUATION,
hr_pagebreak: bool = False):
if heading_numbering not in HEADING_NUMBERING_MODES:
raise ValueError(
f"heading_numbering must be one of {HEADING_NUMBERING_MODES}, "
@@ -52,12 +58,19 @@ class Converter:
f"table_continuation must be one of {TABLE_CONTINUATION_MODES}, "
f"got {table_continuation!r}"
)
if listing_continuation not in LISTING_CONTINUATION_MODES:
raise ValueError(
f"listing_continuation must be one of {LISTING_CONTINUATION_MODES}, "
f"got {listing_continuation!r}"
)
self._output_path = output_path
self._doc_type = doc_type
self._heading_numbering = heading_numbering
self._emdash_to_hyphen = emdash_to_hyphen
self._toc_mode = toc_mode
self._table_continuation = table_continuation
self._listing_continuation = listing_continuation
self._hr_pagebreak = hr_pagebreak
self._profile = get_profile(doc_type)
self._document: Document = docx.Document(template_path)
self._document._body.clear_content()
@@ -67,7 +80,7 @@ class Converter:
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)
self.parser = Parser(self._document, self._preprocessed, hr_pagebreak=hr_pagebreak)
def convert(self):
renderables = list(self.parser.parse())
@@ -85,6 +98,10 @@ class Converter:
r.set_toc_mode(self._toc_mode)
elif isinstance(r, Table):
r.set_continuation_mode(self._table_continuation)
elif isinstance(r, Listing):
r.set_continuation_mode(self._listing_continuation)
elif isinstance(r, DiagramFigure) and r.listing:
r.listing.set_continuation_mode(self._listing_continuation)
formula_refs = find_formula_refs(self._raw_markdown)
registry = assign_numbers(