Substitution in Admonitions

时光怂恿深爱的人放手 提交于 2019-12-31 01:51:07

问题


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


回答1:


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

References:

  • http://sphinx-doc.org/rest.html#inline-markup
  • http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup
  • http://docutils.sourceforge.net/FAQ.html#is-nested-inline-markup-possible

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?**
    


来源:https://stackoverflow.com/questions/24122520/substitution-in-admonitions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!