summaryrefslogtreecommitdiff
path: root/biblio/citation-style-language/citeproc-ir-node.lua
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-04-04 03:01:33 +0000
committerNorbert Preining <norbert@preining.info>2023-04-04 03:01:33 +0000
commite9f267fd4c8414d6146c5fee0dbe459613dd0f3b (patch)
tree83fb57a85aee532d8ccb344a7a808a446c31054d /biblio/citation-style-language/citeproc-ir-node.lua
parent3b4a242af88203c2f3f551d46161bdd037c0d127 (diff)
CTAN sync 202304040301
Diffstat (limited to 'biblio/citation-style-language/citeproc-ir-node.lua')
-rw-r--r--biblio/citation-style-language/citeproc-ir-node.lua37
1 files changed, 36 insertions, 1 deletions
diff --git a/biblio/citation-style-language/citeproc-ir-node.lua b/biblio/citation-style-language/citeproc-ir-node.lua
index 50fe34b059..5770d8d0dc 100644
--- a/biblio/citation-style-language/citeproc-ir-node.lua
+++ b/biblio/citation-style-language/citeproc-ir-node.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
--
@@ -9,6 +9,7 @@ local irnode = {}
local util = require("citeproc-util")
+---@class IrNode
local IrNode = {
_element = nil,
_type = "IrNode",
@@ -61,6 +62,35 @@ function IrNode:derive(type)
return o
end
+function IrNode:_debug(level)
+ level = level or 0
+ local ir_info_str = ""
+ if self.delimiter then
+ ir_info_str = ir_info_str .. string.format('delimiter: "%s"', self.delimiter)
+ end
+ if self.should_inherit_delim then
+ if ir_info_str ~= "" then
+ ir_info_str = ir_info_str .. " "
+ end
+ ir_info_str = ir_info_str .. "should_inherit_delim: true"
+ end
+ 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)
+ if self.children and #self.children > 0 then
+ for _, child_ir in ipairs(self.children) do
+ text = text .. child_ir:_debug(level + 1)
+ end
+
+ elseif self.inlines then
+ for _, inline in ipairs(self.inlines) do
+ text = text .. " " .. inline:_debug()
+ end
+ end
+ return text
+end
+
function IrNode:flatten(format)
return format:flatten_ir(self)
end
@@ -105,6 +135,7 @@ function IrNode:find_first_year_ir()
end
+---@class Rendered: IrNode
local Rendered = IrNode:derive("Rendered")
function Rendered:new(inlines, element)
@@ -122,6 +153,7 @@ function Rendered:new(inlines, element)
end
+---@class YearSuffix: IrNode
local YearSuffix = IrNode:derive("YearSuffix")
function YearSuffix:new(inlines, element)
@@ -139,9 +171,11 @@ function YearSuffix:new(inlines, element)
end
+---@class NameIr: IrNode
local NameIr = IrNode:derive("NameIr")
+---@class PersonNameIr: IrNode
local PersonNameIr = IrNode:derive("PersonNameIr")
function PersonNameIr:new(inlines, element)
@@ -157,6 +191,7 @@ function PersonNameIr:new(inlines, element)
end
+---@class SeqIr: IrNode
local SeqIr = IrNode:derive("SeqIr")
-- function SeqIr:new(children)