diff --git a/index.md b/index.md index e9fb43d..a2531c5 100644 --- a/index.md +++ b/index.md @@ -92,11 +92,43 @@ All options are optional, unless otherwise indicated. ## Customization -The following options can be specified at the heading level via `data-toc-*` attributes. +### Headings + +By default, the plugin chooses the top-level navigation items by searching for headings at the first heading level, then works its way down (`

`, then `

`, etc.) It will stop when it finds the first set of headings where more than one exists at that level. For example: + +```html +

The title

+

Some sub-title

+... +

Section 1

+

Subsection A

+... +

Subsection B

+... +

Section 2

+``` + +The plugin would see there's only one `

`, then that there's only one `

`, then stop when it sees there's more than one `

`. The identified level becomes the top-level navigation items in the Table of Contents, and any headings under those (the `

`s in this case) would be the second-level navigation. + +This behavior can be customized with the `$scope` [option](#options). That jQuery object can be created with one or more selectors to force certain headings to be used. + +In the above example, let's say that you wanted the navigation to only contain the Subsections. You could pass: + +```javascript +Toc.init({ + $scope: $("h4") + // ... +}); +``` + +and the resulting Table of Contents would only contain: + +> * Subsection A +> * Subsection B ### Displayed text -By default, Bootstrap TOC will use the text from the heading element in the table of contents. If you want to customize what is displayed, add a `data-toc-text` attribute with the desired text. For example: +By default, Bootstrap TOC will use the text from the heading element in the table of contents. If you want to customize what is displayed, add a `data-toc-text` attribute to the heading with the desired text. For example: ```html

Longer text

@@ -106,7 +138,7 @@ displays "Longer text" as the heading, but "Short text" in the sidebar. ### Skipping -To prevent a particular heading from being added to the table of contents, add a `data-toc-skip` [boolean attribute](https://www.w3.org/TR/2008/WD-html5-20080610/semantics.html#boolean). +To prevent a particular heading from being added to the table of contents, add a `data-toc-skip` [boolean attribute](https://www.w3.org/TR/2008/WD-html5-20080610/semantics.html#boolean) to the heading. ```html

Some heading you don't want in the nav