Markdown: Implement GetNestedHierarchy()

Fixes part of #1546
Markdown: Work around some bugs in embedded JSON editors

There are still more bugs that are much harder to work around
Merge pull request #1560 from SLaks/markdown-fixes

Implement GetNestedHierarchy() for Markdown