27 lines
820 B
Python
27 lines
820 B
Python
import os
|
|
import subprocess
|
|
from tqdm import tqdm
|
|
|
|
from config import *
|
|
|
|
os.makedirs(OUTDIR_MEDIAWIKI, exist_ok=True)
|
|
|
|
# Process each markdown file in the input directory
|
|
for filename in tqdm(os.listdir(OUTDIR_MARKDOWN)):
|
|
if filename.endswith(".md"):
|
|
input_path = os.path.join(OUTDIR_MARKDOWN, filename)
|
|
output_filename = os.path.splitext(filename)[0] + ".mediawiki"
|
|
output_path = os.path.join(OUTDIR_MEDIAWIKI, output_filename)
|
|
|
|
# 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}")
|
|
|