Sha256: 5670a6bb7315a4c67b085e7459a8b1715e71ead537146882342f76fe951c3430

Contents?: true

Size: 948 Bytes

Versions: 13

Compression:

Stored size: 948 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', __dir__),
                  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

13 entries across 13 versions & 2 rubygems

Version Path
bibtex-ruby-6.1.0 examples/bib2html.rb
bibtex-ruby-6.0.0 examples/bib2html.rb
bibtex-ruby-5.1.6 examples/bib2html.rb
bibtex-ruby-5.1.5 examples/bib2html.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/bibtex-ruby-5.1.4/examples/bib2html.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/bibtex-ruby-5.1.4/examples/bib2html.rb
bibtex-ruby-5.1.4 examples/bib2html.rb
bibtex-ruby-5.1.3 examples/bib2html.rb
bibtex-ruby-5.1.2 examples/bib2html.rb
bibtex-ruby-5.1.1 examples/bib2html.rb
bibtex-ruby-5.1.0 examples/bib2html.rb
bibtex-ruby-5.0.1 examples/bib2html.rb
bibtex-ruby-5.0.0 examples/bib2html.rb