Commit d88502d1 authored by Georges Khaznadar's avatar Georges Khaznadar

documented the command

parent 5af54dc6
#! /usr/bin/python3
import subprocess, sys, os
"""
Converts an RST file to Dokuwiki format.
This utility was taylored to feed the collaborative place
https://expeyes.aulaslibres.org
Usage:
./rst2dokuwiki.py somefile.rst
or:
cat somefile.rst | ./rst2dokuwiki.py
This feeds valid dokuwiki code in the standard output.
"""
import subprocess, sys
p = subprocess.Popen(
"pandoc -f rst -t dokuwiki",
......@@ -8,12 +22,13 @@ p = subprocess.Popen(
stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
if len(sys.argv) > 1:
infile=sys.argv[1]
else:
infile=os.stdin
with open(infile) as data:
p.write(data.read())
comment="""\
> Editar y traducir esta página
"""
with (open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin) as data:
p.stdin.write(data.read().encode("utf-8"))
out, err = p.communicate()
os.stdout.write(out)
sys.stdout.write(comment + out.decode("utf-8"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment