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

CSL fixes (subsequent-author-substitute, LDoc typings) #2204

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions packages/bibtex/csl/engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ function CslEngine:_init (style, locale, extras)
}

self.subsequentAuthorSubstitute = self.inheritable["bibliography"]["subsequent-author-substitute"]
local _, count = luautf8.gsub(self.subsequentAuthorSubstitute, "[%-_–—]", "") -- naive count
if count > 0 then
-- With many fonts, a sequence of dashes is not looking that great.
-- So replace them with a command, and let the typesetter decide for a better rendering.
-- NOTE: Avoid (quoted) attributes and dashes in tags, as some global
-- substitutions might affect quotes...So we use a simple "wrapper" command.
local trail = luautf8.gsub(self.subsequentAuthorSubstitute, "^[%-–—_]+", "")
self.subsequentAuthorSubstitute = "<bibRule>" .. count .. "</bibRule>" .. trail
if self.subsequentAuthorSubstitute then
local _, count = luautf8.gsub(self.subsequentAuthorSubstitute, "[%-_–—]", "") -- naive count
if count > 0 then
-- With many fonts, a sequence of dashes is not looking that great.
-- So replace them with a command, and let the typesetter decide for a better rendering.
-- NOTE: Avoid (quoted) attributes and dashes in tags, as some global
-- substitutions might affect quotes...So we use a simple "wrapper" command.
local trail = luautf8.gsub(self.subsequentAuthorSubstitute, "^[%-–—_]+", "")
self.subsequentAuthorSubstitute = "<bibRule>" .. count .. "</bibRule>" .. trail
end
end
end

Expand Down Expand Up @@ -1490,15 +1492,15 @@ function CslEngine:_process (entries, mode)
end

--- Generate a citation string.
-- @tparam table entry List of CSL entries
-- @tparam table entries List of CSL entries
-- @treturn string The XML citation string
function CslEngine:cite (entries)
entries = type(entries) == "table" and not entries.type and entries or { entries }
return self:_process(entries, "citation")
end

--- Generate a reference string.
-- @tparam table entry List of CSL entries
-- @tparam table entries List of CSL entries
-- @treturn string The XML reference string
function CslEngine:reference (entries)
entries = type(entries) == "table" and not entries.type and entries or { entries }
Expand Down
1 change: 0 additions & 1 deletion packages/bibtex/csl/locale.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ end
--- Lookup an ordinal term in the locale.
-- Reserved for ordinal terms.
-- @tparam number number The numeric value to be formatted
-- @tparam string name The name of the term
-- @tparam string form The form of the term (default: "short")
-- @tparam string genderf The gender-form of the term (default: "neuter")
-- @tparam boolean plural Whether to return the plural form (default: false)
Expand Down
Loading