首页 > 解决方案 > Including a literal block inside an admonition

问题描述

I'm an RST newbie. I want to create a Warning block that includes a line of code.

Here are four attempts:

.. WARNING:: Base case - This doesn't format the next line as a literal::
   $ ls /

.. WARNING:: Split over two lines - This still doesn't format the next line
   as a literal::
   $ ls /

.. WARNING:: Indented - Still no luck::
     $ ls /

.. WARNING:: Split line AND indented. Works, but gives a warning "Unexpected
   indentation"::
     $ ls /

And here is the result from Sphinx.

Output from Sphinx

The last example gives the output I am looking for, but I get a warning from Sphinx when it runs it.

What am I missing?

标签: python-sphinxrestructuredtext

解决方案


我解决了。发布后不久,我通过点击任意按钮随机点击答案,直到它起作用:

.. WARNING:: The magic incantation - a blank line::

   $ ls /

推荐阅读