diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-08-12 11:13:27 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-08-12 11:13:27 -0700 |
commit | d6f097312873596a7eef12c55d20375ab035f2cd (patch) | |
tree | 91ec665bc1b8622ded7e846c49e97c4565ad9925 /src/Text | |
parent | f97ec6db2c66c25e0a62500939ce1a848a7587b0 (diff) | |
parent | 9d0b390d48823e2fcbcbabf84fd105b595bcb60b (diff) | |
download | pandoc-d6f097312873596a7eef12c55d20375ab035f2cd.tar.gz |
Merge pull request #1524 from jkr/dropCap3
Docx reader: move dropcap combining logic to Reducible
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Docx/Reducible.hs | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 10dc45581..9943ebeb8 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -462,9 +462,7 @@ bodyPartToBlocks (Paragraph pPr parparts) bodyPartToBlocks (Paragraph pPr parparts) = do ils <- parPartsToInlines parparts >>= (return . normalizeSpaces) dropIls <- gets docxDropCap - let ils' = case ils of - (x:xs) -> reduceList (dropIls ++ [x]) ++ xs - [] -> dropIls + let ils' = concatR dropIls ils if dropCap pPr then do modify $ \s -> s { docxDropCap = ils' } return [] diff --git a/src/Text/Pandoc/Readers/Docx/Reducible.hs b/src/Text/Pandoc/Readers/Docx/Reducible.hs index a852e25bf..39a93d988 100644 --- a/src/Text/Pandoc/Readers/Docx/Reducible.hs +++ b/src/Text/Pandoc/Readers/Docx/Reducible.hs @@ -39,6 +39,7 @@ module Text.Pandoc.Readers.Docx.Reducible ((<++>), innards, reduceList, reduceListB, + concatR, rebuild) where @@ -78,6 +79,15 @@ reduceList' as (x:xs) = reduceList' (init as ++ (last as <++> x) ) xs reduceList :: (Reducible a) => [a] -> [a] reduceList = reduceList' [] +concatR :: (Reducible a) => [a] -> [a] -> [a] +concatR [] [] = [] +concatR [] ss = ss +concatR rs [] = rs +concatR rs ss = let (x:xs) = reverse rs + (y:ys) = ss + in + reverse xs ++ ( x <++> y ) ++ ys + combineReducibles :: (Reducible a, Eq a) => a -> a -> [a] combineReducibles r s = let (conts, rs) = topLevelContainers r |