29 lines
869 B
Python
29 lines
869 B
Python
|
import os
|
||
|
import subprocess
|
||
|
|
||
|
input_dir = "recipes-md"
|
||
|
output_dir = "recipes-mediawiki"
|
||
|
|
||
|
os.makedirs(output_dir, exist_ok=True)
|
||
|
|
||
|
# Process each markdown file in the input directory
|
||
|
for filename in os.listdir(input_dir):
|
||
|
if filename.endswith(".md"):
|
||
|
input_path = os.path.join(input_dir, filename)
|
||
|
output_filename = os.path.splitext(filename)[0] + ".mediawiki"
|
||
|
output_path = os.path.join(output_dir, output_filename)
|
||
|
|
||
|
# Run pandoc command
|
||
|
try:
|
||
|
subprocess.run([
|
||
|
"pandoc",
|
||
|
input_path,
|
||
|
"-f", "markdown",
|
||
|
"-t", "mediawiki",
|
||
|
"-o", output_path
|
||
|
], check=True)
|
||
|
print(f"Converted {filename} to {output_filename}")
|
||
|
except subprocess.CalledProcessError as e:
|
||
|
print(f"Error converting {filename}: {e}")
|
||
|
|