1
votes

I am working on converting a bunch of orgmode files into markdown. I have been unable to find how to prevent pandoc from converting headings greater than level 3 into numbered lists. For example:

* Heading 1

Here is some content

** Heading 2

Here is some content

*** Heading 3

Here is some content

**** Heading 4

Here is some content

***** Heading 5

Here is some content

**** Another Heading 4

Here is some content

***** Another Heading 5

Here is some content

Converting with this command: pandoc -f org -t gfm --atx-headers myfile.org

Results in this output:

# Heading 1

Here is some content

## Heading 2

Here is some content

### Heading 3

Here is some content

1.  Heading 4
    
    Here is some content
    
    1.  Heading 5
        
        Here is some content

2.  Another Heading 4
    
    Here is some content
    
    1.  Another Heading 5
        
        Here is some content

How can I have Heading 4 and Heading 5 be actual headings instead of numbered lists?

Thanks

1
Why not write a awk or sed command to make the change?Red Cricket
@RedCricket, can you elaborate on your suggestion? After performing this conversion, it's hard (or impossible) to distinguish between level 4 headings and lists that are intended to be numbered lists.tgrosinger

1 Answers

3
votes

Org mode uses the H export setting to control this behavior:

Set the number of headline levels for export (org-export-headline-levels). Below that level, headlines are treated differently. In most back-ends, they become list items.

Pandoc respects this setting. The default value for this, both in Emacs Org-mode and pandoc, is 3.

So the solution for your issue is to set this to a higher value. Either add this to the top of your org file:

#+OPTIONS: H:9

Or, if you are on Mac or Linux, use your shell's process substitution feature to prefix your input with this line:

pandoc -f org -t gfm --atx-headers <(printf "#+OPTIONS: H:9") myfile.org