2025-06-01 23:33:03 +02:00
|
|
|
import os
|
|
|
|
import subprocess
|
2025-06-02 01:38:40 +02:00
|
|
|
from tqdm import tqdm
|
2025-06-01 23:33:03 +02:00
|
|
|
|
2025-06-02 21:25:38 +02:00
|
|
|
from config import *
|
2025-06-01 23:33:03 +02:00
|
|
|
input_dir = "recipes-md"
|
|
|
|
|
2025-06-02 21:25:38 +02:00
|
|
|
os.makedirs(OUTDIR_MEDIAWIKI, exist_ok=True)
|
2025-06-01 23:33:03 +02:00
|
|
|
|
|
|
|
# Process each markdown file in the input directory
|
2025-06-02 01:38:40 +02:00
|
|
|
for filename in tqdm(os.listdir(input_dir)):
|
2025-06-01 23:33:03 +02:00
|
|
|
if filename.endswith(".md"):
|
|
|
|
input_path = os.path.join(input_dir, filename)
|
|
|
|
output_filename = os.path.splitext(filename)[0] + ".mediawiki"
|
2025-06-02 21:25:38 +02:00
|
|
|
output_path = os.path.join(OUTDIR_MEDIAWIKI, output_filename)
|
2025-06-01 23:33:03 +02:00
|
|
|
|
|
|
|
# Run pandoc command
|
|
|
|
try:
|
|
|
|
subprocess.run([
|
|
|
|
"pandoc",
|
|
|
|
input_path,
|
|
|
|
"-f", "markdown",
|
|
|
|
"-t", "mediawiki",
|
|
|
|
"-o", output_path
|
|
|
|
], check=True)
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
print(f"Error converting {filename}: {e}")
|
|
|
|
|