summaryrefslogtreecommitdiff
path: root/Pancake
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-21 23:08:46 +0300
committerdefanor <defanor@uberspace.net>2017-12-21 23:08:46 +0300
commit1a1c45b33d258a9852a85a92f5a93d9288dde0d3 (patch)
tree009433d1cfe8873dbcc06aacda5bc23519009320 /Pancake
parent7019a437de75a096ecaa52d8e7b1a9278c17f16d (diff)
Set breadcrumbs for Plain elements' lines
Diffstat (limited to 'Pancake')
-rw-r--r--Pancake/Rendering.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/Pancake/Rendering.hs b/Pancake/Rendering.hs
index e5d03c4..054edc5 100644
--- a/Pancake/Rendering.hs
+++ b/Pancake/Rendering.hs
@@ -400,11 +400,25 @@ readInline (P.Span attr i) = do
-- | Reads lines of inline elements.
readInlines :: [P.Inline] -> Renderer [StyledLine]
-readInlines i = pure . concat <$> mapM readInline i
+readInlines i = do
+ inlineBits <- concat <$> mapM readInline i
+ pure $ pure inlineBits
+
+-- | Akin to 'lines', but for 'Inline' elements.
+inlines :: [P.Inline] -> [[P.Inline]]
+inlines = flip inlines' []
+ where inlines' :: [P.Inline] -> [P.Inline] -> [[P.Inline]]
+ inlines' [] [] = []
+ inlines' [] curLine = [curLine]
+ inlines' (P.LineBreak : xs) curLine = curLine : inlines' xs []
+ inlines' (other : xs) curLine = inlines' xs (curLine ++ [other])
-- | Renders a block element.
renderBlock :: P.Block -> Renderer ()
-renderBlock (P.Plain i) = indented =<< readInlines i
+renderBlock (P.Plain i) =
+ zipWithM_ (\l n -> withBreadcrumb n $
+ (pure . concat <$> mapM readInline l) >>= indented)
+ (inlines i) [1..]
renderBlock (P.Para i) = indented =<< readInlines i
renderBlock (P.LineBlock i) =
zipWithM_ (\l n -> withBreadcrumb n $