RST:如何呈现`tree`命令的输出?

Luí*_*usa 9 restructuredtext

我想tree在重构文本文档中显示命令的输出.我正在使用此代码:

.. code-block:: bash

   project
   ??? demo.py
   ??? LICENCE.txt
   ??? processes          
   ?   ??? area.py
   ?   ??? bboxinout.py
   ??? pywps.cfg          
   ??? requirements.txt
   ??? server.py          
   ??? setup.py
   ??? static
   ??? templates
   ??? tests
Run Code Online (Sandbox Code Playgroud)

哪个产生以下输出:

在此输入图像描述

然后我尝试tree用unicode定义替换字符,例如:

.. |hbar| unicode:: 01C0 ..

但是在|hbar|代码块中使用时,序列是逐字打印的.

有没有其他方法可以强制正确打印这些字符?

小智 10

在ReST中,我使用文字块来表示树结构:

::

    project
    ??? demo.py
    ??? LICENCE.txt
    ??? processes          
    ?   ??? area.py
    ?   ??? bboxinout.py
    ??? pywps.cfg          
    ??? requirements.txt
    ??? server.py          
    ??? setup.py
    ??? static
    ??? templates
    ??? tests
Run Code Online (Sandbox Code Playgroud)

我希望这有帮助!


小智 5

现在回答你的问题有点晚了,但是对于遇到这个问题的人来说,我设法通过使用行块来显示一棵树,即在每行的开头添加“|”,如下所示:

\n\n
| project\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 demo.py\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 LICENCE.txt\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 processes          \n| \xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 area.py\n| \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 bboxinout.py\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pywps.cfg          \n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 requirements.txt\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 server.py          \n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 setup.py\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 static\n| \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 templates\n| \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tests\n
Run Code Online (Sandbox Code Playgroud)\n\n

当你制作你的 html 时,这应该给你这样的东西:

\n\n

在此输入图像描述

\n\n

它并不完美,它没有将树包装在一个块中,但确实显示了树。

\n\n

希望这可以帮助。

\n