Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Pandoc CSL Tests for citeproc-js
require 'bibtex'
require 'citeproc/js'
repo = ''
data ='')
# styles to test
styles = %w{ aaa apa ama }
styles.each do |style|
puts style
# create processor
p = :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
[[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 class="csl-entry">
<div class="csl-left-margin"> 2006</div><div class="csl-right-inline">Article. Journal of Generic Studies.</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>
[[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>
[[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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.