Skip to content

Commit

Permalink
Merge pull request #2204 from Omikhleia/fix-csl-december
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque authored Jan 2, 2025
2 parents a3de042 + 5e6e745 commit 40c2890
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
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

0 comments on commit 40c2890

Please sign in to comment.