Sha256: f7c5836f09a70f7d6621d047125aa3144e21ea9e63421027aef03da4e91a6fa7
Contents?: true
Size: 876 Bytes
Versions: 1
Compression:
Stored size: 876 Bytes
Contents
require "nokogiri" module BibTeX class Bibliography attr_accessor :filepath class << self def trim_unnecessary_entries!(bib, citekeys) bib.entries.each do |k,v| if !citekeys.include? k bib.delete(k) end end end def from_bcf(path) File.open(path, "r") do |f| @bcf = Nokogiri::XML(f).remove_namespaces! end filepath = File.dirname(path) + "/" + @bcf.at_xpath("//datasource").content citekeys = @bcf.xpath("//citekey", 'bcf'=>'URI').map(&:content) bib = open(filepath, :filter => 'latex') bib.filepath = filepath trim_unnecessary_entries!(bib, citekeys) bib.sort! { |a,b| a.author <=> b.author } bib.extend(BibtexMunge) bib.fix_everything! return bib end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bibtex_munge-0.0.1 | lib/bibtex_munge/bcf.rb |