本文整理汇总了Python中markdown.Markdown.inlinePatterns[pattern]方法的典型用法代码示例。如果您正苦于以下问题:Python Markdown.inlinePatterns[pattern]方法的具体用法?Python Markdown.inlinePatterns[pattern]怎么用?Python Markdown.inlinePatterns[pattern]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类markdown.Markdown
的用法示例。
在下文中一共展示了Markdown.inlinePatterns[pattern]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate
# 需要导入模块: from markdown import Markdown [as 别名]
# 或者: from markdown.Markdown import inlinePatterns[pattern] [as 别名]
def generate(self, body, **options):
"""Override to generate content from Markdown payload.
:param body: payload content.
:type body: str
:return: a tuple of two elements, generated body and metadata
dictionary, respectively.
:rtype: tuple
"""
ext = BlockHtmlFormatterExtension({
'code': CodeBlockHtmlFormatter(css_class=CODE_HIGHLIGHT_CLASS),
'latex': LatexBlockHtmlFormatter()
})
md = Markdown(output_format='html5', extensions=[ext])
if 'relocator' in options:
relocator = options['relocator']
elif 'url' in options:
relocator = ResourceRelocator(options['base'],
url_prefix=options['url'][1:-1])
else:
relocator = ResourceRelocator(options['base'])
recorded_patterns = {
'reference': RelocatingReferencePattern(
REFERENCE_RE, md, relocator),
'link': RelocatingLinkPattern(LINK_RE, md, relocator),
'image_link': RelocatingImagePattern(IMAGE_LINK_RE, md, relocator),
'image_reference': RelocatingImageReferencePattern(
IMAGE_REFERENCE_RE, md, relocator),
'short_reference': RelocatingReferencePattern(
SHORT_REF_RE, md, relocator),
}
for pattern, instance in recorded_patterns.iteritems():
md.inlinePatterns[pattern] = instance
output = md.convert(body)
meta = ext.get_requisites()
meta['local_references'] = relocator.resources
return output, meta