Wiki -> Markdown converting
This commit is contained in:
parent
f42ee7010d
commit
0611c5ad29
23
convert_markdown.py
Normal file
23
convert_markdown.py
Normal file
@ -0,0 +1,23 @@
|
||||
from os import listdir
|
||||
from os.path import isfile, join
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
# argv[1] - wiki files directory
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Argument missing. Usage: python3 moin_convert.py <wiki content dir>")
|
||||
else:
|
||||
path = sys.argv[1]
|
||||
if os.path.exists(path):
|
||||
files = [ f for f in listdir(path) if isfile(join(path, f)) ]
|
||||
for filename in files:
|
||||
name, file_extension = os.path.splitext(filename)
|
||||
if file_extension == ".txt":
|
||||
print("Converting %s/%s" % (path, filename))
|
||||
options = ['pandoc','-f','mediawiki','-t','markdown','-s',join(path,filename),'-o',join(path,name + ".md")]
|
||||
subprocess.call(options)
|
||||
else:
|
||||
print("Error: the path specified is invalid")
|
||||
|
Loading…
Reference in New Issue
Block a user