Search code examples
python-sphinxrestructuredtext

Force a new line in Sphinx text


I have Sphinx text in the following format in source code:

Line 1 Line 2 Line 3 Line 4

I would like Line 4 to be rendered in HTML on a separate physical line. Is this possible?


Solution

  • You can define a hard line break as follows:

    .. # define a hard line break for HTML
    .. |br| raw:: html
    
       <br />
    

    You should define such aliases in a prolog.inc and reference it in you Sphinx configuration file.

    Here is a usage example:

    My first line |br|
    My second line