From a02ce74acf2189207b178fb7c6b62efd23145b0e Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Sat, 9 Aug 2014 23:35:09 -0400 Subject: Docx reader: Fix spacing issue. Previously spaces at the beginning of Emph/Strong/etc were kept inside. This makes sure they are moved out. --- src/Text/Pandoc/Readers/Docx/Reducible.hs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Readers/Docx') diff --git a/src/Text/Pandoc/Readers/Docx/Reducible.hs b/src/Text/Pandoc/Readers/Docx/Reducible.hs index e8e407844..2f1945c7d 100644 --- a/src/Text/Pandoc/Readers/Docx/Reducible.hs +++ b/src/Text/Pandoc/Readers/Docx/Reducible.hs @@ -87,13 +87,16 @@ 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 -> case () of + _ | (not . null) rs && isSpace (last rs) -> + rebuild conts (init rs) ++ [last rs, s] + _ | (not . null) ss && isSpace (head ss) -> + [r, head ss] ++ rebuild conts' (tail ss) + _ -> [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 +180,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 - - -- cgit v1.2.3 From c15978ce5e0b9784de8aaba1f76f299ca5a996bf Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Sun, 10 Aug 2014 09:10:34 -0400 Subject: Change head/tail to pattern guards. --- src/Text/Pandoc/Readers/Docx/Reducible.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc/Readers/Docx') diff --git a/src/Text/Pandoc/Readers/Docx/Reducible.hs b/src/Text/Pandoc/Readers/Docx/Reducible.hs index 2f1945c7d..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 @@ -87,12 +87,13 @@ combineReducibles r s = remaining' = conts' \\ shared in case null shared of - True -> case () of - _ | (not . null) rs && isSpace (last rs) -> - rebuild conts (init rs) ++ [last rs, s] - _ | (not . null) ss && isSpace (head ss) -> - [r, head ss] ++ rebuild conts' (tail ss) - _ -> [r,s] + 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 $ -- cgit v1.2.3