【问题标题】:Use substitution in Sphinx with MyST在 Sphinx 中使用 MyST 替换
【发布时间】:2020-09-28 16:59:34
【问题描述】:

MyST 允许在 markdown 中编写 sphinx 文档。 是否可以将其与替换结合起来?

【问题讨论】:

  • 最好的方法是向 MyST 开发者提出问题。

标签: markdown python-sphinx substitution restructuredtext myst


【解决方案1】:

是的,有可能。

首先,您需要在您的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'
}

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

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

这会产生输出:

本文档由 Luiz Oliveira 撰写。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-26
    • 1970-01-01
    • 2013-12-29
    • 2023-03-20
    • 2012-02-07
    • 2014-06-11
    • 1970-01-01
    相关资源
    最近更新 更多