本文整理汇总了Python中docutils.nodes.math_block方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.math_block方法的具体用法?Python nodes.math_block怎么用?Python nodes.math_block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.nodes
的用法示例。
在下文中一共展示了nodes.math_block方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_Text
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import math_block [as 别名]
def visit_Text(self, node):
parent = node.parent
while parent:
if isinstance(parent, node_blacklist):
return
parent = parent.parent
rawtext = node.rawsource
data = rawtext.split("@@")
if len(data) == 1:
return
nodes = []
for i in range(len(data)):
text = data[i]
if i % 2 == 0:
nodes.append(Text(text))
else:
formula = eval(text, pygrim.__dict__)
latex = formula.latex()
#nodes.append(literal(text, text))
nodes.append(math(latex, Text(latex)))
#nodes.append(math_block(latex, Text(latex)))
node.parent.replace(node, nodes)
示例2: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import math_block [as 别名]
def run(self):
set_classes(self.options)
self.assert_has_content()
# join lines, separate blocks
content = '\n'.join(self.content).split('\n\n')
nodes = []
for block in content:
nodes.append(Text("Input: "))
nodes.append(literal(block, Text(block)))
formula = eval(block, pygrim.__dict__)
latex = formula.latex()
latex = "$$" + latex + "$$"
node = math_block(latex, Text(latex), **self.options)
node.attributes['nowrap'] = True
nodes.append(node)
return nodes
'''
for block in content:
if not block:
continue
print("DUMB", type(self.block_text), type(block))
#node = nodes.math_block(self.block_text, Text(block), **self.options)
#node.line = self.content_offset + 1
#self.add_name(node)
_nodes.append(Text(self.block_text))
#_nodes.append(node)
return _nodes
'''
示例3: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import math_block [as 别名]
def run(self):
set_classes(self.options)
self.assert_has_content()
# join lines, separate blocks
content = '\n'.join(self.content).split('\n\n')
_nodes = []
for block in content:
if not block:
continue
node = nodes.math_block(self.block_text, block, **self.options)
node.line = self.content_offset + 1
self.add_name(node)
_nodes.append(node)
return _nodes