module BibTeX

BibTeX

This module encompasses a parser for BibTeX files and an API to the individual BibTeX objects: String, Preamble, Comment, and Entry.

Author

Sylvester Keil

Copyright

Copyright © 2010-2014 Sylvester Keil

License

GNU GPL 3.0

Attributes

log[RW]

Public Class Methods

name(string)
Alias for: names
names(string) click to toggle source

Parses the given string as a BibTeX name value and returns a Names object.

# File lib/bibtex/utilities.rb, line 46
def names(string)
  Names.parse(string)
end
Also aliased as: name, parse_name, parse_names
open(file, options = {}, &block) click to toggle source

Opens a BibTeX file or URI and returns a corresponding Bibliography object or, if a block is given, yields the Bibliography to the block, ensuring that the file is saved.

# File lib/bibtex/utilities.rb, line 24
def open(file, options = {}, &block)
  Bibliography.open(file, options, &block)
end
parse(string, options = {}, &block) click to toggle source

Parses the given string and returns a corresponding Bibliography object. Delegates to ::open if the string is a filename or URI.

# File lib/bibtex/utilities.rb, line 30
def parse(string, options = {}, &block)
  if string.length < 260 && File.exist?(string)
    Bibliography.open(string, options, &block)
  elsif string =~ %r{\A[a-z]+://}i
    Bibliography.open(string, options)
  else
    Bibliography.parse(string, options)
  end
end
parse_name(string)
Alias for: names
parse_names(string)
Alias for: names
transliterate(str) click to toggle source
# File lib/bibtex/compatibility.rb, line 10
def self.transliterate(str)
  @iconv.iconv(str)
end
valid?(file) click to toggle source

Returns true if the given file is a valid BibTeX bibliography.

# File lib/bibtex/utilities.rb, line 41
def valid?(file)
  Bibliography.open(file).valid?
end