module AnyStyle::Format::CSL
Public Instance Methods
dates_to_citeproc(hash, date_format: 'edtf', **opts)
click to toggle source
# File lib/anystyle/format/csl.rb 28 def dates_to_citeproc(hash, date_format: 'edtf', **opts) 29 date, = *hash.delete(:date) 30 31 case date_format.to_s 32 when 'citeproc' 33 hash[:issued] = begin 34 require 'citeproc' 35 ::CiteProc::Date.parse!(date.tr('X~', 'u?')).to_citeproc.symbolize_keys 36 rescue 37 { raw: date } 38 end 39 else 40 hash[:issued] = date 41 end 42 end
format_csl(dataset, **opts)
click to toggle source
# File lib/anystyle/format/csl.rb 4 def format_csl(dataset, **opts) 5 format_hash(dataset).map do |hash| 6 dates_to_citeproc(hash, **opts) if hash.key?(:date) 7 flatten_values hash, skip: Normalizer::Names.keys 8 9 rename_value hash, :pages, :page 10 rename_value hash, :location, :'publisher-place' 11 rename_value hash, :url, :URL 12 rename_value hash, :doi, :DOI 13 rename_value hash, :pmid, :PMID 14 rename_value hash, :pmcid, :PMCID 15 16 Normalizer::Names.keys.each do |role| 17 if hash.key?(role) 18 hash[role].reject! { |name| name[:others] } 19 end 20 end 21 22 hash 23 end 24 end
Also aliased as: format_citeproc