This module encompasses a parser for BibTeX files
and an API to the individual BibTeX objects:
String
, Preamble
, Comment
, and
Entry
.
Copyright © 2010-2014 Sylvester Keil
GNU GPL 3.0
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 26 def open(file, options = {}, &block) Bibliography.open(file, options, &block) end
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 32 def parse(string, options = {}, &block) case when string.length < 260 && File.exist?(string) Bibliography.open(string, options, &block) when string =~ /\A[a-z]+:\/\// Bibliography.open(string, options) else Bibliography.parse(string, options) end end
# File lib/bibtex/compatibility.rb, line 10 def self.transliterate(str) @iconv.iconv(str) end
Returns true if the given file is a valid BibTeX bibliography.
# File lib/bibtex/utilities.rb, line 44 def valid?(file) Bibliography.open(file).valid? end