本文整理汇总了Python中MoinMoin.Page.Page.formatter方法的典型用法代码示例。如果您正苦于以下问题:Python Page.formatter方法的具体用法?Python Page.formatter怎么用?Python Page.formatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.Page.Page
的用法示例。
在下文中一共展示了Page.formatter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import formatter [as 别名]
def parse(body):
"""Parse body and return html
Create a page with body, then parse it and format using html formatter
"""
assert body is not None
request.reset()
pg = Page(request, 'ThisPageDoesNotExistsAndWillNeverBeReally')
pg.set_raw_body(body)
from MoinMoin.formatter.text_html import Formatter
pg.formatter = Formatter(request)
request.formatter = pg.formatter
pg.formatter.setPage(pg)
pg.hilite_re = None
output = []
# Temporarily replace request.write with custom write function that
# write into our output object.
def write_output(text, o=output):
o.append(text)
saved_write = request.write
request.write = write_output
try:
Parser(body, request).format(pg.formatter)
finally:
request.write = saved_write
return ''.join(output)
示例2: parse
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import formatter [as 别名]
def parse(self, body):
"""Parse body and return html
Create a page with body, then parse it and format using html formatter
"""
request = self.request
assert body is not None
request.reset()
page = Page(request, PAGENAME)
page.hilite_re = None
page.set_raw_body(body)
formatter = HtmlFormatter(request)
formatter.setPage(page)
page.formatter = formatter
request.formatter = formatter
parser = WikiParser(body, request, line_anchors=False)
formatter.startContent("") # needed for _include_stack init
output = request.redirectedOutput(parser.format, formatter)
formatter.endContent("")
return output
示例3: parse
# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import formatter [as 别名]
def parse(self, body):
"""Parse body and return html
Create a page with body, then parse it and format using html formatter
"""
assert body is not None
self.request.reset()
page = Page(self.request, 'ThisPageDoesNotExistsAndWillNeverBeReally')
page.set_raw_body(body)
from MoinMoin.formatter.text_html import Formatter
page.formatter = Formatter(self.request)
self.request.formatter = page.formatter
page.formatter.setPage(page)
page.hilite_re = None
output = StringIO()
saved_write = self.request.write
self.request.write = output.write
try:
Parser(body, self.request).format(page.formatter)
finally:
self.request.write = saved_write
return output.getvalue()