public
Created

Pandoc CSL Tests for citeproc-js

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
require 'bibtex'
require 'citeproc/js'
 
repo = 'https://raw.github.com/citation-style-language/styles/master/'
data = BibTeX.open('http://johnmacfarlane.net/pandoc/csltest/biblio.bib')
 
# styles to test
styles = %w{ aaa apa ama }
 
styles.each do |style|
 
puts style
 
# create processor
p = CiteProc::Processor.new :style => "#{repo}#{style}.csl"
 
# register input data
data.to_citeproc.each { |d| p << d }
# generate citations
puts p.append(:id => 'item1').inspect
puts p.append(:id => 'item2', :locator => 'p. 30').inspect
puts p.append(:id => 'item3', :locator => 'p. 30', :suffix => 'and nowhere else').inspect
# generate bibliography
puts p.bibliography.join
puts
end
output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
aaa
[[0, "(Doe 2005)"]]
[[0, "(Doe 2005)"], [1, "(Doe 2006:p. 30)"]]
[[0, "(Doe 2005)"], [1, "(Doe 2006:p. 30)"], [2, "(Doe and Roe 2007:p. 30 and nowhere else)"]]
<div class="csl-bib-body">
<div class="csl-entry">
 
<div class="csl-block">Doe, John</div>
 
<div class="csl-left-margin"> 2005</div><div class="csl-right-inline">First Book. Cambridge: Cambridge University Press.</div>
</div>
 
<div class="csl-entry">
<div class="csl-left-margin"> 2006</div><div class="csl-right-inline">Article. Journal of Generic Studies.</div>
</div>
 
<div class="csl-entry">
 
<div class="csl-block">Doe, John, and Jenny Roe</div>
 
<div class="csl-left-margin"> 2007</div><div class="csl-right-inline">Why Water Is Wet. <i>In</i> Third Book. Sam Smith, ed. Oxford: Oxford University Press.</div>
</div>
</div>
 
apa
[[0, "(Doe, 2005)"]]
[[0, "(Doe, 2005)"], [1, "(Doe, 2006, p. p. 30)"]]
[[0, "(Doe, 2005)"], [1, "(Doe, 2006, p. p. 30)"], [2, "(Doe &#38; Roe, 2007, p. p. 30 and nowhere else)"]]
<div class="csl-bib-body">
<div class="csl-entry">Doe, J. (2005). <i>First Book</i>. Cambridge: Cambridge University Press.</div>
 
<div class="csl-entry">Doe, J. (2006). Article. <i>Journal of Generic Studies</i>.</div>
 
<div class="csl-entry">Doe, J., &#38; Roe, J. (2007). Why Water Is Wet. In S. Smith (Ed.), <i>Third Book</i>. Oxford: Oxford University Press.</div>
</div>
 
ama
[[0, "<sup>1</sup>"]]
[[1, "<sup>2(pp. 30)</sup>"]]
[[2, "<sup>3(pp. 30) and nowhere else</sup>"]]
<div class="csl-bib-body">
<div class="csl-entry">1. Doe J. <i>First Book</i>. Cambridge: Cambridge University Press; 2005.</div>
 
<div class="csl-entry">2. Doe J. Article. <i>Journal of Generic Studies</i>. 2006;6:33-34.</div>
 
<div class="csl-entry">3. Doe J, Roe J. Why Water Is Wet. In: Smith S, ed. <i>Third Book</i>. Oxford: Oxford University Press; 2007.</div>
</div>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.