How do I create a new line with reStructuredText?

2020-08-09 06:27发布

How do I force a line break/new line in rst? I don't want it to be a new paragraph (ie. no additional spaces between the lines), I just want the text to start on a new line. Thanks!

3条回答
Ridiculous、
2楼-- · 2020-08-09 06:42

The line block syntax also worked, and was a bit cleaner:

| This is a line | This is another line | Another new line

查看更多
手持菜刀,她持情操
3楼-- · 2020-08-09 06:43

We added a substitution to our global.rst file so we didn't have to add raw tags all the time.

.. |br| raw:: html

  <br/>

This way we can just use |br| when we need a line break.

查看更多
Luminary・发光体
4楼-- · 2020-08-09 06:47

According to the docs for docutils raw role, you can do this:

If there just *has* to be a line break here,
:raw-html:`<br />`
it can be accomplished with a "raw"-derived role.
But the line block syntax should be considered first.

You will need to define the raw role first:

.. role:: raw-html(raw)
    :format: html

As the example states, consider line block syntax first.

| Lend us a couple of bob till Thursday.
| I'm absolutely skint.
| But I'm expecting a postal order and I can pay you back
  as soon as it comes.
| Love, Ewan.
查看更多
登录 后发表回答