Search code examples
markdownpandocrestructuredtextgithub-flavored-markdown

Prevent extra newline after heading in md to rst conversion


I have some markdown files that I want to convert to reStructuredText files. I have just started using Pandoc for this particular requirement. So far I am using the following simple command

> pandoc --from markdown --to rst --columns 80 --output foo.rst foo.md

Now in my markdown I have laid out the text, such that there is no new line after the headings, for example:

# Some heading
Some text that follows on the line immediately after the heading

The result from the mentioned command inserts an extra new-line though:

Some heading
============

Some text that follows after the heading *and* a new-line

If I'm correct in thinking that this added new-line is not a requirement for reStructuredText, is there some simple way that I can prevent Pandoc from inserting it?


Solution

  • As @Waylan commented, having a new line after a heading is considered the best practice style for markdown and thus Pandoc's insertion of them was correct.