gpt4 book ai didi

markdown - 使用 MyST 在 Sphinx 中使用替换

转载 作者:行者123 更新时间:2023-12-05 05:02:12 24 4
gpt4 key购买 nike

MyST允许在 markdown 中编写 sphinx 文档。是否可以将其与替代品结合使用?

最佳答案

是的,这是可能的。

首先,您需要在 conf.py 文件中启用 substitution 扩展:

# Don't forget to activate `myst_parser` as well
extensions = [
# ...
'myst_parser'
]
myst_enable_extensions = [
# ...
'substitution'
]

仍然在您的 conf.py 文件中,您必须在 myst_substitutions 字典中定义您的替换。

myst_substitutions = {
'my_name': 'Luiz Oliveira'
}

最后,在您的 markdown 文件中,您可以通过在双花括号 ({{YOUR_SUB_KEY}}}) 内传递 key 来使用替换,如下所示:

<!-- This is my markdown file -->
This document was written by {{my_name}}.

这将生成输出:

This document was written by Luiz Oliveira.

关于markdown - 使用 MyST 在 Sphinx 中使用替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62283915/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com