Convert a markdown document into a JSON tree structure.