Style

Style

Julia Format

Example

using BibTeX
using BibTeXFormat

bibliography = Bibliography(readstring(joinpath(Pkg.dir("BibTeXFormat"),
                             "test/Clustering.bib")))
formatted_entries = format_entries(AlphaStyle,bibliography)
HTMLoutput        = write_to_string( HTMLBackend(),formatted_entries )

Alpha Style

Config(label_style = AlphaLabelStyle(),sorting_style = AuthorYearTitleSortingStyle())

source

PlainAlphaStyle

source

UNSRTAlphaStyle

Config(label_style = AlphaLabelStyle())

source
function format_entries(b::T, entries::Dict) where T <: BaseStyle

Format a Dict of entries with a given style b::T where T <: BaseStyle

using BibTeX
using BibTeXFormat
bibliography      = Bibliography(readstring("test/Clustering.bib"))
formatted_entries = format_entries(AlphaStyle,bibliography)
source
function format_entry(b::T, label, entry::Citation) where T <: BaseStyle
source
function format_entry(b::T, label, entry) where T <: BaseStyle

Format an entry with a given style b::T where T <: BaseStyle

source

Expand wildcard citations (\citation{*} in .aux file).

julia> using BibTeX

julia> import BibTeXFormat: expand_wildcard_citations, Citation, Bibliography

julia> data = Bibliography("", Dict{String,Citation}("uno"=>Citation{:article}(),"dos"=>Citation{:article}(),"tres"=>Citation{:article}(),	"cuatro"=>Citation{:article}()));

julia> expand_wildcard_citations(data, [])
0-element Array{Any,1}

julia> print(expand_wildcard_citations(data, ["*"]))
Any["tres", "dos", "uno", "cuatro"]
julia> print(expand_wildcard_citations(data, ["uno", "*"]))
Any["uno", "tres", "dos", "cuatro"]
julia> print(expand_wildcard_citations(data, ["dos", "*"]))
Any["dos", "tres", "uno", "cuatro"]
julia> print(expand_wildcard_citations(data, ["*", "uno"]))
Any["tres", "dos", "uno", "cuatro"]
julia> print(expand_wildcard_citations(data, ["*", "DOS"]))
Any["tres", "dos", "uno", "cuatro"]
source
function format_bibliography(self::T, bib_data, citations=nothing) where T<:BaseStyle

Format bibliography entries with the given keys Params:

  • self::T where T<:BaseStyle. The style
  • bib_data BibTeX.Bibliography
  • param citations: A list of citation keys.
using BibTeX
using BibTeXFormat
bibliography      = Bibliography(readstring("test/Clustering.bib"))

formatted_entries = format_entries(AlphaStyle,bibliography)
source

Get cititations not cited explicitly but referenced by other citations.

julia> using BibTeX

julia> import BibTeXFormat: get_crossreferenced_citations, Citation, Bibliography

julia> data = Bibliography("", Dict{String,Citation}("main_article"=>Citation{:article}(Dict("crossref"=>"xrefd_article")),"xrefd_article"=>Citation{:article}()));

julia> print(get_crossreferenced_citations(data, [], min_crossrefs=1))
Any[]
julia> print(get_crossreferenced_citations(data, ["main_article"], min_crossrefs=1))
Any["xrefd_article"]
julia> print(get_crossreferenced_citations(data,["Main_article"], min_crossrefs=1))
Any["xrefd_article"]
julia> print(get_crossreferenced_citations(data, ["main_article"], min_crossrefs=2))
Any[]
julia> print(get_crossreferenced_citations(data, ["xrefd_arcicle"], min_crossrefs=1))
Any[]
source
function transform(e::Citation, label)

Add some information to a BibTeX.Citation.

source

BST

using BibTeX
using BibTeXFormat
bibliography = Bibliography(readstring(joinpath(Pkg.dir("BibTeXFormat"), "test/Clustering.bib")))
style        = BST.parse_file(joinpath(Pkg.dir("BibTeXFormat"),"test/format/apacite.bst"))
latexOutput = format_entries(style, bibliography)

References

type Style <: BaseStyle

A Style obtained from a .bst file

source
function parse_file(filename::String)
source
function parse_string(content::String)
source
BibTeXFormat.BST.runFunction.
function run(self, citations, bib_files, min_crossrefs):

Run bst script and return formatted bibliography.

source

Strip the commented part of the line."

julia> print(strip_comment("a normal line"))
a normal line
julia> print(strip_comment("%"))

julia> print(strip_comment("%comment"))

julia> print(strip_comment("trailing%"))
trailing
julia> print(strip_comment("a normal line% and a comment"))
a normal line
julia> print(strip_comment(""100% compatibility" is a myth"))
"100% compatibility" is a myth
julia> print(strip_comment(""100% compatibility" is a myth% or not?"))
"100% compatibility" is a myth
source
function format_bibliography(self::Style, bib_data, citations=nothing)

Format bibliography entries with the given keys

Params:

  • style::Style. The BST style
  • bib_data
  • param citations: A list of citation keys.
source
function format_entries(b::Style, entries::Dict)

Format a Dict of entries with a given style b::Style

