@@ -0,0 +1,52 @@
|
||||
#!/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()
|
||||
Reference in New Issue
Block a user