5

I have the following text in a .rst file:

Some text.
* Heading
  | The first topic.
  | Another topic which is very verbose and spans multiple lines ad infinitum.
  Topic continued......................................

and I would like it to render as:

Some text.
* Heading
  The first topic.
  Another topic which is very verbose and spans multiple lines ad infinitum....................
  Topic continued.............

However it renders like this in Html:

Some text.
* Heading| The first topic.| Another topic which is very verbose and spans multiple lines ad infinitum .................... Topic continued

The Sphinx documentation suggests using the | symbol to signal a line break as do several posts here on Stackoverflow, but I have been unable to get it to work. I would like a method which is independent of the Sphinx builder being used.

Blank lines between the elements do work but do not give the visual effect that I want.

What do I need to do?

Jonathan
  • 2,635
  • 3
  • 30
  • 49
  • @Steve I feel that this solution is too heavyweight for my situation. I have decided to use a solution given in https://stackoverflow.com/questions/7033239/how-to-preserve-line-breaks-when-generating-python-docs-using-sphinx which allows me to use |br| as my marker for a line break. – Jonathan Apr 28 '18 at 02:46

2 Answers2

3

Do this in two steps.

First get your reStructuredText to use the correct whitespace to generate a usable HTML structure with default visual styles applied.

Some text.

* Heading

  | The first topic.
  | Another topic which is very verbose and spans multiple lines ad infinitum.

  Topic continued......................................

Second override the default style sheet to generate the desired visual effect as described in this SO post, How do I set up custom styles for reStructuredText, Sphinx, ReadTheDocs, etc.?.

Steve Piercy
  • 13,693
  • 1
  • 44
  • 57
  • Your example will not work because | needs to be present in the first position of the line with no preceding white space. – Jonathan Jan 11 '19 at 02:12
2

If you add the following to your main .rst file:

.. |br| raw:: html

   <br />

Then in your markup you can add in |br| to create linebreaks just for HTML.

I want to break this line here: |br| after the break.
Andrey Mazur
  • 510
  • 4
  • 14