本文整理汇总了Python中markdown.preprocessors方法的典型用法代码示例。如果您正苦于以下问题:Python markdown.preprocessors方法的具体用法?Python markdown.preprocessors怎么用?Python markdown.preprocessors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类markdown
的用法示例。
在下文中一共展示了markdown.preprocessors方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extendMarkdown
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extendMarkdown(self, md: markdown.Markdown, md_globals: Dict[str, Any]) -> None:
md.preprocessors.add(
'generate_code_example', APICodeExamplesPreprocessor(md, self.getConfigs()), '_begin',
)
md.preprocessors.add(
'generate_api_description', APIDescriptionPreprocessor(md, self.getConfigs()), '_begin',
)
示例2: extendMarkdown
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extendMarkdown(self, md: markdown.Markdown, md_globals: Dict[str, Any]) -> None:
md.preprocessors.add(
'tabbed_sections', TabbedSectionsPreprocessor(md, self.getConfigs()), '_end')
示例3: extendMarkdown
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extendMarkdown(self, md: markdown.Markdown, md_globals: Dict[str, Any]) -> None:
""" Add RelativeLinksHelpExtension to the Markdown instance. """
md.registerExtension(self)
md.preprocessors.add('help_relative_links', RelativeLinks(), '_begin')
示例4: extendMarkdown
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extendMarkdown(self, md: markdown.Markdown, md_globals: Dict[str, Any]) -> None:
""" Add SettingHelpExtension to the Markdown instance. """
md.registerExtension(self)
md.preprocessors.add('setting', Setting(), '_begin')
示例5: extendMarkdown
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extendMarkdown(self, md: markdown.Markdown, md_globals: Dict[str, Any]) -> None:
md.preprocessors.add(
'generate_api_arguments', APIArgumentsTablePreprocessor(md, self.getConfigs()), '_begin',
)
示例6: extendMarkdown
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extendMarkdown(self, md: markdown.Markdown, md_globals: Dict[str, Any]) -> None:
md.preprocessors.add(
'generate_return_values', APIReturnValuesTablePreprocessor(md, self.getConfigs()), '_begin',
)
示例7: extendMarkdown
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extendMarkdown(self, md, md_globals):
md.preprocessors.add('CodeBlockPreprocessor', CodeBlockPreprocessor(), '_begin')
示例8: extendMarkdown
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extendMarkdown(self, md, md_globals=None):
md.preprocessors.add("code_isolation",
IndentsAsCellOutputPreprocessor(md),
"<html_block")
md.parser.blockprocessors['code'] = IndentsAsCellOutputProcessor(md.parser)
示例9: extract_code_blocks
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extract_code_blocks(filename):
with open(filename) as fin:
doc = fin.read().split("\n")
M = markdown.Markdown(extensions=[SpecialFencedCodeExtension()])
preprocessors = M.preprocessors
tree_processors = M.treeprocessors
try:
version_info = markdown.__version_info__
except AttributeError:
version_info = markdown.version_info
# Markdown 3.* stores the processors in a class that can be iterated directly.
# Markdown 2.* stores them in a dict, so we have to pull out the values.
if version_info[0] == 2:
# Note: `markdown.version_info` will be deprecated in favor of
# `markdown.__version_info__` in later versions of Markdown.
preprocessors = preprocessors.values()
tree_processors = tree_processors.values()
for prep in preprocessors:
doc = prep.run(doc)
root = M.parser.parseDocument(doc).getroot()
for treeproc in tree_processors:
newRoot = treeproc.run(root)
if newRoot is not None:
root = newRoot
return SpecialFencePreprocessor.EXAMPLES
示例10: extendMarkdown
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def extendMarkdown(self, md, md_globals=None):
""" Add FencedBlockPreprocessor to the Markdown instance. """
md.registerExtension(self)
if markdown.version_info[0] >= 3:
md.preprocessors.register(
SpecialFencePreprocessor(md), "fenced_code_block", 10
)
else:
md.preprocessors.add(
"fenced_code_block",
SpecialFencePreprocessor(md),
">normalize_whitespace",
)
示例11: md_filter_add_syntax_highlight
# 需要导入模块: import markdown [as 别名]
# 或者: from markdown import preprocessors [as 别名]
def md_filter_add_syntax_highlight(md):
md.preprocessors.add('highlight', CodeBlockPreprocessor(), "_begin")
return True