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