diff options
author | defanor <defanor@uberspace.net> | 2017-12-22 08:45:02 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2017-12-22 08:45:02 +0300 |
commit | d096dd977c094378fd1ef36ca42a26bded3b6fe9 (patch) | |
tree | ce76abaee6c6a2f3b178618c435d98567cd15b7c /Pancake | |
parent | aecf9cf8449d8f28b40af1295883c38a8cf2db25 (diff) |
Split inline elements into lines in readInlines
Diffstat (limited to 'Pancake')
-rw-r--r-- | Pancake/Rendering.hs | 12 |
1 files changed, 11 insertions, 1 deletions
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]] |