aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-03 23:16:15 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-03 23:16:15 +0100
commit9616a8a2dd27903a09969dc4d62dcf9227458d27 (patch)
tree15df7a647703e6972539345cf71010a298b1e343 /src/Text
parentce9d49ef0421f23fdc05fabd8d7f754d680bea47 (diff)
downloadpandoc-9616a8a2dd27903a09969dc4d62dcf9227458d27.tar.gz
OpenDocument writer: Clarified some code.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index c268c5133..865faf37c 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -242,18 +242,17 @@ orderedListToOpenDocument o pn bs =
orderedItemToOpenDocument :: PandocMonad m
=> WriterOptions -> Int -> [Block] -> OD m Doc
-orderedItemToOpenDocument o n (b:bs)
- | OrderedList a l <- b = go =<< newLevel a l
- | Para l <- b = go =<< inParagraphTagsWithStyle ("P" ++ show n) <$> inlinesToOpenDocument o l
- | otherwise = go =<< blockToOpenDocument o b
- where
- go i = ($$) i <$> orderedItemToOpenDocument o n bs
- newLevel a l = do
- nn <- length <$> gets stParaStyles
- ls <- head <$> gets stListStyles
- modify $ \s -> s { stListStyles = orderedListLevelStyle a ls : tail (stListStyles s) }
- inTagsIndented "text:list" <$> orderedListToOpenDocument o nn l
-orderedItemToOpenDocument _ _ [] = return empty
+orderedItemToOpenDocument o n bs = vcat <$> mapM go bs
+ where go (OrderedList a l) = newLevel a l
+ go (Para l) = inParagraphTagsWithStyle ("P" ++ show n) <$>
+ inlinesToOpenDocument o l
+ go b = blockToOpenDocument o b
+ newLevel a l = do
+ nn <- length <$> gets stParaStyles
+ ls <- head <$> gets stListStyles
+ modify $ \s -> s { stListStyles = orderedListLevelStyle a ls :
+ drop 1 (stListStyles s) }
+ inTagsIndented "text:list" <$> orderedListToOpenDocument o nn l
isTightList :: [[Block]] -> Bool
isTightList [] = False