Module: AsciidoctorBibtex::CitationUtils

Defined in:
lib/asciidoctor-bibtex/citation_utils.rb

Overview

Some utility functions used in Citations class

Class Method Summary collapse

Class Method Details

.arrange_authors(authors, surname_first) ⇒ Object

arrange author string, flag for order of surname/initials



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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) ⇒ Object

Arrange given author string into Chicago format



30
31
32
# File 'lib/asciidoctor-bibtex/citation_utils.rb', line 30

def self.author_chicago(authors)
  arrange_authors authors, true
end