Sha256: 56aa7e3d8b745381ad77c5b4db162b55b1cb3eea440d6087b3f12d800492e469

Contents?: true

Size: 924 Bytes

Versions: 27

Compression:

Stored size: 924 Bytes

Contents

require 'rubygems'
require 'bibtex'

begin
  require 'citeproc/ruby'
  require 'csl/styles'
rescue LoadError
  puts 'this example depends on the citeproc-ruby and csl-styles gems'
  exit
end

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

# Replaces all strings in the Bibliography and then
# converts each BibTeX entries to a string using Chicago style
# (all other elements are mapped to simple strings)
bib.replace

cp = CiteProc::Processor.new :style => 'apa',
  :format => 'html', :locale => 'en'

cp.import bib.to_citeproc

content = bib['@entry, @meta_content'].map do |e|
  if e.entry?
    cp.render :bibliography, :id => e.key
  else
    e.to_s
  end
end


begin
  require 'redcarpet'
rescue LoadError
  puts 'this example depends on the redcarpet gem'
  exit
end

puts Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content.join)

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
bibtex-ruby-4.4.7 examples/bib2html.rb
bibtex-ruby-4.4.6 examples/bib2html.rb
bibtex-ruby-4.4.5 examples/bib2html.rb
bibtex_to_scrapbox-0.2.0 gems/gems/bibtex-ruby-4.4.4/examples/bib2html.rb
bibtex_to_scrapbox-0.1.0 gems/gems/bibtex-ruby-4.4.4/examples/bib2html.rb
bibtex-ruby-4.4.4 examples/bib2html.rb
bibtex-ruby-4.4.3 examples/bib2html.rb
bibtex-ruby-4.4.2 examples/bib2html.rb
bibtex-ruby-4.4.1 examples/bib2html.rb
bibtex-ruby-4.4.0 examples/bib2html.rb
bibtex-ruby-4.3.0 examples/bib2html.rb
bibtex-ruby-4.2.0 examples/bib2html.rb
bibtex-ruby-4.1.2 examples/bib2html.rb
bibtex-ruby-4.1.1 examples/bib2html.rb
bibtex-ruby-4.1.0 examples/bib2html.rb
bibtex-ruby-4.0.16 examples/bib2html.rb
bibtex-ruby-4.0.15 examples/bib2html.rb
bibtex-ruby-4.0.14 examples/bib2html.rb
bibtex-ruby-4.0.13 examples/bib2html.rb
bibtex-ruby-4.0.12 examples/bib2html.rb