lib/jekyll-toc.rb in jekyll-toc-0.12.0.rc1 vs lib/jekyll-toc.rb in jekyll-toc-0.12.0.rc2
- old
+ new
@@ -3,22 +3,25 @@
require 'nokogiri'
require 'table_of_contents/configuration'
require 'table_of_contents/parser'
module Jekyll
- # class TocTag < Liquid::Tag
- # def render(context)
- # return unless context.registers[:page]['toc']
- #
- # content_html = context.registers[:page].content
- # ::Jekyll::TableOfContents::Parser.new(content_html).build_toc
- # end
- # end
+ # toc tag for Jekyll
+ class TocTag < Liquid::Tag
+ def render(context)
+ return '' unless context.registers[:page]['toc']
+ content_html = context.registers[:page].content
+ ::Jekyll::TableOfContents::Parser.new(content_html).build_toc
+ end
+ end
+
# Jekyll Table of Contents filter plugin
module TableOfContentsFilter
def toc_only(html)
+ Jekyll.logger.warn 'Deprecation: toc_only filter is deprecated and will be remove in jekyll-toc v1.0.',
+ 'Use `{% toc %}` instead of `{{ contents | toc_only }}`.'
return '' unless toc_enabled?
::Jekyll::TableOfContents::Parser.new(html, toc_config).build_toc
end
@@ -45,6 +48,6 @@
end
end
end
Liquid::Template.register_filter(Jekyll::TableOfContentsFilter)
-# Liquid::Template.register_tag('toc', Jekyll::TocTag) # will be enabled at v1.0
+Liquid::Template.register_tag('toc', Jekyll::TocTag) # will be enabled at v1.0