lib/biblicit/parscit.rb in biblicit-2.0.8 vs lib/biblicit/parscit.rb in biblicit-2.1.0

- old
+ new

@@ -24,14 +24,32 @@ private def parse(xml) parsed = xml.css("algorithm[name=ParsHed]") - { + + result = { title: parsed.css('title').text.gsub(/\s+/,' ').strip, authors: parsed.css('author').map { |a| a.text.gsub(/\s+/,' ').strip }, abstract: parsed.css('abstract').text } + + citations = xml.css('algorithm[name=ParsCit] > citationList > citation').map do |node| + cite = { + authors: node.css('author').map(&:text).map(&:strip).reject(&:blank?).uniq + } + + node.children.each do |child| + unless ['contexts','authors','marker','rawString'].include?(child.name) || (text = child.text.strip).blank? + cite[child.name.to_sym] = text + end + end + + cite + end + + result[:citations] = citations + result end end end