本文整理汇总了Python中docutils.languages.append方法的典型用法代码示例。如果您正苦于以下问题:Python languages.append方法的具体用法?Python languages.append怎么用?Python languages.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.languages
的用法示例。
在下文中一共展示了languages.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: depart_colspec
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def depart_colspec(self, node):
# write out <colgroup> when all colspecs are processed
if isinstance(node.next_node(descend=False, siblings=True),
nodes.colspec):
return
if 'colwidths-auto' in node.parent.parent['classes'] or (
'colwidths-auto' in self.settings.table_style and
('colwidths-given' not in node.parent.parent['classes'])):
return
total_width = sum(node['colwidth'] for node in self.colspecs)
self.body.append(self.starttag(node, 'colgroup'))
for node in self.colspecs:
colwidth = int(node['colwidth'] * 100.0 / total_width + 0.5)
self.body.append(self.emptytag(node, 'col',
style='width: %i%%' % colwidth))
self.body.append('</colgroup>\n')
示例2: visit_entry
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def visit_entry(self, node):
atts = {'class': []}
if isinstance(node.parent.parent, nodes.thead):
atts['class'].append('head')
if node.parent.parent.parent.stubs[node.parent.column]:
# "stubs" list is an attribute of the tgroup element
atts['class'].append('stub')
if atts['class']:
tagname = 'th'
atts['class'] = ' '.join(atts['class'])
else:
tagname = 'td'
del atts['class']
node.parent.column += 1
if 'morerows' in node:
atts['rowspan'] = node['morerows'] + 1
if 'morecols' in node:
atts['colspan'] = node['morecols'] + 1
node.parent.column += node['morecols']
self.body.append(self.starttag(node, tagname, '', **atts))
self.context.append('</%s>\n' % tagname.lower())
# TODO: why does the html4css1 writer insert an NBSP into empty cells?
# if len(node) == 0: # empty cell
# self.body.append(' ') # no-break space
示例3: visit_literal
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def visit_literal(self, node):
# special case: "code" role
classes = node.get('classes', [])
if 'code' in classes:
# filter 'code' from class arguments
node['classes'] = [cls for cls in classes if cls != 'code']
self.body.append(self.starttag(node, 'code', ''))
return
self.body.append(
self.starttag(node, 'span', '', CLASS='docutils literal'))
text = node.astext()
# remove hard line breaks (except if in a parsed-literal block)
if not isinstance(node.parent, nodes.literal_block):
text = text.replace('\n', ' ')
# Protect text like ``--an-option`` and the regular expression
# ``[+]?(\d+(\.\d*)?|\.\d+)`` from bad line wrapping
for token in self.words_and_spaces.findall(text):
if token.strip() and self.sollbruchstelle.search(token):
self.body.append('<span class="pre">%s</span>'
% self.encode(token))
else:
self.body.append(self.encode(token))
self.body.append('</span>')
# Content already processed:
raise nodes.SkipNode
示例4: set_class_on_child
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def set_class_on_child(self, node, class_, index=0):
"""
Set class `class_` on the visible child no. index of `node`.
Do nothing if node has fewer children than `index`.
"""
children = [n for n in node if not isinstance(n, nodes.Invisible)]
try:
child = children[index]
except IndexError:
return
child['classes'].append(class_)
示例5: visit_Text
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def visit_Text(self, node):
text = node.astext()
encoded = self.encode(text)
if self.in_mailto and self.settings.cloak_email_addresses:
encoded = self.cloak_email(encoded)
self.body.append(encoded)
示例6: visit_abbreviation
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def visit_abbreviation(self, node):
# @@@ implementation incomplete ("title" attribute)
self.body.append(self.starttag(node, 'abbr', ''))
示例7: depart_abbreviation
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def depart_abbreviation(self, node):
self.body.append('</abbr>')
示例8: depart_acronym
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def depart_acronym(self, node):
self.body.append('</acronym>')
示例9: visit_address
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def visit_address(self, node):
self.visit_docinfo_item(node, 'address', meta=False)
self.body.append(self.starttag(node, 'pre',
suffix= '', CLASS='address'))
示例10: depart_address
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def depart_address(self, node):
self.body.append('\n</pre>\n')
self.depart_docinfo_item()
示例11: visit_admonition
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def visit_admonition(self, node):
node['classes'].insert(0, 'admonition')
self.body.append(self.starttag(node, 'div'))
示例12: depart_admonition
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def depart_admonition(self, node=None):
self.body.append('</div>\n')
示例13: depart_attribution
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def depart_attribution(self, node):
self.body.append(self.context.pop() + '</p>\n')
示例14: visit_author
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def visit_author(self, node):
if not(isinstance(node.parent, nodes.authors)):
self.visit_docinfo_item(node, 'author')
self.body.append('<p>')
示例15: depart_author
# 需要导入模块: from docutils import languages [as 别名]
# 或者: from docutils.languages import append [as 别名]
def depart_author(self, node):
self.body.append('</p>')
if isinstance(node.parent, nodes.authors):
self.body.append('\n')
else:
self.depart_docinfo_item()