Määritä metadatataulukon sarakemäärä oikein listoille

This commit is contained in:
Saku Laesvuori 2023-11-21 13:54:56 +02:00
parent d355a1658d
commit 0ec7996bd7
1 changed files with 5 additions and 3 deletions

View File

@ -14,21 +14,23 @@ renderMeta :: MetaValue -> [Block]
renderMeta (MetaMap metaMap) = singleton $ plainTable
(map (singleton . Plain . singleton . Str . fst))
(singleton . plainRow . map (renderMeta . snd))
length
(toList metaMap)
renderMeta (MetaList metaValues) = singleton $ plainTable
(const [])
(map (plainRow . singleton . renderMeta))
(const 1)
metaValues
renderMeta (MetaBool bool) = [Plain [Str $ if bool then "true" else "false"]]
renderMeta (MetaString text) = [Plain [Str text]]
renderMeta (MetaInlines inlines) = [Plain inlines]
renderMeta (MetaBlocks blocks) = blocks
plainTable :: ([a] -> [[Block]]) -> ([a] -> [Row]) -> [a] -> Block
plainTable mkHead mkBody xs = Table
plainTable :: ([a] -> [[Block]]) -> ([a] -> [Row]) -> ([a] -> Int) -> [a] -> Block
plainTable mkHead mkBody columns xs = Table
nullAttr
(Caption Nothing [])
(map (const $ (AlignDefault, ColWidthDefault)) xs)
(replicate (columns xs) (AlignDefault, ColWidthDefault))
(plainHead $ mkHead xs)
[plainBody $ mkBody xs]
(TableFoot nullAttr [])