Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bibliography package improvements on BibTeX syntax #2048

Merged
merged 9 commits into from
Jun 23, 2024
4 changes: 3 additions & 1 deletion packages/bibtex/bibliography.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ do
von_start, last_lim, jr_lim, first_start, first_lim = 1, commas[1], commas[2], commas[2], n + 1
divide_von_from_last()
else
SU.error("Too many commas in name '%s'")
SU.error(("Too many commas in name '%s'"):format(str))
end
-- <set fields of name based on [[first_start]] and friends>=
-- We set long and short forms together; [[ss]] is the
Expand Down Expand Up @@ -286,6 +286,7 @@ Bibliography = {
produceCitation = function (cite, bib, style)
local item = bib[cite.key]
if not item then
-- Should have been already checked by the caller
return Bibliography.Errors.UNKNOWN_REFERENCE
end
local t = Bibliography.buildEnv(cite, item.attributes, style)
Expand All @@ -296,6 +297,7 @@ Bibliography = {
produceReference = function (cite, bib, style)
local item = bib[cite.key]
if not item then
-- Should have been already checked by the caller
return Bibliography.Errors.UNKNOWN_REFERENCE
end
item.type = item.type:gsub("^%l", string.upper)
Expand Down
60 changes: 60 additions & 0 deletions packages/bibtex/bibmaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- Mappings for aliases and inheritance rules

-- Partial implementation of the Biber/BibLaTeX data inheritance rules
-- (derived from the biblatex package manual v3.20, appendix A)
-- FIXME: This is not complete
local crossrefmap = {
book = {
inbook = {
author = "author", -- inbook inherits author from book author
bookauthor = "author", -- inbook inherits bookauthor from book author
indexsorttitle = false, -- inbook skips (=does not inherit) indexsorttitle from book
indextitle = false,
shorttitle = false,
sorttitle = false,
subtitle = "booksubtitle",
title = "booktitle",
titleaddon = "booktitleaddon",
},
},
periodical = {
article = {
indexsorttitle = false,
indextitle = false,
shorttitle = false,
sorttitle = false,
subtitle = "journalsubtitle",
title = "journaltitle",
titleaddon = "journaltitleaddon",
},
},
proceedings = {
inproceedings = {
indexsorttitle = false,
indextitle = false,
shorttitle = false,
sorttitle = false,
subtitle = "booksubtitle",
title = "booktitle",
titleaddon = "booktitleaddon",
},
},
}

-- biblatex field aliases
-- From biblatex package manual v3.20, section 2.2.5
local fieldmap = {
address = "location",
annote = "annotation",
archiveprefix = "eprinttype",
key = "sortkey",
pdf = "file",
journal = "journaltitle",
primaryclass = "eprintclass",
school = "institution",
}

return {
crossrefmap = crossrefmap,
fieldmap = fieldmap,
}
Loading
Loading