From 0ec7996bd72795b02b4858e5ac5ee30e904aad60 Mon Sep 17 00:00:00 2001 From: Saku Laesvuori Date: Tue, 21 Nov 2023 13:54:56 +0200 Subject: [PATCH] =?UTF-8?q?M=C3=A4=C3=A4rit=C3=A4=20metadatataulukon=20sar?= =?UTF-8?q?akem=C3=A4=C3=A4r=C3=A4=20oikein=20listoille?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gitea-markdown/src/Gitea/Preview/Markdown/Meta.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gitea-markdown/src/Gitea/Preview/Markdown/Meta.hs b/gitea-markdown/src/Gitea/Preview/Markdown/Meta.hs index ebb995b..b57cbe7 100644 --- a/gitea-markdown/src/Gitea/Preview/Markdown/Meta.hs +++ b/gitea-markdown/src/Gitea/Preview/Markdown/Meta.hs @@ -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 [])