0

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 <support@blabla.com>`_
"""

In this case 'support team' would turn into a link pointing to the email address.

Unfortunately, this does not work and the build breaks.

So I've tried dumping HTML in there, not knowing when the substitution happens, but it happens before HTML conversion, so that does not work in my output.

rst_epilog = """
.. |support| replace:: <a href="support@blabla.com">support team</a>
"""

Any idea I could do this with a variable?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Flag
  • 497
  • 1
  • 3
  • 17

1 Answers1

0

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>`
"""
mzjn
  • 48,958
  • 13
  • 128
  • 248