dcneiner/TableOfContents — pull request #6 by aleray (2013-12-15 02:28:00+00:00)
Title: Extra filtering of headings

Hi, I've just added a new option for my own needs, the description is below. If you feel like it may be useful for others, feel free to merge. Also happy to feature it in the docs, and discuss it further.

Thanks for your plugin btw.

* * *

A new option to filter the headings we want to feature on the table of content.

It may be useful if, for instance, we want to exclude headings
that are within elements such as

or

. The value must
be a function, whose first argument is the jquery collection of headings
and that return a sub-collection.

An example: remove all the headings that are within an article element.

$("#toc").tableOfContents("#main-content", {
startLevel: 2,
depth: 1,
exclude: function ($headings, $scope) {
return $headings.not(function() { return $(this).parentsUntil($scope).is('article') })
}
});