2012-06-19 23:22:44 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: iso-8859-1 -*-
|
|
|
|
from MoinMoin import wikimacro, wikiutil
|
|
|
|
from MoinMoin.Page import Page
|
|
|
|
from MoinMoin.parser.wiki import Parser
|
|
|
|
|
|
|
|
from text_dokuwiki import Formatter
|
|
|
|
from MoinMoin.request import RequestCLI
|
|
|
|
|
2012-09-16 19:40:02 +02:00
|
|
|
import sys
|
|
|
|
import StringIO
|
|
|
|
|
|
|
|
def moin2doku(pagename, text):
|
|
|
|
parser = Parser(text, request)
|
|
|
|
|
|
|
|
# this needed for macros
|
|
|
|
request.formatter = formatter
|
2012-06-19 23:22:44 +02:00
|
|
|
|
2012-09-16 19:40:02 +02:00
|
|
|
p = Page(request, pagename)
|
|
|
|
formatter.setPage(p)
|
2012-06-19 23:22:44 +02:00
|
|
|
|
2012-09-16 19:40:02 +02:00
|
|
|
output = StringIO.StringIO()
|
2012-06-19 23:22:44 +02:00
|
|
|
|
2012-09-16 19:40:02 +02:00
|
|
|
# wrap sys.stdout as RequestCLI has no interface to say where to output
|
|
|
|
stdout = sys.stdout
|
|
|
|
sys.stdout = output
|
|
|
|
parser.format(formatter)
|
|
|
|
sys.stdout = stdout
|
2012-06-19 23:22:44 +02:00
|
|
|
|
2012-09-16 19:40:02 +02:00
|
|
|
return output.getvalue()
|
|
|
|
|
|
|
|
request = RequestCLI()
|
|
|
|
formatter = Formatter(request)
|
2012-06-19 23:22:44 +02:00
|
|
|
|
2012-09-16 19:40:02 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
# pages/playground\(2f\)SyntaxReference/revisions/00000001
|
|
|
|
with open('syntaxreference.txt', 'r') as f:
|
|
|
|
text = f.read()
|
|
|
|
print moin2doku('test', text)
|