lib/brief/document/section/builder.rb in brief-1.4.4 vs lib/brief/document/section/builder.rb in brief-1.5.0

- old
+ new

@@ -59,15 +59,17 @@ source.compact! @cycles += 1 end - self.nodes = source.map(&:last) + self.nodes = source.map(&:last).flatten nodes.each do |node| parent = node.css('section, article').first - if %w(h1 h2 h3 h4 h5 h6).include?(parent.children.first.name) - parent['data-heading'] = parent.children.first.text + parents_first_el = parent.children.first + + if parents_first_el && %w(h1 h2 h3 h4 h5 h6).include?(parent.children.first.name) + parent['data-heading'] = parents_first_el.text end end nodes.map!(&:to_html) end