git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1524 from jkr/dropCap3

Docx reader: move dropcap combining logic to Reducible

commitd6f097312873596a7eef12c55d20375ab035f2cd authorJohn MacFarlane <jgm@berkeley.edu> dateTue 12 Aug 2014, 11:13 (12 years ago) parentf97ec6d9d0b390
2 files changed+11−3
src/Text/Pandoc/Readers/Docx.hs+1−3 src/Text/Pandoc/Readers/Docx/Reducible.hs+10
src/Text/Pandoc/Readers/Docx.hs+1−3
@@ -462,9 +462,7 @@ bodyPartToBlocks (Paragraph pPr parparts)
462462bodyPartToBlocks (Paragraph pPr parparts) = do
463463 ils <- parPartsToInlines parparts >>= (return . normalizeSpaces)
464464 dropIls <- gets docxDropCap
465− let ils' = case ils of
466− (x:xs) -> reduceList (dropIls ++ [x]) ++ xs
467− [] -> dropIls
465+ let ils' = concatR dropIls ils
468466 if dropCap pPr
469467 then do modify $ \s -> s { docxDropCap = ils' }
470468 return []
src/Text/Pandoc/Readers/Docx/Reducible.hs+10
@@ -39,6 +39,7 @@ module Text.Pandoc.Readers.Docx.Reducible ((<++>),
3939 innards,
4040 reduceList,
4141 reduceListB,
42+ concatR,
4243 rebuild)
4344 where
4445
@@ -78,6 +79,15 @@ reduceList' as (x:xs) = reduceList' (init as ++ (last as <++> x) ) xs
7879reduceList :: (Reducible a) => [a] -> [a]
7980reduceList = reduceList' []
8081
82+concatR :: (Reducible a) => [a] -> [a] -> [a]
83+concatR [] [] = []
84+concatR [] ss = ss
85+concatR rs [] = rs
86+concatR rs ss = let (x:xs) = reverse rs
87+ (y:ys) = ss
88+ in
89+ reverse xs ++ ( x <++> y ) ++ ys
90+
8191combineReducibles :: (Reducible a, Eq a) => a -> a -> [a]
8292combineReducibles r s =
8393 let (conts, rs) = topLevelContainers r