Sha256: 8bccd37f4f92b79117d11c240dd0f71d3e5a7e1fb8343f647b8aac6e1d6933dd
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# PageTocFilter Inserts a table of contents on a page via the [`HTML::Pipeline`](https://github.com/jch/html-pipeline). ## Installation Add this line to your application's Gemfile: ``` ruby gem 'page-toc-filter' ``` And then execute: $ bundle Or install it yourself as: $ gem install page-toc-filter ## Usage The simplest way to do this is ``` ruby require 'page-toc-filter' ``` Then, place this filter *after* you've rendered your content through the Markdown and TOC filters: ``` ruby pipeline = HTML::Pipeline.new([ HTML::Pipeline::MarkdownFilter, HTML::Pipeline::TableOfContentsFilter, HTML::Pipeline::PageTocFilter ]) ``` Then, on your page, enter the text `{:toc}` to have it replaced by a table of contents. By default, only `h2` headings will be converted into a table of contents. You can change this with the optional `toc_levels` setting, which should be a comma-separated string of heading levels. For example: ``` ruby pipeline = HTML::Pipeline.new([ HTML::Pipeline::MarkdownFilter, HTML::Pipeline::TableOfContentsFilter, HTML::Pipeline::PageTocFilter ], { :toc_levels => 'h2, h3' }) ```
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
page-toc-filter-0.2.1 | README.md |
page-toc-filter-0.2.0 | README.md |
page-toc-filter-0.1.0 | README.md |