我想写几行文字。除了每行从第6列开始之外,它们应该正常格式化。例如,我不希望代码块格式规则使这一文本块看起来像代码,因为我将使用其他格式,如粗体面等。如何在Markdown中做到这一点?


当前回答

使用非换行空格开始行的一个问题是,如果你的行足够长,那么当它溢出到第二行时,溢出行的第一个字符将从左开始,而不是从上一行的第一个字符开始。

如果你的系统允许你将HTML与你的markdown混合在一起,一种获得缩进的廉价和愉快的方式是这样的:

<ul>
My indented text goes here, and it can be long and wrap if you like.
And you can have multiple lines if you want.
</ul>

从语义上讲,在HTML中这是毫无意义的(一个没有任何LI项的UL节),但我所使用的所有浏览器都很乐意缩进这些标记之间的内容。

其他回答

做制表符,然后是+号,然后空格,然后是内容

So

*一级 +二级标签

我会使用&emsp;在我看来干净多了。

请使用硬空格

为什么使用另一种标记语言?(我同意上面的@ cz)。 Markdown的一个目标是使文档即使在纯文本编辑器中也可读。

两种方法的结果相同

的代码

Sample code
&nbsp;&nbsp;&nbsp;&nbsp;5th position in an really ugly code  
    5th position in a clear an readable code  
    Again using non-breaking spaces :)

结果

示例代码 在一个非常丑陋的代码中排名第五 第5位在一个清晰易读的代码 再次使用非换行空格:)

非间断空格(或硬空格)的视觉表示通常是一个正常的空格“”,然而,它的Unicode表示是U+00A0。 普通空格的Unicode表示是U+0020(在ASCII表中是32)。 因此,文本处理器的行为可能会有所不同,而视觉表示则保持不变。

插入硬空间

| OS        | Input method                      |
|-----------| ----------------------------------|
| macOS     | OPTION+SPACE (ALT+SPACE)          |
| Linux     | Compose Space Space or AltGr+Space|
| Windows   | Alt+0+1+6+0                       |

Some text editor use Ctrl+Shift+Space.

问题

在复制和粘贴操作中,一些文本编辑器可以将硬空格转换为公共空格,因此要小心。

为了完整起见,更深入的项目列表如下:

嵌套的更深层次: ----在这里留下一个空行 *第一级A项目-前面没有空格的子弹字符 *二级Aa物品- 1格足够 *三级Aaa物品- 5个空格最少 *第二级Ab项目- 4个空格也可能 *第一个B级道具

嵌套的更深层次:

first level A item - no space in front the bullet character second level Aa item - 1 space is enough third level Aaa item - 5 spaces min second level Ab item - 4 spaces possible too first level B item Nested deeper levels: ...Skip a line and indent eight spaces. (as said in the editor-help, just on this page) * first level A item - no space in front the bullet character * second level Aa item - 1 space is enough * third level Aaa item - 5 spaces min * second level Ab item - 4 spaces possible too * first level B item And there could be even more such octets of spaces.

正如@AlexDupuy在评论中指出的,定义列表可以用于此。

这不是所有的降价处理器都支持,但广泛可用:降价指南-定义列表

Term 1
: definition 1
: definition 2

Term 2
: definition 1
: definition 2

呈现为(html):

<dl>
    <dt>Term 1</dt>
    <dd>definition 1</dd>
    <dd>definition 2</dd>
    <dt>Term 2</dt>
    <dd>definition 1</dd>
    <dd>definition 2</dd>
</dl>

通常,DT以类似标题的格式呈现,而每个DD以缩进文本的形式呈现。

如果你不想要标题/术语,只需使用一个不间断的空格来代替定义术语:

&nbsp;
: This is the text that I want indented.  All text on the same line as the preceding colon will be included in this definition.
: If you include a second definition you'll get a new line; potentially separated by a space. <br />Some inline HTML may be supported within this too, allowing you to create new lines without spaces.
: Support for other markdown syntax varies; e.g. we can add a bullet list, but each one's wrapped in a separate definition term, so the spacing may be out.
: - item 1
: - item 2
: - item 3

你可以复制粘贴上面的例子到这个站点:Stack Edit Markdown Editor