/simple_toc

'simple-toc' makes a simple table of contents from DOM structure.

Primary LanguageRubyMIT LicenseMIT

SimpleToc

Gem Version MIT License

'simple-toc' makes a simple table of contents from DOM structure.

Installation

gem 'simple_toc'

And then execute:

$ bundle

Or install it yourself as:

$ gem install simple_toc

Usage

To require this plguin, add the following to your application.js:

//= require simpleToc

This plugin require jQuery.

$(function() {
  # simple case
  $('#toc').simpleToc();

  # advance case
  $('#toc').simpleToc({
      listType: '<ol/>',
      selectors: 'h1,h2,h3',
      prefix: 'toc',
  });
});
<div id="toc"></div>

<h2>hoge</h2>
<h2>fuga</h2>
<h3>fuga > fuga</h3>
<h2>piyo</h2>

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/miraoto/simple_toc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.