Search code examples
documentationpython-sphinxsubstitutionrestructuredtext

Substitution in Admonitions


How can I do a substitution in an admonition?

For example:

|p| account

.. note::

    **Been using |p| separately and now integrating?**

In my sphinx conf.py I define a replacement rule which gets appended to the rst file prior to interpretation (at least that is how I understand it):

rst_epilog = '.. |p| replace:: Labnext'

My first substitution in the paragraph works without fail. However the substitution in the note directive isn't applied. Any work arounds?

Thanks,

Mike


Solution

  • The substitution in the note works if you remove the strong emphasis (double asterisks). Nesting of inline markup is not supported.

    References:


    Here is a workaround if you need to keep the strong emphasis:

    1. In conf.py, use the following definition:

       rst_epilog = '.. |p| replace:: **Labnext**'
      
    2. In your .rst file, use this markup:

       .. note::
      
         **Been using** |p| **separately and now integrating?**