Skip to content
This repository has been archived by the owner on Nov 26, 2019. It is now read-only.

Commit

Permalink
lower level way to use CiteProc::Ruby API, perhaps less overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
jrochkind committed Feb 28, 2018
1 parent 30f03f2 commit 0f12927
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions app/indexers/chf/generic_work_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ def self.csl_en_us_locale

def render_citation(work)
csl_data = CitableAttributes.new(work).as_csl_json.stringify_keys
citation_item = CiteProc::CitationItem.new(id: csl_data["id"]) do |c|
c.data = CiteProc::Item.new(csl_data)
end

cp = CiteProc::Processor.new(
style: self.class.csl_chicago_style,
locale: self.class.csl_en_us_locale,
format: 'html'
)
renderer = CiteProc::Ruby::Renderer.new :format => 'html',
:style => self.class.csl_chicago_style, :locale => self.class.csl_en_us_locale

cp.import [csl_data]
# safe to html_safe, CiteProc::Processor already escapes html in citation, I checked.
cp.render(:bibliography, id: csl_data["id"]).first
renderer.render citation_item, self.class.csl_chicago_style.bibliography
end

def remove_duplicates(field)
Expand Down

0 comments on commit 0f12927

Please sign in to comment.