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