Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
see #97
  • Loading branch information
inukshuk committed Oct 14, 2014
1 parent eda5109 commit 5833277
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions examples/bib2html.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
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

begin
require 'citeproc'
rescue LoadError
puts 'this example depends on the citeproc-ruby gem'
exit
end
cp = CiteProc::Processor.new :style => 'apa',
:format => 'html', :locale => 'en'

cp.import bib.to_citeproc

content = bib.replace.q('@entry, @meta_content').map do |b|
if b.entry?
CiteProc.process b.to_citeproc
content = bib['@entry, @meta_content'].map do |e|
if e.entry?
cp.render :bibliography, :id => e.key
else
b.to_s
e.to_s
end
end

Expand Down
2 changes: 1 addition & 1 deletion examples/markdown.bib
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
============
Here is a little bibliography to illustrate how *BibTeX* and
*Markdown* can be seamlessly integrated. This is a _valid_ BibTex
*Markdown* can be seamlessly integrated. This is a _valid_ BibTeX
File; at the same time its comments are written using Markdown
markup. For example, this is a list:
Expand Down

0 comments on commit 5833277

Please sign in to comment.