diff options
Diffstat (limited to 'biblio/citation-style-language/citeproc-node-choose.lua')
-rw-r--r-- | biblio/citation-style-language/citeproc-node-choose.lua | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/biblio/citation-style-language/citeproc-node-choose.lua b/biblio/citation-style-language/citeproc-node-choose.lua index 3a4fc3f79e..4a9329c297 100644 --- a/biblio/citation-style-language/citeproc-node-choose.lua +++ b/biblio/citation-style-language/citeproc-node-choose.lua @@ -1,5 +1,5 @@ -- --- Copyright (c) 2021-2022 Zeping Lee +-- Copyright (c) 2021-2023 Zeping Lee -- Released under the MIT license. -- Repository: https://github.com/zepinglee/citeproc-lua -- @@ -24,32 +24,37 @@ function Choose:from_node(node) end function Choose:build_ir(engine, state, context) - local branch + local active_branch local branch_ir + + local ir = SeqIr:new({}, self) + ir.should_inherit_delim = true + ir.group_var = "UnresolvedPlain" + for _, child in ipairs(self.children) do if child:evaluate_conditions(engine, state, context) then - branch = child + active_branch = child branch_ir = child:build_ir(engine, state, context) + if branch_ir and branch_ir.group_var ~= "missing" then + table.insert(ir.children, branch_ir) + ir.group_var = branch_ir.group_var + ir.name_count = branch_ir.name_count + ir.sort_key = branch_ir.sort_key + else + ir.group_var = "missing" + end break end end - if not branch_ir then - branch_ir = SeqIr:new({}, self) - branch_ir.group_var = "missing" - end - - local ir = SeqIr:new({branch_ir}, self) - ir.group_var = branch_ir.group_var - ir.name_count = branch_ir.name_count - ir.sort_key = branch_ir.sort_key + -- util.debug(ir) if not context.disambiguate then context.disambiguate = true for _, child in ipairs(self.children) do if child:evaluate_conditions(engine, state, context) then - if child ~= branch then + if child ~= active_branch then ir.disambiguate_branch_ir = child:build_ir(engine, state, context) end break |