[UPDATE] рефакторинг: Unicode -> ASCII, README на русском, форматирование

- Unicode стрелки (->) -> ASCII (->)
- Добавлен README.md на русском языке
- from __future__ import annotations во всех файлах
- Исправлены ошибки mypy (Callable[..., str], Token import)
- make format + make tidy проходят чисто
This commit is contained in:
Arseny
2026-07-16 09:00:24 +03:00
parent 59ba0555bb
commit c116d7d9af
12 changed files with 138 additions and 40 deletions
+18 -8
View File
@@ -18,9 +18,15 @@ def _print_latex_errors(log_path: Path) -> None:
def run_xelatex(tex_path: Path, output_dir: Path) -> bool:
result = subprocess.run(
["xelatex", "-interaction=nonstopmode",
"-output-directory", str(output_dir), str(tex_path)],
capture_output=True, text=True,
[
"xelatex",
"-interaction=nonstopmode",
"-output-directory",
str(output_dir),
str(tex_path),
],
capture_output=True,
text=True,
)
pdf_path = output_dir / tex_path.with_suffix(".pdf").name
return pdf_path.exists() and result.returncode == 0
@@ -29,15 +35,19 @@ def run_xelatex(tex_path: Path, output_dir: Path) -> bool:
def main() -> None:
cli = argparse.ArgumentParser(
prog="md2gost",
description="Markdown LaTeX конвертер по ГОСТ Р 7.0.5-2008",
description="Markdown -> LaTeX конвертер по ГОСТ Р 7.0.5-2008",
)
cli.add_argument("input", type=Path, help="путь к .md файлу")
cli.add_argument(
"-o", "--output", type=Path, default=Path("."),
"-o",
"--output",
type=Path,
default=Path("."),
help="выходная директория (по умолчанию текущая)",
)
cli.add_argument(
"--no-pdf", action="store_true",
"--no-pdf",
action="store_true",
help="только .tex, без компиляции в PDF",
)
args = cli.parse_args()
@@ -62,7 +72,7 @@ def main() -> None:
final_tex = args.output / tex_name
shutil.copy2(tex_path, final_tex)
print(f" {final_tex}")
print(f"-> {final_tex}")
if not args.no_pdf:
if not run_xelatex(tex_path, cache_dir):
@@ -79,7 +89,7 @@ def main() -> None:
pdf_path = cache_dir / pdf_name
final_pdf = args.output / pdf_name
shutil.copy2(pdf_path, final_pdf)
print(f" {final_pdf}")
print(f"-> {final_pdf}")
if __name__ == "__main__":