def simplify_source_code_blocks_for_latex(app, doctree, fromdocname): # pylint: disable=unused-argument
"""Simplify coqdoc and coqtop blocks.
In HTML mode, this does nothing; in other formats, such as LaTeX, it
replaces coqdoc and coqtop blocks by plain text sources, which will use
pygments if available. This prevents the LaTeX builder from getting
confused.
"""
is_html = app.builder.tags.has("html")
for node in doctree.traverse(is_coqtop_or_coqdoc_block):
if is_html:
node.rawsource = '' # Prevent pygments from kicking in
else:
if 'coqtop-hidden' in node['classes']:
node.parent.remove(node)
else:
node.replace_self(nodes.literal_block(node.rawsource, node.rawsource, language="Coq"))
评论列表
文章目录