willklein / markdown-menu

Browser extension that adds a navigation menu to any readme or Markdown file on GitHub.com
https://chrome.google.com/webstore/detail/markdown-menu-for-github/jekgocfoijmbgcjejohdgmojaejofdpo
MIT License
41 stars 18 forks source link

Odd behavior when there are gaps between header levels #1

Open willpiers opened 9 years ago

willpiers commented 9 years ago

you can see an example here https://github.com/RallySoftware/burro/blob/master/UE_SHELL.md

Basically if the structure of the markdown file uses an h6 as a child of an h2 there will be extra padding generated by the padding-left that github applies to uls. I wonder if your extension could be smart enough to not add extra uls

willklein commented 9 years ago

Yeah, I think we can handle that. Right now the logic is simple to handle hierarchy.

What would you expect if you have, say, an h3 elsewhere? Perhaps also a child of the h2, after the h6 children:

I guess we can collapse level 6 to level 4 to maintain that distinction.

What if we have:

... we'd probably only want to collapse levels missing from the full tree, and squash the h6 to what would be an h4.

A generic algorithm that handles unexpected hierarchies should be possible. I'll try this after I get some more browsers supported. :smile: