列表项中的结束文字块 [英] End literal block in list item

查看:55
本文介绍了列表项中的结束文字块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 rst 文件中有一个列表项,我想将文本块放入其中,但我无法让文本块正确结束.

I have a list item in my rst file that I would like to put a literal block into, but I am unable to get the literal block to end properly.

这是我的第一个:

1. Item 1 (not literal)
2. Item 2::

    MyCode.example()

    Description of the code shown above (not literal)

我希望以 Description 开头的段落位于其上方的文字块之外,但仍是列表项 #2 的一部分.我能想出的唯一解决方法是:

I would like the paragraph starting with Description to be outside the literal block above it, but still part of list item #2. The only workaround I have been able to come up with is this:

1. Item 1 (not literal)
2. Item 2:

    ::

        MyCode.example()

    Description of the code shown above (not literal)

这允许非文字文本返回到前一级别的缩进,使所有内容看起来都符合我的要求.但是,我希望在列表项的第一行中有 ::.

This allows the non-literal text to return to the previous level of indentation, making everything look just the way I want it to. However, I would like to have the :: in the first line of the list item.

是否可以以允许 :: 保留在列表项的第一行的方式显式结束文字块?

Is it possible to end the literal block explicitly in a way that would allow the :: to stay in the first line of the list item?

推荐答案

是的.空白是棘手的.您的代码中有一个额外的前导空格以及以描述"开头的行.试试这个:

Yes. Whitespace is tricky. You have one extra leading space in your code and the line starting with "Description". Try this:

1. Item 1 (not literal)
2. Item 2::

       MyCode.example()

   Description of the code shown above (not literal)

注意item和description的首字母垂直对齐,代码块缩进4个空格.

Note that the first letters of the item and description vertically align and code blocks are indented 4 spaces.

额外提示:我喜欢在编号项目及其句点之间添加一个空格,以便它从第 5 列开始.这使得在我的编辑器中将段落缩进 4 个空格(和代码块 8 个空格)变得更容易.如果我有超过 9 个项目,那么项目 10-99 的缩进看起来会更好.

Bonus tip: I like to add a space between numbered items and its period so that it is starts at column 5. This makes it easier to indent paragraphs to 4 spaces (and code blocks 8 spaces) in my editor. And in case I have more than 9 items, then the indentation looks nicer for items 10-99.

这篇关于列表项中的结束文字块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