blob: 50caf714b3d48024bed23426e1017bf43a0f2cff (
plain)
- --[[
- stylish-roles - provide existence hints for attributes and CrediT roles
- as authors[*].metadata.credit[role], by-author[*].metadata.credit[role],
- some-author-has[*].credit[role] and some-author-has.attributes[attribute].
- Copyright: © 2024 Jonas Smedegaard <dr@jones.dk
- License: MIT – see LICENSE file for details
- ]]
- function Meta(meta)
- local attributes = {"corresponding", "equal-contributor"}
- for _, author in ipairs(meta.authors) do
- if author.roles then
- local _by = meta["by-author"][tonumber(author.number)]
- local _some = meta["some-author-has"]
- for _, role in ipairs(author.roles) do
- if role["vocab-term"] then
- -- create if missing
- author.metadata.credit = author.metadata.credit or {}
- _by.metadata.credit = _by.metadata.credit or {}
- meta["some-author-has"] = meta["some-author-has"] or {}
- meta["some-author-has"].credit = meta["some-author-has"].credit or {}
- author.metadata.credit[role["vocab-term"]] = true
- _by.metadata.credit[role["vocab-term"]] = true
- meta["some-author-has"].credit[role["vocab-term"]] = true
- -- debugging aid
- --error(pandoc.utils.stringify(author.name.literal)
- -- .. " does " .. role["vocab-term"] .. ".")
- end
- end
- for _, attr in ipairs(attributes) do
- if author.attributes and author.attributes[attr] then
- -- create if missing
- meta["some-author-has"].attributes = meta["some-author-has"].attributes or {}
- meta["some-author-has"].attributes[attr] = true
- end
- end
- end
- end
- -- debugging aid
- --quarto.utils.dump(meta)
- --quarto.utils.dump(meta["authors"])
- --quarto.utils.dump(meta["by-author"])
- --quarto.utils.dump(meta["some-author-has"])
- return meta
- end
|