using BibTeX
using BibTeXFormat
bibliography      = Bibliography(readstring("test/Clustering.bib"))
style        = BST.parse_file(joinpath(Pkg.dir("BibTeXFormat"),"test/format/apacite.bst"))
formatted_entries = format_entries(style, bibliography)
source
function bst_join(words, tie="~", space=" ")

Join some words, inserting ties (~) when nessessary. Ties are inserted: - after the first word, if it is short - before the last word Otherwise space is inserted. Should produce the same oubput as BibTeX.

julia> import BibTeXFormat.BST: bst_join

julia> print(bst_join(["a", "long", "long", "road"]))
a~long long~road

julia> print(bst_join(["very", "long", "phrase"]))
very long~phrase

julia> print(bst_join(["De", "La"]))
De~La
source

Name formatting

BibTeX-like name formatting.

julia> import BibTeXFormat.BST: format_name

julia> name = "Charles Louis Xavier Joseph de la Vallee Poussin";

julia> print(format_name(name, "{vv~}{ll}{, jj}{, f.}"))
de~la Vallee~Poussin, C.~L. X.~J.
julia> name = "abc";

julia> print(format_name(name, "{vv~}{ll}{, jj}{, f.}"))
abc
julia> name = "Jean-Pierre Hansen";

julia> print(format_name(name, "{ff~}{vv~}{ll}{, jj}"))
Jean-Pierre Hansen
julia> print(format_name(name, "{f.~}{vv~}{ll}{, jj}"))
J.-P. Hansen
julia> name = "F. Phidias Phony-Baloney";

julia> print(format_name(name, "{v{}}{l}"))
P.-B
julia> print(format_name(name, "{v{}}{l.}"))
P.-B.
julia> print(format_name(name, "{v{}}{l{}}"))
PB
BibTeXFormat.formatFunction.
function format(self::LastFirstNameStyle, person, abbr=false)

Format names similarly to {vv~}{ll}{, jj}{, f.} in BibTeX.

julia> import BibTeXFormat: Person, render_as, LastFirstNameStyle, format

julia> import BibTeXFormat.TemplateEngine

julia> name = Person("Charles Louis Xavier Joseph de la Vall{\'e}e Poussin");

julia> lastfirst = LastFirstNameStyle();

julia> render_as(TemplateEngine.format(format(lastfirst,name)),"latex")
"de~la Vall{é}e~Poussin, Charles Louis Xavier~Joseph"

julia> render_as(TemplateEngine.format(format(lastfirst,name)),"html")
"de&nbsp;la Vall<span class="bibtex-protected">é</span>e&nbsp;Poussin, Charles Louis Xavier&nbsp;Joseph"

julia> render_as(TemplateEngine.format(format(lastfirst,name, true)),"latex")
"de~la Vall{é}e~Poussin, C.~L. X.~J."

julia> render_as(TemplateEngine.format(format(lastfirst,name, true)),"html")
"de&nbsp;la Vall<span class="bibtex-protected">é</span>e&nbsp;Poussin, C.&nbsp;L. X.&nbsp;J."

julia> name = Person(first="First", last="Last", middle="Middle");

julia> render_as(TemplateEngine.format(format(lastfirst,name)),"latex")
"Last, First~Middle"

julia> render_as(TemplateEngine.format(format(lastfirst,name, true)),"latex")
"Last, F.~M."
source
BibTeXFormat.formatFunction.

Format names similarly to {ff~}{vv~}{ll}{, jj} in BibTeX.

julia> import BibTeXFormat: Person, render_as, PlainNameStyle, format

julia> import BibTeXFormat.TemplateEngine

julia> name = Person("Charles Louis Xavier Joseph de la Vall{'e}e Poussin");

julia> plain = PlainNameStyle();

julia> render_as(TemplateEngine.format(format(plain, name)),"latex")
"Charles Louis Xavier~Joseph de~la Vall{é}e~Poussin"

julia> render_as(TemplatEngine.format(format(plain, name),"html"))
"Charles Louis Xavier&nbsp;Joseph de&nbsp;la Vall<span class="bibtex-protected">é</span>e&nbsp;Poussin"

julia> render_as(TemplateEngine.format(format(plain,name, true)), "latex")
"C.~L. X.~J. de~la Vall{é}e~Poussin"

julia> render_as(TemplateEngine.format(format(plain, name, true)),"html")
"C.&nbsp;L. X.&nbsp;J. de&nbsp;la Vall<span class="bibtex-protected">é</span>e&nbsp;Poussin"

julia> name = Person(first="First", last="Last", middle="Middle");

julia> render_as(TemplateEngine.format(format(plain, name)),"latex")
"First~Middle Last"

julia> render_as(TemplateEngine.format(format(plain,name, true)),"latex")
"F.~M. Last"

julia> render_as(TemplateEngine.format(format(plain,Person("de Last, Jr., First Middle"))),"latex")
"First~Middle de~Last, Jr."
source

Labels

Strip all non-alphanumerical characters from a list of strings.

julia> import BibTeXFormat: _strip_nonalnum

julia> print(_strip_nonalnum(["ÅA. B. Testing 12+}[.@~_", " 3%"]))
AABTesting123
source