Pandoc Markdown:包含代码块的多段列表

问题描述 投票:0回答:1

有关Pandoc site列表的整个文档似乎是错误的,或者至多是一个巨大的混乱。

我主要解决了处理列表中多个段落的方式,但我坚持使用以下组合:代码块段落后面的文本段落从列表中删除。也就是说,代码块段落会破坏列表(如latex .tex输出文件中所示;使用选项-t tex)。

如果以下Markdown文本在文件test.md中,我使用Pandoc作为pandoc -t latex test.md -o test.pdf

如何格式化以下Markdown文本,以便第3段落在列表的第1项内并与第1段对齐?

   1. List item. Paragraph 1

   ```javascript
        // Second paragraph is a code block. If start at column 6, code shows ok.
        // Additional indentation only moves code block further right
        // Notice code block tag/backticks starts at column 1 though!!
        //  If it starts at col 2+, code block w/ tag is messed up as all code block.
        var x = 3
        print( "Pandoc has made a mess out of Markdown!" )
   ```

        Paragraph 3. However list is broken and Par 3 falls off.
   2. List item

它应该显示为:

  1. 项目清单。第1段

// Second paragraph is a code block. If start at column 6, code shows ok. // Additional indentation only moves code block further right // Notice code block tag/backticks starts at column 1 though!! // If it starts at col 2+, code block w/ tag is messed up as all code block. var x = 3 print( "Pandoc has made a mess out of Markdown!" )

   Paragraph 3. However list is broken and Par 3 falls off.

2.列出项目

但显示为

  1. 项目清单。第1段

// Second paragraph is a code block. If start at column 6, code shows ok. // Additional indentation only moves code block further right // Notice code block tag/backticks starts at column 1 though!! // If it starts at col 2+, code block w/ tag is messed up as all code block. var x = 3 print( "Pandoc has made a mess out of Markdown!" )

第3段。然而,名单被打破,第3项下降。

  1. 项目清单
markdown pandoc github-flavored-markdown
1个回答
2
投票

关键是使用缩进和换行的正确组合:

1. List item, no indention

    This paragraph is indented by two tabs (four spaces). 
    Put separating newlines below and above the following code chunk:

    ```javascript
    // This code chunk is indented by two tabs (four spaces)
    var x = 3
    print("Pandoc has made a mess out of Markdown!")
    ```

    Paragraph 3 is indented by two tabs.

2. List item, no indention

这产生了

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.