50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
"""Smoke tests for MD → LaTeX emitter."""
|
|
|
|
from pathlib import Path
|
|
|
|
from md2latex.emitter import emit_document
|
|
from md2latex.converter import convert_md_to_latex_project
|
|
|
|
|
|
SAMPLE = """\
|
|
# *СОДЕРЖАНИЕ
|
|
[TOC]
|
|
|
|
# *ВВЕДЕНИЕ
|
|
|
|
См. @Таблица:cmp.
|
|
|
|
%cmp Сравнение
|
|
|
|
| A | B |
|
|
|---|---|
|
|
| 1 | 2 |
|
|
| 3 | 4 |
|
|
|
|
# *СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ
|
|
|
|
[1]: Иванов И. И. Книга. — М., 2024.
|
|
"""
|
|
|
|
|
|
def test_emit_longtable_continuation_headers(tmp_path):
|
|
tex = emit_document(SAMPLE, work_dir=tmp_path, images_dir=tmp_path / "Images")
|
|
assert r"\begin{longtable}" in tex
|
|
assert r"\endfirsthead" in tex
|
|
assert r"\endhead" in tex
|
|
assert "Продолжение таблицы" in tex
|
|
assert r"\label{tab:cmp}" in tex
|
|
assert r"\begin{thebibliography}" in tex
|
|
|
|
|
|
def test_convert_project(tmp_path):
|
|
md = tmp_path / "t.md"
|
|
md.write_text(SAMPLE, encoding="utf-8")
|
|
out = tmp_path / "proj"
|
|
main = convert_md_to_latex_project(md, out)
|
|
assert main.is_file()
|
|
assert (out / "content.tex").is_file()
|
|
assert (out / "Settings" / "packages.tex").is_file()
|
|
body = (out / "content.tex").read_text(encoding="utf-8")
|
|
assert "longtable" in body
|