Sha256: 1b9d0854950c814dbe7a023578492ae53bc1e23cd8116db0906b51e10b4ce092

Contents?: true

Size: 641 Bytes

Versions: 8

Compression:

Stored size: 641 Bytes

Contents

require 'nokogiri'
require 'table_of_contents/parser'

module Jekyll
  module TableOfContentsFilter
    def toc_only(html)
      return html unless page['toc']

      ::Jekyll::TableOfContents::Parser.new(html).build_toc
    end

    def inject_anchors(html)
      return html unless page['toc']

      ::Jekyll::TableOfContents::Parser.new(html).inject_anchors_into_html
    end

    def toc(html)
      return html unless page['toc']

      ::Jekyll::TableOfContents::Parser.new(html).toc
    end

    private

    def page
      @context.registers[:page]
    end
  end
end

Liquid::Template.register_filter(Jekyll::TableOfContentsFilter)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
jekyll-toc-0.4.0 lib/jekyll-toc.rb
jekyll-toc-0.4.0.rc2 lib/jekyll-toc.rb
jekyll-toc-0.4.0.rc lib/jekyll-toc.rb
jekyll-toc-0.3.0 lib/jekyll-toc.rb
jekyll-toc-0.3.0.pre1 lib/jekyll-toc.rb
jekyll-toc-0.2.1 lib/jekyll-toc.rb
jekyll-toc-0.2.0 lib/jekyll-toc.rb
jekyll-toc-0.1.1 lib/jekyll-toc.rb