本文整理汇总了Python中docutils.nodes.comment方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.comment方法的具体用法?Python nodes.comment怎么用?Python nodes.comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.nodes
的用法示例。
在下文中一共展示了nodes.comment方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_only_nodes
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import comment [as 别名]
def process_only_nodes(config, document, tags):
# type: (nodes.Node, Tags) -> None
"""Filter ``only`` nodes which does not match *tags* or html (through config)"""
ret_html_cell = config['jupyter_allow_html_only']
for node in document.traverse(addnodes.only):
try:
ret = tags.eval_condition(node['expr']) #check for jupyter only
if ret_html_cell and node['expr'] == 'html': #allow html only cells if option is specified
ret = True
except Exception as err:
logger.warning(__('exception while evaluating only directive expression: %s'), err,
location=node)
node.replace_self(node.children or nodes.comment())
else:
if ret:
node.replace_self(node.children or nodes.comment())
else:
# A comment on the comment() nodes being inserted: replacing by [] would
# result in a "Losing ids" exception if there is a target node before
# the only node, so we make sure docutils can transfer the id to
# something, even if it's just a comment and will lose the id anyway...
node.replace_self(nodes.comment())
示例2: apply
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import comment [as 别名]
def apply(self):
if self.document.settings.strip_comments:
for node in self.document.traverse(nodes.comment):
node.parent.remove(node)
示例3: comment
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import comment [as 别名]
def comment(self, match):
if not match.string[match.end():].strip() \
and self.state_machine.is_next_line_blank(): # an empty comment?
return [nodes.comment()], 1 # "A tiny but practical wart."
indented, indent, offset, blank_finish = \
self.state_machine.get_first_known_indented(match.end())
while indented and not indented[-1].strip():
indented.trim_end()
text = '\n'.join(indented)
return [nodes.comment(text, text)], blank_finish
示例4: explicit_construct
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import comment [as 别名]
def explicit_construct(self, match):
"""Determine which explicit construct this is, parse & return it."""
errors = []
for method, pattern in self.explicit.constructs:
expmatch = pattern.match(match.string)
if expmatch:
try:
return method(self, expmatch)
except MarkupError as error:
lineno = self.state_machine.abs_line_number()
message = ' '.join(error.args)
errors.append(self.reporter.warning(message, line=lineno))
break
nodelist, blank_finish = self.comment(match)
return nodelist + errors, blank_finish
示例5: visit_comment
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import comment [as 别名]
def visit_comment(self, node: comment):
"""Begin ``comment`` node.
comment node render as speaker note.
"""
self.body.append('<aside class="notes">\n')
示例6: depart_comment
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import comment [as 别名]
def depart_comment(self, node: comment):
"""End ``comment`` node.
Close speaker note.
"""
self.body.append("</aside>\n")
示例7: authors_from_bullet_list
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import comment [as 别名]
def authors_from_bullet_list(self, field):
authors = []
for item in field[1][0]:
if isinstance(item, nodes.comment):
continue
if len(item) != 1 or not isinstance(item[0], nodes.paragraph):
raise TransformError
authors.append(item[0].children)
if not authors:
raise TransformError
return authors
示例8: authors_from_paragraphs
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import comment [as 别名]
def authors_from_paragraphs(self, field):
for item in field[1]:
if not isinstance(item, (nodes.paragraph, nodes.comment)):
raise TransformError
authors = [item.children for item in field[1]
if not isinstance(item, nodes.comment)]
return authors