【问题标题】:Format to add standard code blocks within Markdown lists在 Markdown 列表中添加标准代码块的格式
【发布时间】:2012-05-03 12:17:47
【问题描述】:

我发现我无法在编号列表中获取代码块。

例如,当我通过缩进四个空格来添加代码块时,通常如下所示:

1. Do the first thing

    $ git stuff
    $ git other stuff 

2. second thing:

    $ git more stuff

结果如下,$ git 行是普通文本,没有格式化为代码:

  1. 做第一件事

    $ git 的东西 $ git 其他东西

  2. 第二件事:

    $ git 更多的东西

我可以使用反引号来做到这一点,即

1. Do the first things

    `$ git stuff`  
    `$ git other stuff` 

2. second thing:

    `$ git more stuff`

但如果可以的话,我想“正常”地做积木(4 个空格缩进)。

【问题讨论】:

    标签: markdown code-formatting


    【解决方案1】:

    根据the documentation,你需要做额外的缩进; +4 个空格或 +1 个制表符(分别为第 0 列的 8/2)。

    1. Item 1
    
            $git stuff
            $git other stuff
    
    2. Item 2
    
            $git more stuff
    

    这些换行符是必要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多