在这里详述 ObpLatform/2007-02-06. = SimpleWikiPraser = {{{#!python #coding=utf-8 from MoinMoin.request import RequestCLI, Clock import sys class DUMPClass(object):pass class EmptyRequest(RequestCLI): def __init__(self, output=sys.stdout, url='CLI', pagename='', properties={}): self.output = output self.saved_cookie = '' self.path_info = '/' + pagename self.query_string = '' self.remote_addr = '127.0.0.1' self.is_ssl = 0 self.http_user_agent = 'CLI/Script' self.url = url self.request_method = 'GET' self.request_uri = '/' + pagename # TODO check self.http_host = 'localhost' self.http_referer = '' self.script_name = '.' self.if_modified_since = None self.if_none_match = None self.getText = lambda text: text self.form = '' self.cfg = DUMPClass() self.cfg.siteid = '' self.cfg.caching_formats = [] self.cfg.macro_names = '' self.cfg.bang_meta = None self.cfg.show_section_numbers = False self.cfg.data_underlay_dir = None self.cfg.url_mappings = {} self.hilite_re = None self.page_name = '' self._page_headings = {} self.pragma = {} self.user = DUMPClass() self.user.show_topbottom = False self.current_lang = '' self.content_lang = '' self.clock = Clock() # self.cfg.caching_formats = [] # don't spoil the cache # self.initTheme() # usually request.run() does this, but we don't use it def write(self, *data): """ Write to output stream. """ self.output.write(self.encode(data)) o = file('outmoin.html', 'wb') req = EmptyRequest(o) #from MoinMoin.formatter import text_plain #html_formatter = text_plain.Formatter(req) from MoinMoin.formatter import text_html html_formatter = text_html.Formatter(req) html_formatter.setPage(req) from MoinMoin.parser.wiki import Parser class SimpleWikiParser(Parser): def _word_repl(self, word, text=None): return word text = file('moin.txt').read() text = unicode(text, 'utf-8') parser = SimpleWikiParser(text, req) parser.format(html_formatter) o.close() }}} 这个程序可以用。输入文件为moin.txt,输出为outmoin.html。不过,真正要实现定制输出还要看在哪里加入处理点。宏不能使用。表情图不能使用。