HTML variables in Sphinx

前端 未结 1 659
天涯浪人
天涯浪人 2021-01-28 17:31

I\'m trying to have a variable in conf.py that inserts a link that is applied on a string:

rst_epilog = \"\"\"
.. |support| replace:: `support team 

        
相关标签:
1条回答
  • 2021-01-28 17:53

    Use this substitution definition:

    .. |support| replace:: support team support@blabla.com
    

    support@blabla.com is automatically recognized as a mailto link.

    The |support| substitution reference produces the following output:

    support team <a class="reference external" href="mailto:support&#37;&#52;&#48;blabla&#46;com">support<span>&#64;</span>blabla<span>&#46;</span>com</a>
    

    An alternative is to use a raw-html role (see http://docutils.sourceforge.net/docs/ref/rst/roles.html#raw).

    Add this to conf.py:

    rst_epilog = """
    .. role:: raw-html(raw)
       :format: html
    
    .. |support| replace:: :raw-html:`<a href="mailto:support@blabla.com">support team</a>`
    """
    
    0 讨论(0)
提交回复
热议问题