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


当前回答

请使用硬空格

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

两种方法的结果相同

的代码

Sample code
    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.

问题

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

其他回答

对于引用/缩进的段落,这个hack可能会工作(取决于渲染引擎):

| | | |
|-|-|-|
|  | _"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."_ | |
|

呈现为:

检查您是否可以使用HTML与您的markdown。也许这对你有用:

列出条目1 <br/> 缩进行< br / > < br / > 还有更多… 第二个条目 分项< br / > 你好!

作为一个变通办法,我建议插入一个竖条(|),后面跟着硬空格(Alt- code在Windows: Alt+0160)。这保留了条后的缩进,从而为原始和渲染Markdown提供了一个视觉上可接受的解决方案。

This is a normal line of text.
|    This is an indented line of text.
|        This is another indented line of text.

如果你真的必须使用标签,并且你不介意灰色背景色和填充,<pre>标签可能工作(如果支持):

<pre>
This        That        And             This
That        This        And             That    
</pre>
This        That        And             This
That        This        And             That    

一种方法是使用项目符号,它允许您指定多个缩进级别。项目符号用两个空格、星号和另一个空格的倍数插入。

this is a normal line of text
  * this is the first level of bullet points, made up of <space><space>*<space>
    * this is more indented, composed of <space><space><space><space>*<space>

这种方法有一个很大的优点,那就是当您查看原始文本时,它也很有意义。

如果你不想看到项目符号本身,你应该(取决于你在哪里使用markdown)能够为整个标记下来的区域在css中添加li {list-style-type: none;}。