Reputation: 2845
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?
Upvotes: 20
Views: 28226
Reputation: 317
In the source code, just add extra empty line and it will do the job. for example:
Line 1
Line 2
Line 3
Upvotes: 2
Reputation: 81
I had to use directive line block, nothing else worked for me.
.. line-block::
Line 1
Line 2
Upvotes: 2
Reputation: 21
The solutions user14678546 and Paebbels also work for tables:
Using line blocks in tables is inconstant, not pretty, as well as it leaves a blank/additional line break at the end, resulting in ex. 3 lines but only the first 2 lines have text.
Here is an example of a line break in a table of reStructuredText (only for html):
.. table:: Truth table for "not"
:width: 20%
:widths: 1 3 1
===== ===== =====
A not A Note
===== ===== =====
False True Text here
True False Comment here
False
False True Text here |br| line break in table here
True False
===== ===== =====
.. |br| raw:: html
<br>
Using |br|
inline in text in a table, results in a line brake in a single cell of text (in html): Table with line break
It also works for csv tables.
Upvotes: 2
Reputation:
You can use:
Line 1 |br|
Line 2 |br|
Line 3 |br|
Line 4 |br|
At the end of the file you need to put:
.. |br| raw:: html
<br>
Note: This does not work when making latex code.
Upvotes: 0
Reputation: 2505
Use line blocks:
| Line 1
| Line 2
| Line 3
| Line 4
Will produce:
Line 1
Line 2
Line 3
Line 4
Upvotes: 34
Reputation: 16221
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
Upvotes: 4