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
+49
View File
@@ -201,6 +201,15 @@ def test_preprocess_skips_uml_and_mermaid_fences():
"```\n\n"
"```uml-c4context\n"
'Person(user, "Заявитель")\n'
"```\n\n"
"```idef0\n"
'title "Выручка"\n'
"[A0] Процесс\n"
"```\n\n"
"```dfd\n"
'entity User\n'
'process App\n'
'User --> App "request"\n'
"```\n"
)
out = preprocess_markdown(md)
@@ -209,6 +218,10 @@ def test_preprocess_skips_uml_and_mermaid_fences():
assert 'title "Выручка"' in out
assert 'Person(user, "Заявитель")' in out
assert "«Акционеры»" not in out
assert "[A0] Процесс" in out
assert "entity User" in out
assert 'User --> App "request"' in out
assert "«request»" not in out
def test_formula_refs():
@@ -247,6 +260,42 @@ def test_biblio_entries_from_concatenated_paragraph():
assert flat[0].key == "1"
def test_fold_bibliography_drops_citation_mangled_residue():
"""Citation linking turns [5]: into []: in .text — must still be consumed."""
import docx
from md2gost.biblio_processor import (
fold_bibliography,
is_biblio_source_paragraph,
)
from md2gost.bibliography_renderable import Bibliography
from md2gost.renderable.heading import Heading
from md2gost.renderable.paragraph import Paragraph
assert is_biblio_source_paragraph("[1]: Книга. — М., 2024.")
assert is_biblio_source_paragraph("[]: Книга. — М., 2024.")
assert is_biblio_source_paragraph("[]: https://example.com/a")
assert not is_biblio_source_paragraph("Обычный абзац без источника.")
doc = docx.Document(r"md2gost/Template.docx")
doc._body.clear_content()
h = Heading(doc._body, 1, numbered=False)
h.add_run("СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ")
residue = Paragraph(doc._body)
residue.add_run("[]: Остаток после гиперссылки на цитату.")
prose = Paragraph(doc._body)
prose.add_run("Это уже не библиография.")
md = """# *СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ
[1]: Книга. — М., 2024.
"""
out = fold_bibliography([h, residue, prose], doc._body, raw_markdown=md)
types = [type(x).__name__ for x in out]
assert types == ["Heading", "Bibliography", "Paragraph"]
assert isinstance(out[1], Bibliography)
assert out[2] is prose
def test_emdash_to_hyphen_preprocess():
from md2gost.profiles import preprocess_markdown, set_emdash_to_hyphen, dash_separator
out = preprocess_markdown("Цель — тест. Слово - слово.", emdash_to_hyphen=True)