diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-08-10 07:11:59 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-08-10 07:11:59 -0700 |
commit | 65b31e0cacbdd2dc57a8406b420559f7e5fb4867 (patch) | |
tree | a13c79ea63283062acb7390872daf0f20a9bb1bc | |
parent | 7ec8dd956f253613510695b5e971eae71d2f5287 (diff) | |
parent | c15978ce5e0b9784de8aaba1f76f299ca5a996bf (diff) | |
download | pandoc-65b31e0cacbdd2dc57a8406b420559f7e5fb4867.tar.gz |
Merge pull request #1510 from jkr/spacefix
Docx reader: Fix spacing issue.
-rw-r--r-- | src/Text/Pandoc/Readers/Docx/Reducible.hs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Reducible.hs b/src/Text/Pandoc/Readers/Docx/Reducible.hs index e8e407844..2dbef4131 100644 --- a/src/Text/Pandoc/Readers/Docx/Reducible.hs +++ b/src/Text/Pandoc/Readers/Docx/Reducible.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE OverloadedStrings, PatternGuards #-} {- Copyright (C) 2014 Jesse Rosenthal <jrosenthal@jhu.edu> @@ -87,13 +87,17 @@ combineReducibles r s = remaining' = conts' \\ shared in case null shared of - True -> case (not . null) rs && isSpace (last rs) of - True -> rebuild conts (init rs) ++ [last rs, s] - False -> [r,s] - False -> rebuild - shared $ - reduceList $ - (rebuild remaining rs) ++ (rebuild remaining' ss) + True | (x : xs) <- reverse rs + , isSpace x -> + rebuild conts (reverse xs) ++ [x, s] + | (x : xs) <- ss + , isSpace x -> + [r, x] ++ rebuild conts' (xs) + True -> [r,s] + False -> rebuild + shared $ + reduceList $ + (rebuild remaining rs) ++ (rebuild remaining' ss) instance Reducible Inline where s1@(Span (id1, classes1, kvs1) ils1) <++> s2@(Span (id2, classes2, kvs2) ils2) = @@ -177,5 +181,3 @@ rebuild :: [Container a] -> [a] -> [a] rebuild [] xs = xs rebuild ((Container f) : cs) xs = rebuild cs $ [f xs] rebuild (NullContainer : cs) xs = rebuild cs $ xs - - |