aboutsummaryrefslogtreecommitdiff
path: root/create_adoc.py
blob: e25da7a72fc873965398a4988e8ae01d43be23d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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", "")
    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,
    )