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, render

Constructor Details

This class inherits a constructor from Mdtoc::Node

Instance Method Details

#headersObject



69
70
71
72
73
74
75
# File 'lib/mdtoc/node.rb', line 69

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