Class: Danger::Toc::Extractor
- Inherits:
-
Kramdown::Converter::Base
- Object
- Kramdown::Converter::Base
- Danger::Toc::Extractor
- Defined in:
- lib/toc/extractor.rb
Instance Method Summary collapse
- #convert(el) ⇒ Object
-
#initialize(root, options) ⇒ Extractor
constructor
A new instance of Extractor.
Constructor Details
Instance Method Details
#convert(el) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/toc/extractor.rb', line 13 def convert(el) if el.type == :header && el.[:raw_text] == Danger::Toc.config.header @in_toc = true @toc_start = el.[:location] elsif el.type == :header @toc_end = el.[:location] if @in_toc && !@toc_end @in_toc = false else el.children.each { |child| convert(child) } end [@toc_start, @toc_end] end |