module AsciidoctorBibtex::CitationUtils

Some utility functions used in Citations class

Public Class Methods

arrange_authors(authors, surname_first) click to toggle source

arrange author string, flag for order of surname/initials

# File lib/asciidoctor-bibtex/citation_utils.rb, line 12
def self.arrange_authors(authors, surname_first)
  return [] if authors.nil?

  authors.split(/\band\b/).collect do |name|
    if name.include?(', ')
      parts = name.strip.rpartition(', ')
      if surname_first
        "#{parts[0]}, #{parts[2]}"
      else
        "#{parts[2]} #{parts[0]}"
      end
    else
      name
    end
  end
end
author_chicago(authors) click to toggle source

Arrange given author string into Chicago format

# File lib/asciidoctor-bibtex/citation_utils.rb, line 30
def self.author_chicago(authors)
  arrange_authors authors, true
end