It hadn't occurred to me that the visitor pattern could be used here, so I did the stack-based explicit recursion thing, but that only works it all the headings and content are top-level children of the root element. If they are already nested within, for instance, some arbitrary div, it doesn't work.
It hadn't occurred to me that the visitor pattern could be used here, so I did the stack-based explicit recursion thing, but that only works it all the headings and content are top-level children of the root element. If they are already nested within, for instance, some arbitrary
div
, it doesn't work.remark-sectionize does that much more elegantly.