Standard Markdown syntax does not require a blank line before a heading. Pandoc does require this (except, of course, at the beginning of the document). The reason for the requirement is that it is all too easy for a #
to end up at the beginning of a line by accident (perhaps through line wrapping). Consider, for example:
I like several of their flavors of ice cream:
#22, for example, and #5.