Class: Diamante::Parser
- Inherits:
-
Object
- Object
- Diamante::Parser
- Defined in:
- lib/diamante/md/parser.rb
Class Method Summary collapse
Class Method Details
.call(filepath) ⇒ Object
5 6 7 |
# File 'lib/diamante/md/parser.rb', line 5 def self.call(filepath) parse(load(filepath)) end |
.load(filepath) ⇒ Object
11 12 13 14 15 |
# File 'lib/diamante/md/parser.rb', line 11 def self.load(filepath) content = File.read(filepath) doc = Kramdown::Document.new(content) root = doc.root end |
.parse(root) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/diamante/md/parser.rb', line 17 def self.parse(root) sections = {} title = :init root.children.each do |elem| if elem.type == :header title = elem.[:raw_text] || "Sin tÃtulo" sections[title] = [] elsif title == :init # nothing # pp elem else sections[title] << elem end end sections end |