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