Module: Jekyll::TableOfContentsFilter

Includes:
Jekyll::TableOfContents::ConfigResolver
Defined in:
lib/jekyll-toc-plus.rb

Overview

Jekyll Table of Contents filter plugin

Instance Method Summary collapse

Instance Method Details

#inject_anchors(html) ⇒ Object



50
51
52
53
54
# File 'lib/jekyll-toc-plus.rb', line 50

def inject_anchors(html)
  return html unless toc_enabled?

  TableOfContents::Parser.new(html, toc_config).inject_anchors_into_html
end

#toc(html) ⇒ Object



56
57
58
59
60
# File 'lib/jekyll-toc-plus.rb', line 56

def toc(html)
  return html unless toc_enabled?

  TableOfContents::Parser.new(html, toc_config).toc
end

#toc_only(html) ⇒ Object

Renders the TOC only (no anchors injected into the content). Kept as a supported filter: unlike the toc % tag, it works on any page because it receives the content as input, whereas the tag reads page and therefore only works for Posts and Collections.



44
45
46
47
48
# File 'lib/jekyll-toc-plus.rb', line 44

def toc_only(html)
  return '' unless toc_enabled?

  TableOfContents::Parser.new(html, toc_config).build_toc
end