aboutsummaryrefslogblamecommitdiff
path: root/create_adoc.py
blob: c5af711a5dda4e04d32afab66a40abfbebcedda9 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                   
                                                                                                                      








                                                                                    
import os
from pathlib import Path
import subprocess

source_dir = Path("./content")
target_dir = Path("./public/text")

for md_path in source_dir.rglob("*.md"):
    relative_path = md_path.relative_to(source_dir)
    target_path = str(target_dir / relative_path.with_suffix(".txt")).replace("/index", "").replace("_index", "index")
    print(target_path)
    # Создать все необходимые каталоги
    Path(target_path).parent.mkdir(parents=True, exist_ok=True)
    
    # Преобразовать файл из Markdown в AsciiDoc
    subprocess.run(
        ["pandoc", "-f", "markdown", "-t", "ansi", str(md_path), "-o", target_path],
        check=True,
    )