本文整理汇总了Python中markdown.extensions.Extension方法的典型用法代码示例。如果您正苦于以下问题:Python extensions.Extension方法的具体用法?Python extensions.Extension怎么用?Python extensions.Extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类markdown.extensions
的用法示例。
在下文中一共展示了extensions.Extension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from markdown import extensions [as 别名]
# 或者: from markdown.extensions import Extension [as 别名]
def __init__(self, config: dict, **kwargs) -> None:
"""
Initialization method.
Arguments:
config: The configuration items from `mkdocs` and `mkdocstrings` that must be passed to the block processor
when instantiated in [`extendMarkdown`][mkdocstrings.extension.MkdocstringsExtension.extendMarkdown].
kwargs: Keyword arguments used by `markdown.extensions.Extension`.
"""
super().__init__(**kwargs)
self._config = config
示例2: registerExtensions
# 需要导入模块: from markdown import extensions [as 别名]
# 或者: from markdown.extensions import Extension [as 别名]
def registerExtensions(self, extensions, configs): # noqa
"""
Register extensions with this instance of Markdown.
Keyword arguments:
* `extensions`: A list of extensions, which can either
be strings or objects. See the docstring on Markdown.
* `configs`: A dictionary mapping module names to configuration options.
"""
from markdown import util
from markdown.extensions import Extension
for ext in extensions:
try:
if isinstance(ext, util.string_type):
ext = self.build_extension(ext, configs.get(ext, {}))
if isinstance(ext, Extension):
ext._extendMarkdown(self)
elif ext is not None:
raise TypeError(
'Extension "%s.%s" must be of type: "markdown.Extension"'
% (ext.__class__.__module__, ext.__class__.__name__)
)
except Exception:
# We want to gracefully continue even if an extension fails.
_log('Failed to load markdown module!')
_debug(traceback.format_exc(), ERROR)
return self