lib/rpub/chapter.rb in rpub-0.3.0 vs lib/rpub/chapter.rb in rpub-0.4.0
- old
+ new
@@ -15,9 +15,14 @@
def initialize(content, number, layout)
@content, @number, @layout = content, number, layout
@document = Kramdown::Document.new(content, KRAMDOWN_OPTIONS.merge(:template => layout))
end
+
+ # @return [Kramdown::Element] Toc elements hierarchy
+ def toc
+ Kramdown::Converter::Toc.convert(@document.root).first
+ end
# @return [String] Unique identifier for this chapter.
def uid
@uid ||= Digest::SHA1.hexdigest([content, xml_id.to_s, layout].join)
end