Home

BibTeX.jl

BibTeX.CitationType.
Citation{S}(data::Dict{String,String})

A bibliography item in a bibTeX database, based on a dictionary of strings to values. It is parameterized by a symbol S giving the type of the item (:article etcetera). A b::Citation supports b[key] access to retrieve the data and in general acts like a dictionary from String to String.

source
Bibliography(bibtex::String)
Bibliography(io::IO)

Given a string (or IO stream) of bibtex-format bibliography data, parses the data and returns a Dict-like object b::Bibliography that behaves as a dictionary mapping strings to bibliography items Citation.

source
parse_bibtex(text)

This is a simple input parser for BibTex. I had trouble finding a standard specification, but I've included several features of real BibTex. Returns a preamble (or an empty string) and a dict of dicts.

julia> using BibTeX: parse_bibtex

julia> preamble, result = parse_bibtex("""
            @preamble{some instructions}
            @comment blah blah
            @string{short = long}
            @a{b,
              c = {{c} c},
              d = "d {"} d",
              e = f # short
            }
            """);

julia> preamble
"some instructions"

julia> result["b"]["__type__"]
"a"

julia> result["b"]["c"]
"{c} c"

julia> result["b"]["d"]
"d {\"} d"

julia> result["b"]["e"]
"f short"

julia> parse_bibtex("@book")
ERROR: Expected { on line 1
[...]

julia> parse_bibtex("@book@")
ERROR: Expected { on line 1
[...]

Repeated fields and keys are not allowed:

julia> using BibTeX: parse_bibtex

julia> parse_bibtex("""
            @book{abook,
                title = A}
            @book{abook,
                title = B}
        """)
ERROR: Duplicated id abook on line 3
[...]

julia> parse_bibtex("""
            @book{abook,
                title = A,
                title = B}
        """)
ERROR: Duplicated field title on line 3
[...]
source