2017-06-16 44 views
0

我想在conf.py一個變量插入是一個字符串加一個鏈接:獅身人面像HTML變量

rst_epilog = """ 
.. |support| replace:: `support team <[email protected]>`_ 
""" 

在這種情況下「支持團隊」會變成指向一個鏈接電子郵件地址。

不幸的是,這不起作用,構建中斷。

所以我試着在那裏轉儲HTML,不知道何時發生替換,但它發生在HTML轉換之前,所以在我的輸出中不起作用。

rst_epilog = """ 
.. |support| replace:: <a href="[email protected]">support team</a> 
""" 

任何想法我可以做這個變量?

回答

0

使用這種替代定義:

.. |support| replace:: support team [email protected] 

[email protected]被自動識別爲一個mailto鏈接。

|support|取代的參考產生以下輸出:

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> 

另一種方法是使用一個raw-html作用(見http://docutils.sourceforge.net/docs/ref/rst/roles.html#raw)。

添加這conf.py:

rst_epilog = """ 
.. role:: raw-html(raw) 
    :format: html 

.. |support| replace:: :raw-html:`<a href="mailto:[email protected]">support team</a>` 
""" 
+0

權,但是如果我想不同的文字比href值是什麼?我會澄清我的問題。 – Flag

+0

感謝您的編輯,但我不能轉儲我的config.py中的第一個指令:( – Flag

+0

我的壞,出於某種原因,我認爲epilog只能包含替換,沒有其他指令。 – Flag