summaryrefslogtreecommitdiffstats
path: root/scripts/metadata_filter.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/metadata_filter.lua')
-rw-r--r--scripts/metadata_filter.lua19
1 files changed, 16 insertions, 3 deletions
diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua
index cb060fa..07f060c 100644
--- a/scripts/metadata_filter.lua
+++ b/scripts/metadata_filter.lua
@@ -27,6 +27,19 @@ function pandoc.List:take(n)
27 return result 27 return result
28end 28end
29 29
30function dump(o)
31 if type(o) == 'table' then
32 local s = '{ '
33 for k, v in pairs(o) do
34 if type(k) ~= 'number' then k = '"' .. k .. '"' end
35 s = s .. '[' .. k .. '] = ' .. dump(v) .. ','
36 end
37 return s .. '} '
38 else
39 return tostring(o)
40 end
41end
42
30function page_sort(order) 43function page_sort(order)
31 return function(p1, p2) 44 return function(p1, p2)
32 if p1.position then 45 if p1.position then
@@ -241,10 +254,10 @@ function generate_list(meta)
241 return meta.pages.all 254 return meta.pages.all
242 :map(function(cat) 255 :map(function(cat)
243 local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c) 256 local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c)
244 if c.pages then 257 if not c.pages or not cat.list_flatten then
245 return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end)
246 else
247 return pandoc.List({ d1_page_to_list_item(cat, c) }) 258 return pandoc.List({ d1_page_to_list_item(cat, c) })
259 else
260 return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end)
248 end 261 end
249 end) 262 end)
250 allItems:sort(page_sort(cat.list_order)) 263 allItems:sort(page_sort(cat.list_order))