class AsciidoctorBibliography::Formatter

Public Class Methods

new(style, locale: "en-US") click to toggle source
Calls superclass method
# File lib/asciidoctor-bibliography/formatter.rb, line 9
def initialize(style, locale: "en-US")
  super style: style, format: :adoc, locale: locale
end

Public Instance Methods

force_sort!(mode:) click to toggle source
# File lib/asciidoctor-bibliography/formatter.rb, line 23
def force_sort!(mode:)
  # Valid modes are :citation and :bibliography
  engine.sort! data, engine.style.send(mode).sort_keys if engine.style.send(mode).sort?
end
replace_bibliography_sort(array) click to toggle source
# File lib/asciidoctor-bibliography/formatter.rb, line 13
def replace_bibliography_sort(array)
  new_keys = array.map(&::CSL::Style::Sort::Key.method(:new))
  new_sort = ::CSL::Style::Sort.new.add_children(*new_keys)

  bibliography = engine.style.find_child("bibliography")
  bibliography.find_child("sort")&.unlink

  bibliography.add_child new_sort
end