I have the following code:
import Text.Pandoc
myWriterOptions = defaultWriterOptions
{ writerHtml5 = True
, writerStrictMarkdown = False
}
markdownToHtml :: String -> Html
markdownToHtml = writeHtml myWriterOptions . readMarkdown defaultParserState
If I apply it to a markdown string:
"header\n=======\nA line of text.\n### A list ###\n- apple\n- orange\n- pear"
I end up with:
"<h1 id=\"header\">header</h1>\n<p>A line of text. ### A list ### - apple - orange - pear</p>"
Your code looks fine to me, and so does the output. I get the same output from Try Pandoc.
If you add newlines before the second heading and list, then it produces the output you’re looking for. I wouldn’t be surprised if other Markdown implementations require blank lines, too; after all, it would be pretty annoying if starting a line with a hyphen started a new list (think line wrapping).