Skip to content

Commit

Permalink
fix(summary): ordering and indentation of nested entries
Browse files Browse the repository at this point in the history
  • Loading branch information
nuhakala authored and vhyrro committed Jun 28, 2024
1 parent a5c2624 commit 9279672
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lua/neorg/modules/core/summary/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,18 @@ module.load = function()
local starting_prefix = string.rep("*", heading_level)

local function add_category(category, data, level)
local result_temp = {}
local sub_cats_temp = {}
local new_prefix = starting_prefix .. string.rep("*", level)
table.insert(result, new_prefix .. " " .. category)
table.insert(result_temp, new_prefix .. " " .. category)
for _, datapoint in ipairs(data) do
if datapoint.sub_categories then
level = level + 1
for sub_category, sub_data in vim.spairs(datapoint.sub_categories) do
add_category(sub_category, sub_data, level)
table.insert(sub_cats_temp, add_category(sub_category, sub_data, level + 1))
end
else
table.insert(
result,
result_temp,
table.concat({
string.rep(" ", level + 1),
" - {:$",
Expand All @@ -212,9 +213,18 @@ module.load = function()
)
end
end
for _, sub_cat in pairs(sub_cats_temp) do
for _, row in pairs(sub_cat) do
table.insert(result_temp, row)
end
end
return result_temp
end
for category, data in vim.spairs(categories) do
add_category(category, data, 0)
local temp = add_category(category, data, 0)
for _, row in pairs(temp) do
table.insert(result, row)
end
end
return result
end
Expand Down

0 comments on commit 9279672

Please sign in to comment.