From e9f267fd4c8414d6146c5fee0dbe459613dd0f3b Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 4 Apr 2023 03:01:33 +0000 Subject: CTAN sync 202304040301 --- .../citation-style-language/citeproc-ir-node.lua | 37 +++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'biblio/citation-style-language/citeproc-ir-node.lua') 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) -- cgit v1.2.3