gfranko / jquery.tocify.js

A jQuery Table of Contents plugin that can be themed with Twitter Bootstrap or jQueryUI.
http://gregfranko.com/jquery.tocify.js/
MIT License
928 stars 216 forks source link

Find all subheaders between headers regardless if they are siblings or children #107

Open BoPeng opened 6 years ago

BoPeng commented 6 years ago

I encountered a similar problem with https://github.com/gfranko/jquery.tocify.js/issues/36. More specifically, I am adding TOCs to a bunch of jupyter notebooks whose headers are inside cells and have a structure like

cell -> h2
cell -> h3
cell -> h3
cell -> h2

tocify.js could not get the h3s because they are not children of h2. I checked the source code and find that this restriction is not really necessary so I modified the code to display all headers regardless if they are siblings or children.

The patch works but perhaps not using the best algorithm, but I would first like to know if there is any real reason for the restriction and if you are interested in merging the PR.