To MediaWiki python script
This commit is contained in:
parent
197f9bb4b0
commit
20cd0dce8d
30
to_mediawiki.py
Normal file
30
to_mediawiki.py
Normal file
@ -0,0 +1,30 @@
|
||||
import pandoc, sys
|
||||
|
||||
pandoc.PANDOC_PATH = '/usr/bin/pandoc'
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.stderr.write("USAGE: to_mediawiki.py path/to/chapter.md")
|
||||
sys.exit(-1)
|
||||
|
||||
sys.stderr.write("Reading from " + sys.argv[1] + "\n")
|
||||
|
||||
ifile = open(sys.argv[1])
|
||||
input_t = ""
|
||||
for line in ifile.readlines():
|
||||
if len(line.strip()) > 0 and line.strip()[len(line.strip()) - 1] == "\\":
|
||||
sys.stderr.write("found 1!\n")
|
||||
line = line.strip("\n").strip("\\")
|
||||
line += "<br />\n"
|
||||
input_t += line
|
||||
|
||||
doc = pandoc.Document()
|
||||
|
||||
input_t = input_t.replace("{% highlight lua %}", "<pre>")
|
||||
input_t = input_t.replace("{% endhighlight %}", "</pre>")
|
||||
input_t = input_t.replace("{{ page.root }}/static/", "modding_book_")
|
||||
input_t = input_t.replace("{{ page.root }}", "")
|
||||
|
||||
doc.markdown = input_t
|
||||
|
||||
sys.stdout.write("{{ ModdingBook }}\n\n")
|
||||
sys.stdout.write(doc.mediawiki)
|
Loading…
Reference in New Issue
Block a user