Unify the -/= and ## style headers

so that TOC can be generated properly from a mixed-markup document.

With the current code the TOC for the following document:

````
hb
---
````

is generated as: hb ha hc, while the correct order would be ha hb hc
Merge branch 'unify_header_handling'