Sphinx: Use a different directive for a different output format

后端 未结 2 385
逝去的感伤
逝去的感伤 2021-01-25 12:54

Assume you have a reStructuredText document and want to export it in two formats using Sphinx 2.x: HTML and PDF.

You want to put some slightly different contents in the

2条回答
  •  自闭症患者
    2021-01-25 13:31

    This is a little clunky, but it works for me:

    .. role:: latex(raw)
       :format: latex
    
    .. role:: html(raw)
       :format: html
    
    .. |foo| replace:: :latex:`LaTeX text`:html:`HTML text`
    .. |bar| replace:: :latex:`other latex text`:html:`other html text`
    

提交回复
热议问题