From cc02f7e0b99bf4b4c5139a3ae83840bf833a0c6d Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 17 Nov 2021 18:49:27 +0100 Subject: Better list limit --- scripts/metadata_filter.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua index 5fa7dfc..c154708 100644 --- a/scripts/metadata_filter.lua +++ b/scripts/metadata_filter.lua @@ -196,8 +196,6 @@ end function generate_list(meta) if not meta.pages then return nil end - local limit = (meta.list_limit and tonumber(pandoc.utils.stringify(meta.list_limit))) or 9999 - if meta.depth == "1" then return meta.pages.all:map(function(p) return { @@ -212,6 +210,7 @@ function generate_list(meta) end) elseif meta.depth == "2" then return meta.pages.all:map(function(cat) + local limit = (cat.list_limit and tonumber(pandoc.utils.stringify(cat.list_limit))) or 9999 local allItems = ((cat.pages and cat.pages.all) or pandoc.List()):map(function(p) return { title = p.title, @@ -238,6 +237,7 @@ function generate_list(meta) end):filter(function(cat) return #cat.items ~= 0 end) elseif meta.depth == "3" then return meta.pages.all:map(function(cat) + local limit = (cat.list_limit and tonumber(pandoc.utils.stringify(cat.list_limit))) or 9999 local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c) if c.pages then return c.pages.all:map(function(p) -- cgit v1.2.3-70-g09d2