diff options
| author | John MacFarlane <[email protected]> | 2024-10-01 08:47:29 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2024-10-01 08:47:29 -0700 |
| commit | 0d9cfc8ec0f623f7d26a867e876d6d85a94bd0e8 (patch) | |
| tree | 3420323f15b262d572ecbd03e71a9a0be9e0d44d /src | |
| parent | f202ae159587374079beb9dc6a1950334b618c3e (diff) | |
Amend the fix to #10236 to handle list tables.
With this patch, we also reuse bullet list code for list tables,
which simplifies the code.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/RST.hs | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 4f14030db..3f365d8a3 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -567,24 +567,8 @@ tableToRSTList caption _ propWidths headers rows = do toColumns :: Int -> Double -> Int toColumns t p = round (p * fromIntegral t) listTableContent :: PandocMonad m => [[[Block]]] -> RST m (Doc Text) - listTableContent = joinTable (joinDocsM '-') (joinDocsM '*') . - mapTable blockListToRST - -- joinDocsM adapts joinDocs in order to work in the `RST m` monad - joinDocsM :: PandocMonad m - => Char -> [RST m (Doc Text)] -> RST m (Doc Text) - joinDocsM c = fmap (joinDocs c) . sequence - -- joinDocs will be used to join cells and to join rows - joinDocs :: Char -> [Doc Text] -> Doc Text - joinDocs c items = (chomp . vcat . map (formatItem c)) items $$ - blankline - formatItem :: Char -> Doc Text -> Doc Text - formatItem c i = hang 2 (text [c, ' ']) (i <> cr) - -- apply a function to all table cells changing their type - mapTable :: (a -> b) -> [[a]] -> [[b]] - mapTable = map . map - -- function hor to join cells and function ver to join rows - joinTable :: ([a] -> a) -> ([a] -> a) -> [[a]] -> a - joinTable hor ver = ver . map hor + listTableContent = fmap vcat . + mapM (fmap (hang 2 (text "* ") . vcat) . mapM bulletListItemToRST) transformInlines :: [Inline] -> [Inline] transformInlines = insertBS . |
