From d096dd977c094378fd1ef36ca42a26bded3b6fe9 Mon Sep 17 00:00:00 2001 From: defanor Date: Fri, 22 Dec 2017 08:45:02 +0300 Subject: Split inline elements into lines in readInlines --- Pancake/Rendering.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Pancake/Rendering.hs b/Pancake/Rendering.hs index b5fd717..213512b 100644 --- a/Pancake/Rendering.hs +++ b/Pancake/Rendering.hs @@ -421,7 +421,17 @@ readInline (P.Span attr i) = do readInlines :: [P.Inline] -> Renderer [StyledLine] readInlines i = do inlineBits <- concat <$> mapM readInline i - pure $ pure inlineBits + pure $ styledLines inlineBits + +-- | Splits a list of styled elements into styled lines. Like +-- 'inlines', but for processed elements. +styledLines :: [Styled] -> [StyledLine] +styledLines = styledLines' [] + where + styledLines' cur [] = [cur] + styledLines' cur (x:xs) + | unstyled [x] == "\n" = cur : styledLines' [] xs + | otherwise = styledLines' (cur ++ [x]) xs -- | Akin to 'lines', but for 'Inline' elements. inlines :: [P.Inline] -> [[P.Inline]] -- cgit v1.2.3