Class HTML::Pipeline::TableOfContentsFilter
In: lib/html/pipeline/toc_filter.rb
Parent: Filter

HTML filter that adds an ‘id’ attribute to all headers in a document, so they can be accessed from a table of contents.

Generates the Table of Contents, with links to each header.

Examples

 TocPipeline =
   HTML::Pipeline.new [
     HTML::Pipeline::TableOfContentsFilter
   ]
 # => #<HTML::Pipeline:0x007fc13c4528d8...>
 orig = %(<h1>Ice cube</h1><p>is not for the pop chart</p>)
 # => "<h1>Ice cube</h1><p>is not for the pop chart</p>"
 result = {}
 # => {}
 TocPipeline.call(orig, {}, result)
 # => {:toc=> ...}
 result[:toc]
 # => "<ul class=\"section-nav\">\n<li><a href=\"#ice-cube\">...</li><ul>"
 result[:output].to_s
 # => "<h1>\n<a id=\"ice-cube\" class=\"anchor\" href=\"#ice-cube\">..."

Methods

Constants

PUNCTUATION_REGEXP = RUBY_VERSION > '1.9' ? /[^\p{Word}\- ]/u : /[^\w\- ]/

Public Instance methods

The icon that will be placed next to an anchored rendered markdown header

[Validate]