dundalek / markmap

Visualize markdown documents as mindmaps
MIT License
1.7k stars 175 forks source link

Support for bi-directional mindmaps #3

Open ilyaminati opened 8 years ago

ilyaminati commented 8 years ago

Does the parser assume that there's exactly one root node? It'd be nice if it would allow for a mindmap that has a root node at the center, and child nodes both left and right of the root. Here's a simple test case:

## This is h2

## And another h2

# And an h1, ouch
dundalek commented 8 years ago

If you are missing a heading at certain level it creates a blank node to preserve hierarchy. If you have multiple top-level nodes it creates extra root node to wrap them.

Your example will look like this:

image

Having nodes both on left and right from the root is not yet implemented.

ilyaminati commented 8 years ago

Exactly. Those two are useful heuristics, but perhaps we could relax them, and work towards nodes on left and right of root.

Where in the code are these two heuristics? It might help in the conversation.

dundalek commented 8 years ago

I think the bi-directional display is not only limited to your case but can be used generally even for proper trees. Therefore it is the matter of the rendering and not parsing.

This d3 example can be used as a start, the changes are needed in view.mindmap.js. I think the trickiest part is to come up with good heuristics how to divide nodes between two sides, so that it is reasonably balanced.

As for the two heuristics, they are located in transform.headings.js.

ilyaminati commented 8 years ago

Do you think it's reasonable to divide the nodes between the two sides NOT using a heuristic but instead using the order in the file? If an h2 comes before an h1, the node of the h2 goes left of the h1, otherwise it goes right.

mralexgray commented 8 years ago

I just woke up.... so this might make no sense.. but if "to the left" directives are implemented, it might be nice to also add implicit rules to force "to the top", and "to the bottom", too.. no?

fzyzcjy commented 1 week ago

Hi, is there any updates? Thanks