本文整理汇总了Python中markdown.util方法的典型用法代码示例。如果您正苦于以下问题:Python markdown.util方法的具体用法?Python markdown.util怎么用?Python markdown.util使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类markdown
的用法示例。
在下文中一共展示了markdown.util方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import util [as 别名]
def run(self, parent, blocks):
sibling = self.lastChild(parent)
block = blocks.pop(0)
block, theRest = self.detab(block)
block = block.rstrip()
block_is_html = False
if "<div " in block or "</" in block or "<span " in block:
block_is_html = True
if (sibling is not None and sibling.tag == "div"):
# The previous block was a code block. As blank lines do not start
# new code blocks, append this block to the previous, adding back
# linebreaks removed from the split into a list.
block_is_html = block_is_html and not isinstance(sibling.text, AtomicString)
block = u'\n'.join([sibling.text, block])
output = sibling
else:
# This is a new codeblock. Create the elements and insert text.
output = markdown.util.etree.SubElement(parent, 'div', {'class': 'code-output'})
# If not HTML, add the `pre` class so that we know to render output as raw text
if not block_is_html and 'pre' not in output.get('class', 'code-output'):
output.set('class', ' '.join([output.get('class', ''), 'pre']))
output.text = "{}\n".format(block) if block_is_html else AtomicString("{}\n".format(block))
if theRest:
# This block contained unindented line(s) after the first indented
# line. Insert these lines as the first block of the master blocks
# list for future processing.
blocks.insert(0, theRest)
示例2: handleMatch
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import util [as 别名]
def handleMatch(self, m):
node = markdown.util.etree.Element('mathjax')
node.text = markdown.util.AtomicString(m.group(2) + m.group(3) + m.group(2))
return node