Sha256: 2a72ee55d68a7f270c70b2f1eeafb8809f9dad2c7b20db91d1d275b30155376f

Contents?: true

Size: 677 Bytes

Versions: 4

Compression:

Stored size: 677 Bytes

Contents

require 'rubygems'
require 'bibtex'


# Open a bibliography file
bib = BibTeX::Bibliography.open(File.expand_path('../markdown.bib',__FILE__),
  :include => [:meta_comments])


# Convert the BibTeX entries into a simple text format
content = bib.data.map do |d|
  result = ''
  
  if d.class == BibTeX::Entry
    d.replace!(bib.strings)
    result = [d[:author], '. ', d[:title], '. ', d[:publisher], ': ', d[:address], ', ', d[:year], '.'].join
  end
  
  if d.class == BibTeX::MetaComment
    result = d.to_s
  end
  
  result
end

# Convert all non BibTeX text (i.e., the `meta comments') using the maruku gem
require 'maruku'
puts Maruku.new(content.join).to_html_document

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bibtex-ruby-1.1.2 examples/bib2html.rb
bibtex-ruby-1.1.1 examples/bib2html.rb
bibtex-ruby-1.1.0 examples/bib2html.rb
bibtex-ruby-1.0.0 examples/bib2html.rb