Files
Igor20264 516abe7b83
Python application / build (push) Has been cancelled
BigUpdate
2026-09-03 10:44:08 +03:00

53 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python
"""Пайплайн: MD (диалект md2gost) → Flat ODF Text (.fodt)."""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
from .converter import convert_md_to_fodt
def main() -> None:
p = argparse.ArgumentParser(
prog="md2fodt",
description=(
"Прямой MD → FODT (Flat OpenDocument Text), без Word и LibreOffice. "
"Диалект разметки — как у md2gost."
),
)
p.add_argument("filename", help="Исходный .md")
p.add_argument(
"-o", "--output",
default=None,
help="Путь к .fodt (по умолчанию: <stem>.fodt рядом с md)",
)
p.add_argument(
"--emdash-to-hyphen",
action=argparse.BooleanOptionalAction,
default=False,
help="Заменить «—» на «-» (по умолчанию выкл.)",
)
args = p.parse_args()
md = Path(args.filename)
if not md.is_file():
print(f"Error: file not found: {md}", file=sys.stderr)
sys.exit(1)
if md.suffix.lower() != ".md":
print("Error: filename must end with .md", file=sys.stderr)
sys.exit(1)
out = convert_md_to_fodt(
md,
args.output,
emdash_to_hyphen=args.emdash_to_hyphen,
)
print(f"Generated document: {out}")
if __name__ == "__main__":
main()