本文整理汇总了Python中docutils.writers.html4css1.Writer方法的典型用法代码示例。如果您正苦于以下问题:Python html4css1.Writer方法的具体用法?Python html4css1.Writer怎么用?Python html4css1.Writer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.writers.html4css1
的用法示例。
在下文中一共展示了html4css1.Writer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from docutils.writers import html4css1 [as 别名]
# 或者: from docutils.writers.html4css1 import Writer [as 别名]
def render(raw, stream=None, **kwargs):
if stream is None:
# Use a io.StringIO as the warning stream to prevent warnings from
# being printed to sys.stderr.
stream = io.StringIO()
settings = SETTINGS.copy()
settings["warning_stream"] = stream
writer = Writer()
writer.translator_class = ReadMeHTMLTranslator
try:
parts = publish_parts(raw, writer=writer, settings_overrides=settings)
except SystemMessage:
rendered = None
else:
rendered = parts.get("docinfo", "") + parts.get("fragment", "")
if rendered:
return clean(rendered)
else:
return None
示例2: render
# 需要导入模块: from docutils.writers import html4css1 [as 别名]
# 或者: from docutils.writers.html4css1 import Writer [as 别名]
def render(raw, stream=None):
if stream is None:
# Use a io.StringIO as the warning stream to prevent warnings from
# being printed to sys.stderr.
stream = io.StringIO()
settings = SETTINGS.copy()
settings["warning_stream"] = stream
writer = Writer()
writer.translator_class = ReadMeHTMLTranslator
try:
parts = publish_parts(raw, writer=writer, settings_overrides=settings)
except SystemMessage:
rendered = None
else:
rendered = parts.get("fragment")
if rendered:
return clean(rendered)
else:
return None
示例3: __init__
# 需要导入模块: from docutils.writers import html4css1 [as 别名]
# 或者: from docutils.writers.html4css1 import Writer [as 别名]
def __init__(self):
html4css1.Writer.__init__(self)
self.translator_class = S5HTMLTranslator
示例4: __init__
# 需要导入模块: from docutils.writers import html4css1 [as 别名]
# 或者: from docutils.writers.html4css1 import Writer [as 别名]
def __init__(self):
html4css1.Writer.__init__(self)
self.translator_class = HTMLTranslator
示例5: interpolation_dict
# 需要导入模块: from docutils.writers import html4css1 [as 别名]
# 或者: from docutils.writers.html4css1 import Writer [as 别名]
def interpolation_dict(self):
subs = html4css1.Writer.interpolation_dict(self)
settings = self.document.settings
pyhome = settings.python_home
subs['pyhome'] = pyhome
subs['pephome'] = settings.pep_home
if pyhome == '..':
subs['pepindex'] = '.'
else:
subs['pepindex'] = pyhome + '/dev/peps'
index = self.document.first_child_matching_class(nodes.field_list)
header = self.document[index]
self.pepnum = header[0][1].astext()
subs['pep'] = self.pepnum
if settings.no_random:
subs['banner'] = 0
else:
import random
subs['banner'] = random.randrange(64)
try:
subs['pepnum'] = '%04i' % int(self.pepnum)
except ValueError:
subs['pepnum'] = self.pepnum
self.title = header[1][1].astext()
subs['title'] = self.title
subs['body'] = ''.join(
self.body_pre_docinfo + self.docinfo + self.body)
return subs
示例6: assemble_parts
# 需要导入模块: from docutils.writers import html4css1 [as 别名]
# 或者: from docutils.writers.html4css1 import Writer [as 别名]
def assemble_parts(self):
html4css1.Writer.assemble_parts(self)
self.parts['title'] = [self.title]
self.parts['pepnum'] = self.pepnum
示例7: __init__
# 需要导入模块: from docutils.writers import html4css1 [as 别名]
# 或者: from docutils.writers.html4css1 import Writer [as 别名]
def __init__(self):
html4css1.Writer.__init__(self)
self.translator_class = self._CustomHTMLTranslator
示例8: _render_html
# 需要导入模块: from docutils.writers import html4css1 [as 别名]
# 或者: from docutils.writers.html4css1 import Writer [as 别名]
def _render_html(source):
return core.publish_parts(
source=source,
writer=Writer(),
writer_name='html',
settings_overrides={'no_system_messages': True}
)