Skip to content

Commit

Permalink
Fix luatex
Browse files Browse the repository at this point in the history
  • Loading branch information
zepinglee committed Jul 19, 2024
1 parent 4964c4c commit 23bde1c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions citeproc/citeproc-latex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,12 @@ function CslCitationManager:bibliography(filter_str)
util.error("Refsection is not initialized.")
return
end
local bib_str = self:make_bibliography(filter_str)
tex.print(bib_str)
local bib_lines = self:make_bibliography(filter_str)
tex.print(util.split(table.concat(bib_lines, "\n"), "\n"))
end

---@param filter_str string
---@return string
---@return string[]
function CslCitationManager:make_bibliography(filter_str)
local engine = self.ref_section.engine
if not engine then
Expand All @@ -633,8 +633,6 @@ function CslCitationManager:make_bibliography(filter_str)
local params = result[1]
local bib_items = result[2]

local res = ""

---@type table<string, any>
local bib_options = {
index = options.index or "1"
Expand Down Expand Up @@ -672,16 +670,17 @@ function CslCitationManager:make_bibliography(filter_str)
local bib_options_str = table.concat(bib_option_list, ", ")

local bibstart = string.format("\\begin{thebibliography}{%s}\n", bib_options_str)
res = res .. bibstart
local bib_lines = {}
table.insert(bib_lines, bibstart)

for _, bib_item in ipairs(bib_items) do
res = res .. "\n" .. bib_item
table.insert(bib_lines, bib_item)
end

if params.bibend then
res = res .. "\n" .. params.bibend
table.insert(bib_lines, params.bibend)
end
return res
return bib_lines
end

function CslCitationManager:set_categories(categories_str)
Expand Down Expand Up @@ -850,8 +849,9 @@ function CslCitationManager:read_aux_file(aux_content)
ref_section:make_citeproc_engine()
end
if ref_section.engine then
local bib_str = self:make_bibliography(content)
table.insert(output_lines, bib_str)
local bib_lines = self:make_bibliography(content)
table.insert(output_lines, "")
util.extend(output_lines, bib_lines)
end
end
end
Expand Down

0 comments on commit 23bde1c

Please sign in to comment.