diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/metadata_filter.lua | 19 |
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 |
| 28 | end | 28 | end |
| 29 | 29 | ||
| 30 | function 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 | ||
| 41 | end | ||
| 42 | |||
| 30 | function page_sort(order) | 43 | function 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)) |
