summaryrefslogtreecommitdiff
path: root/Pancake/Rendering.hs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-11-05 11:56:54 +0300
committerdefanor <defanor@uberspace.net>2017-11-05 11:56:54 +0300
commit75e77e4244e2b4a1955086dd537e2c8663c9cecd (patch)
tree89aa70427c6e6953452a1ac110def24ea18c1726 /Pancake/Rendering.hs
parent09e4bdddc7415117cc27047ad0d7afe523f064c2 (diff)
Fix table cell links and identifiers
Fix link enumeration, and store the identifiers.
Diffstat (limited to 'Pancake/Rendering.hs')
-rw-r--r--Pancake/Rendering.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/Pancake/Rendering.hs b/Pancake/Rendering.hs
index e48c52b..d356110 100644
--- a/Pancake/Rendering.hs
+++ b/Pancake/Rendering.hs
@@ -330,17 +330,22 @@ renderBlock (P.Table caption _ widths headers rows) = do
w -> minimum w /= maximum w
ws <- if widthsAreSet then pure widths else do
lens <- map sum . transpose <$>
- mapM (mapM (\c -> (length . unstyled . concat) <$> tableCell 80 c)) rows
+ mapM (mapM (\c -> (length . unstyled . concat . rLines)
+ <$> renderCell 80 c)) rows
pure $ map (\l -> fromIntegral l / fromIntegral (sum lens)) lens
mapM_ (\r -> renderBlock P.HorizontalRule >> tableRow ws r) (headers : rows)
renderBlock P.HorizontalRule
where
+ renderCell :: Int -> [P.Block] -> Renderer [RendererOutput]
+ renderCell w blocks = do
+ st <- get
+ pure $ runRenderer w (linkCount st) (lineNumber st) $
+ mapM_ renderBlock blocks
tableCell :: Int -> [P.Block] -> Renderer [StyledLine]
tableCell w blocks = do
- st <- get
- let l = runRenderer w (linkCount st) (lineNumber st) $
- mapM_ renderBlock blocks
+ l <- renderCell w blocks
mapM_ storeLink $ rLinks l
+ tell $ map (\(s, i) -> RIdentifier s i) $ rIdentifiers l
pure $ map
(\x -> x ++ [fromString (replicate (w - length (unstyled x)) ' ')])
$ rLines l