git.iko.soy/typeable/pandoc
on master help sign in
OpenDocument writer: Clarified some code.
commit9616a8a2dd27903a09969dc4d62dcf9227458d27 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 3 Mar 2017, 23:16 (10 years ago) parentce9d49e
1 file changed+11−12
src/Text/Pandoc/Writers/OpenDocument.hs+11−12
src/Text/Pandoc/Writers/OpenDocument.hs+11−12
@@ -242,18 +242,17 @@ orderedListToOpenDocument o pn bs =
242242
243243orderedItemToOpenDocument :: PandocMonad m
244244 => WriterOptions -> Int -> [Block] -> OD m Doc
245−orderedItemToOpenDocument o n (b:bs)
246− | OrderedList a l <- b = go =<< newLevel a l
247− | Para l <- b = go =<< inParagraphTagsWithStyle ("P" ++ show n) <$> inlinesToOpenDocument o l
248− | otherwise = go =<< blockToOpenDocument o b
249− where
250− go i = ($$) i <$> orderedItemToOpenDocument o n bs
251− newLevel a l = do
252− nn <- length <$> gets stParaStyles
253− ls <- head <$> gets stListStyles
254− modify $ \s -> s { stListStyles = orderedListLevelStyle a ls : tail (stListStyles s) }
255− inTagsIndented "text:list" <$> orderedListToOpenDocument o nn l
256−orderedItemToOpenDocument _ _ [] = return empty
245+orderedItemToOpenDocument o n bs = vcat <$> mapM go bs
246+ where go (OrderedList a l) = newLevel a l
247+ go (Para l) = inParagraphTagsWithStyle ("P" ++ show n) <$>
248+ inlinesToOpenDocument o l
249+ go b = blockToOpenDocument o b
250+ newLevel a l = do
251+ nn <- length <$> gets stParaStyles
252+ ls <- head <$> gets stListStyles
253+ modify $ \s -> s { stListStyles = orderedListLevelStyle a ls :
254+ drop 1 (stListStyles s) }
255+ inTagsIndented "text:list" <$> orderedListToOpenDocument o nn l
257256
258257isTightList :: [[Block]] -> Bool
259258isTightList [] = False