0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Generates a table of contents for a single page, via HTML::Pipeline.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.8
~> 1.10.0
>= 0

Runtime

 Project Readme

PageTocFilter

Inserts a table of contents on a page via the HTML::Pipeline.

Installation

Add this line to your application's Gemfile:

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

require 'page-toc-filter'

Then, place this filter after you've rendered your content through the Markdown and TOC filters:

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:

pipeline = HTML::Pipeline.new([
  HTML::Pipeline::MarkdownFilter,
  HTML::Pipeline::TableOfContentsFilter,
  HTML::Pipeline::PageTocFilter
], { :toc_levels => 'h2, h3' })