Search code examples
listmarkdownpandoc

How to force pandoc to number all ordered lists starting from one (1)?


I have a Markdown document which is generated by some application. All things go correct, but there are some problems with ordered lists.

Below is minimal reproducible example of such Markdown document:

# Heading 1

Some text

## Heading 1.1

1. list item
1. list item

## Heading 1.2

3. list item
1. list item

## Heading 1.3

7. list item
3. list item

The output format really does not matter, but for PDF (produced by pandoc list-test.md -o list.pdf) I get the following:

pdf output

But for example ReText renders the code as expected:

ReText

Why this happens?


Solution

  • The reason here is that ReText uses Python Markdown.

    Comparison using Babelmark 2 gives a clue that we need to switch Pandoc to the markdown_strict mode by:

    pandoc list-test.md -o list.pdf --from=markdown_strict
    

    to get expected rendering.

    Also using markdown_phpextra or markdown_mmd by:

    pandoc list-test.md -o list.pdf --from=markdown_phpextra
    pandoc list-test.md -o list.pdf --from=markdown_mmd
    

    will fix the issue too.