summaryrefslogtreecommitdiff
path: root/biblio/citation-style-language/citeproc-ir-node.lua
diff options
context:
space:
mode:
Diffstat (limited to 'biblio/citation-style-language/citeproc-ir-node.lua')
-rw-r--r--biblio/citation-style-language/citeproc-ir-node.lua47
1 files changed, 32 insertions, 15 deletions
diff --git a/biblio/citation-style-language/citeproc-ir-node.lua b/biblio/citation-style-language/citeproc-ir-node.lua
index b9324a15bb..9d1ee21905 100644
--- a/biblio/citation-style-language/citeproc-ir-node.lua
+++ b/biblio/citation-style-language/citeproc-ir-node.lua
@@ -15,9 +15,19 @@ else
end
+---@enum GroupVar
+local GroupVar = {
+ Plain = 0,
+ Important = 1,
+ Missing = 2,
+ UnresolvedPlain = 3,
+}
+
+
---@class IrNode
local IrNode = {
_element = nil,
+ _element_name = nil,
_type = "IrNode",
_base_class = "IrNode",
text = nil,
@@ -29,19 +39,20 @@ local IrNode = {
function IrNode:new(children, element)
local o = {
- _element = element.element_name,
+ _element = element,
+ _element_name = element.element_name,
_type = self._type,
children = children,
- group_var = "plain",
+ group_var = GroupVar.Plain,
}
- o.group_var = "missing"
+ o.group_var = GroupVar.Missing
for _, child_ir in ipairs(children) do
- if child_ir.group_var == "important" then
- o.group_var = "important"
+ if child_ir.group_var == GroupVar.Important then
+ o.group_var = GroupVar.Important
break
- elseif child_ir.group_var == "plain" then
- o.group_var = "plain"
+ elseif child_ir.group_var == GroupVar.Plain then
+ o.group_var = GroupVar.Plain
end
end
@@ -83,7 +94,7 @@ function IrNode:_debug(level)
if ir_info_str ~= "" then
ir_info_str = string.format("{%s}", ir_info_str)
end
- local text = string.format("\n%s [%s] %s <%s> %s", string.rep(" ", level), self.group_var, self._type, self._element, ir_info_str)
+ local text = string.format("\n%s [%s] %s <%s> %s", string.rep(" ", level), self.group_var, self._type, self._element_name, ir_info_str)
if self.children and #self.children > 0 then
for _, child_ir in ipairs(self.children) do
text = text .. child_ir:_debug(level + 1)
@@ -126,6 +137,7 @@ function IrNode:collect_year_suffix_irs()
end
function IrNode:find_first_year_ir()
+ -- This also find the citation-label IR
if self.is_year then
return self
end
@@ -146,11 +158,12 @@ local Rendered = IrNode:derive("Rendered")
function Rendered:new(inlines, element)
local o = {
- _element = element.element_name,
+ _element = element,
+ _element_name = element.element_name,
_type = self._type,
element = element, -- required for capitalizing first term
inlines = inlines,
- group_var = "plain",
+ group_var = GroupVar.Plain,
}
setmetatable(o, self)
@@ -164,11 +177,12 @@ local YearSuffix = IrNode:derive("YearSuffix")
function YearSuffix:new(inlines, element)
local o = {
- _element = element.element_name,
+ _element = element,
+ _element_name = element.element_name,
_type = self._type,
element = element,
inlines = inlines,
- group_var = "plain",
+ group_var = GroupVar.Plain,
}
setmetatable(o, self)
@@ -186,10 +200,11 @@ local PersonNameIr = IrNode:derive("PersonNameIr")
function PersonNameIr:new(inlines, element)
local o = {
- _element = element.element_name,
+ _element = element,
+ _element_name = element.element_name,
_type = self._type,
inlines = inlines,
- group_var = "plain",
+ group_var = GroupVar.Plain,
}
setmetatable(o, self)
self.__index = self
@@ -204,7 +219,7 @@ local SeqIr = IrNode:derive("SeqIr")
-- o = IrNode.new(self, children)
-- local o = {
-- children = children,
--- group_var = "plain",
+-- group_var = GroupVar.Plain,
-- }
-- setmetatable(o, self)
-- self.__index = self
@@ -220,4 +235,6 @@ irnode.NameIr = NameIr
irnode.PersonNameIr = PersonNameIr
irnode.SeqIr = SeqIr
+irnode.GroupVar = GroupVar
+
return irnode