diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/common.lua | 34 |
1 files changed, 21 insertions, 13 deletions
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 @@ | |||
| 1 | function dump(o) | 1 | local utils = require 'pandoc.utils' |
| 2 | if type(o) == 'table' then | ||
| 3 | local s = '{ ' | ||
| 4 | for k, v in pairs(o) do | ||
| 5 | if type(k) ~= 'number' then k = '"' .. k .. '"' end | ||
| 6 | s = s .. '[' .. k .. '] = ' .. dump(v) .. ',' | ||
| 7 | end | ||
| 8 | return s .. '} ' | ||
| 9 | else | ||
| 10 | return tostring(o) | ||
| 11 | end | ||
| 12 | end | ||
| 13 | 2 | ||
| 14 | function string.split(str, sep) | 3 | function string.split(str, sep) |
| 15 | sep = sep or '%s' | 4 | sep = sep or '%s' |
| @@ -82,6 +71,25 @@ function pandoc.List:shuffle() | |||
| 82 | return self | 71 | return self |
| 83 | end | 72 | end |
| 84 | 73 | ||
| 74 | function dump(o) | ||
| 75 | if type(o) == 'table' then | ||
| 76 | local s = '{ ' | ||
| 77 | for k, v in pairs(o) do | ||
| 78 | if type(k) ~= 'number' then k = '"' .. k .. '"' end | ||
| 79 | s = s .. '[' .. k .. '] = ' .. dump(v) .. ',' | ||
| 80 | end | ||
| 81 | return s .. '} ' | ||
| 82 | else | ||
| 83 | return tostring(o) | ||
| 84 | end | ||
| 85 | end | ||
| 86 | |||
| 87 | function prep_layout(layout) | ||
| 88 | layout = utils.stringify(layout) | ||
| 89 | return { id = layout, ["is_" .. layout] = true } | ||
| 90 | end | ||
| 91 | |||
| 85 | return { | 92 | return { |
| 86 | dump = dump | 93 | dump = dump, |
| 94 | prep_layout = prep_layout | ||
| 87 | } | 95 | } |
