BibTeX.jl
BibTeX.Bibliography
BibTeX.Citation
BibTeX.parse_bibtex
BibTeX.search_latex_directive
BibTeX.simplify_latex
BibTeX.strip_argument
BibTeX.Citation
— Type.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
.
BibTeX.Bibliography
— Method.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
.
BibTeX.parse_bibtex
— Method.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
[...]
BibTeX.search_latex_directive
— Function.search_latex_directive(astring, start_position = 1, inbrace=false)
Search for a LaTeX directive \directive{argument} or similar in string
, returning (start_position, directive_end, argument_end)
such that string[start_position:directive_end]
gives \directive
and string[directive_end+1:argument_end]
gives {argument}
. Use strip_argument
to remove surrounding braces and whitespace from the argument
.
BibTeX.simplify_latex
— Function.simplify_latex(astring, extra_directives)
Simplify a LaTeX string astring
into "plain text" if possible, stripping/converting known LaTeX directives in favor of e.g Unicode.
extra_directives
is a dictionary (String=>String
) that maps LaTeX directives to replacements. It defaults to BibTeX.text_directives
, which simply strips out things like bold and italics. Alternatively, you can pass BibTeX.markdown_directives
, which uses Markdown syntax for such directives.
BibTeX.strip_argument
— Function.strip_argument(astring, start_position = start(astring), end_position = endof(astring))
Return the substring of astring
corresponding to the argument from start_position:end_position
, stripping leading/trailing whitespace and braces.