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
  • 8,684
  • 19
  • 37
  • 59
user327301
  • 2,631
  • 2
  • 25
  • 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
  • 45,711
  • 11
  • 120
  • 232