Sphinx 文档中的条件输出

发布于 2024-08-20 08:15:09 字数 193 浏览 8 评论 0原文

我正在使用 Sphinx 编写一些文档,并且我只想打印特定的文本块适用于 HTML 文档,不适用于 LaTeX 文档。有些东西告诉我我应该能够使用 sphinx.ext.ifconfig 来做到这一点,但我不知道如何做。有谁知道该怎么做?

I'm writing some documentation with Sphinx and I'd like to print out a certain block of text only for HTML documentation, not for LaTeX documentation. Something tells me I should be able to do this with sphinx.ext.ifconfig but I can't figure out how. Does anyone know how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感性 2024-08-27 08:15:09

无需延期。只需使用 only 指令即可。

(旧链接,来自 2010 年原始帖子)
https://web.archive.org/web/20100129001557/http://sphinx.pocoo.org/markup/misc.html#include-content-based-on-tags

(最新链接)< br>
https:// www.sphinx-doc.org/en/master/usage/restructivetext/directives.html#include-content-based-on-tags

它的工作原理如下:

.. only:: latex

    The stuff in here only appears in the latex output.

.. only:: html

    The stuff in this block only appears in the HTML output. It's
    often useful to use this directive with it:

    .. raw:: html

        It's good for embedding stuff, like video.

No extension is required. Just use the only directive.

(old link, from original 2010 post)
https://web.archive.org/web/20100129001557/http://sphinx.pocoo.org/markup/misc.html#including-content-based-on-tags

(latest link)
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#including-content-based-on-tags

It works like this:

.. only:: latex

    The stuff in here only appears in the latex output.

.. only:: html

    The stuff in this block only appears in the HTML output. It's
    often useful to use this directive with it:

    .. raw:: html

        It's good for embedding stuff, like video.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文