6

How do I define multiple global substitutions in Sphinx?

I see in this question how to create global substitutions using rst_prolog in conf.py. E.g.,

rst_prolog = '.. |my_conf_val| replace:: 42'

All examples of this that I can find only define one substitution in rst_prolog, but I want to do more than one. I tried this:

rst_prolog = """.. |sub1| replace:: mine1\
         .. |sub2| replace:: mine2"""

When I put |sub1| into text in an rst file, |sub1| is (not surprisingly) replaced with:

mine1 .. |sub2| replace:: mine2

What is the correct syntax here?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
user327301
  • 2,641
  • 2
  • 26
  • 33

1 Answers1

10

Make sure that the alignment of the substitution definitions is consistent. Backslashes are not needed. This works:

rst_prolog = """
.. |sub1| replace:: mine1
.. |sub2| replace:: mine2
"""
mzjn
  • 48,958
  • 13
  • 128
  • 248