19
我正在編寫一些文檔,其中包含Sphinx,我只想爲HTML文檔打印出一段文本,而不是LaTeX文檔。東西告訴我,我應該能夠做到這一點與sphinx.ext.ifconfig
,但我不知道如何。有誰知道如何做到這一點?Sphinx文檔中的條件輸出
我正在編寫一些文檔,其中包含Sphinx,我只想爲HTML文檔打印出一段文本,而不是LaTeX文檔。東西告訴我,我應該能夠做到這一點與sphinx.ext.ifconfig
,但我不知道如何。有誰知道如何做到這一點?Sphinx文檔中的條件輸出
不需要擴展名。只需使用only directive即可。它的工作原理是這樣的:
.. 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.
是否可以區分'singlehtml'和'html'? – Carel 2017-01-11 20:25:29
@Carel是的,對於Sphinx 1.2及更高版本,您可以使用顯式構建器標記builder_html和builder_singlehtml來區分'html'和'singlehtml'。 – ddbeck 2017-01-19 19:58:52
你能否看看類似的問題。 http://stackoverflow.com/questions/42798152/adding-custom-tag-in-sphinx – Learner 2017-03-15 00:17:02