From 7c655a95058aa753355251eb78b83d31d44972ab Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 23 Aug 2022 14:07:20 +0200 Subject: Better navigation of related content --- scripts/lib/common.lua | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'scripts/lib/common.lua') diff --git a/scripts/lib/common.lua b/scripts/lib/common.lua index ee7c6aa..d3c6c44 100644 --- a/scripts/lib/common.lua +++ b/scripts/lib/common.lua @@ -1,15 +1,4 @@ -function dump(o) - if type(o) == 'table' then - local s = '{ ' - for k, v in pairs(o) do - if type(k) ~= 'number' then k = '"' .. k .. '"' end - s = s .. '[' .. k .. '] = ' .. dump(v) .. ',' - end - return s .. '} ' - else - return tostring(o) - end -end +local utils = require 'pandoc.utils' function string.split(str, sep) sep = sep or '%s' @@ -82,6 +71,25 @@ function pandoc.List:shuffle() return self end +function dump(o) + if type(o) == 'table' then + local s = '{ ' + for k, v in pairs(o) do + if type(k) ~= 'number' then k = '"' .. k .. '"' end + s = s .. '[' .. k .. '] = ' .. dump(v) .. ',' + end + return s .. '} ' + else + return tostring(o) + end +end + +function prep_layout(layout) + layout = utils.stringify(layout) + return { id = layout, ["is_" .. layout] = true } +end + return { - dump = dump + dump = dump, + prep_layout = prep_layout } -- cgit v1.2.3-54-g00ecf