本文整理匯總了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}
)