本文整理汇总了Python中sphinx.writers.html.SmartyPantsHTMLTranslator类的典型用法代码示例。如果您正苦于以下问题:Python SmartyPantsHTMLTranslator类的具体用法?Python SmartyPantsHTMLTranslator怎么用?Python SmartyPantsHTMLTranslator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SmartyPantsHTMLTranslator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_section
def visit_section(self, node):
'''Give each section a unique ID -- nice for custom CSS hooks'''
old_ids = node.get('ids', [])
node['ids'] = ['s-' + i for i in old_ids]
node['ids'].extend(old_ids)
SmartyPantsHTMLTranslator.visit_section(self, node)
node['ids'] = old_ids
示例2: visit_section
def visit_section(self, node):
old_ids = node.get('ids', [])
node['ids'] = ['s-' + i for i in old_ids]
node['ids'].extend(old_ids)
SmartyPantsHTMLTranslator.visit_section(self, node)
node['ids'] = old_ids
示例3: visit_literal_block
def visit_literal_block(self, node):
self.no_smarty += 1
SmartyPantsHTMLTranslator.visit_literal_block(self, node)
示例4: depart_literal_block
def depart_literal_block(self, node):
SmartyPantsHTMLTranslator.depart_literal_block(self, node)
self.no_smarty -= 1
示例5: __init__
def __init__(self, *args, **kwargs):
SmartyPantsHTMLTranslator.__init__(self, *args, **kwargs)
示例6: __init__
def __init__(self, builder, *args, **kwds):
# HTMLTranslator is an old-style Python class, so 'super' doesn't work: use
# direct parent invocation.
HTMLTranslator.__init__(self, builder, *args, **kwds)
self.within_ignored_h1 = False
self.within_toc = False
示例7: visit_reference
def visit_reference(self, node):
# In "kill_internal_links" mode, we don't emit the actual links for internal
# nodes.
if self.builder.kill_internal_links and node.get('internal'):
pass
else:
HTMLTranslator.visit_reference(self, node)
示例8: visit_title
def visit_title(self, node):
if isinstance(node.parent, nodes.section):
# Steal the id from the parent. This is used in chromesite to handle the
# auto-generated navbar and permalinks.
if node.parent.hasattr('ids'):
node['ids'] = node.parent['ids'][:]
HTMLTranslator.visit_title(self, node)
示例9: visit_topic
def visit_topic(self, node):
if 'contents' in node['classes']:
# TODO(binji):
# Detect a TOC: we want to hide these from chromesite, but still keep
# them in devsite. An easy hack is to add display: none to the element
# here.
# When we remove devsite support, we can remove this hack.
self.within_toc = True
attrs = {'style': 'display: none'}
self.body.append(self.starttag(node, 'div', **attrs))
else:
HTMLTranslator.visit_topic(self, node)
示例10: visit_title
def visit_title(self, node):
# Why this?
#
# Sphinx insists on inserting a <h1>Page Title</h1> into the page, but this
# is not how the devsite wants it. The devsite inserts the page title on
# its own, the the extra h1 is duplication.
#
# Killing the doctree title node in a custom transform doesn't work, because
# Sphinx explicitly looks for it when writing a document. So instead we rig
# the HTML produced.
#
# When a title node is visited, and this is the h1-to-be, we ignore it and
# also set a flag that tells visit_Text not to print the actual text of the
# header.
# The h1 node is in the section whose parent is the document itself. Other
# sections have this top-section as their parent.
if (node.parent and node.parent.parent and
isinstance(node.parent.parent, nodes.document)):
# Internal flag. Also, nothing is pushed to the context. Our depart_title
# doesn't pop anything when this flag is set.
self.within_ignored_h1 = True
else:
HTMLTranslator.visit_title(self, node)
示例11: visit_Text
def visit_Text(self, node):
if not self.within_ignored_h1:
HTMLTranslator.visit_Text(self, node)
示例12: visit_paragraph
def visit_paragraph(self, node):
# Don't generate <p>s within the table of contents
if not self.within_toc:
HTMLTranslator.visit_paragraph(self, node)
示例13: depart_title
def depart_title(self, node):
if not self.within_ignored_h1:
HTMLTranslator.depart_title(self, node)
self.within_ignored_h1 = False
示例14: depart_topic
def depart_topic(self, node):
if self.within_toc:
self.body.append('\n</div>')
else:
HTMLTranslator.visit_topic(self, node)
示例15: depart_reference
def depart_reference(self, node):
if self.builder.kill_internal_links and node.get('internal'):
pass
else:
HTMLTranslator.depart_reference(self, node)