Class: Mdtoc::FileNode

Inherits:
Node
  • Object
show all
Defined in:
lib/mdtoc/node.rb

Instance Method Summary collapse

Methods inherited from Node

for_path, #initialize, #label

Constructor Details

This class inherits a constructor from Mdtoc::Node

Instance Method Details

#headersObject



59
60
61
62
63
64
65
# File 'lib/mdtoc/node.rb', line 59

def headers
  parser = Markdown::Parser.new(@depth, @path)
  headers = parser.headers(File.foreach(@path))
  return headers if headers[0]&.top_level?(@depth)

  headers.unshift(Mdtoc::Markdown::Header.new(@depth, label, @path))
end