aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 84d50a396..08afc94e6 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -150,19 +150,17 @@ strNormalize (Str "" : ils) = strNormalize ils
strNormalize ((Str s) : (Str s') : l) = strNormalize ((Str (s++s')) : l)
strNormalize (il:ils) = il : (strNormalize ils)
+stripSpaces :: [Inline] -> [Inline]
+stripSpaces ils =
+ reverse $ dropWhile (Space ==) $ reverse $ dropWhile (Space ==) ils
+
blockNormalize :: Block -> Block
-blockNormalize (Plain (Space : ils)) = blockNormalize (Plain ils)
-blockNormalize (Plain ils) = Plain $ strNormalize ils
-blockNormalize (Para (Space : ils)) = blockNormalize (Para ils)
-blockNormalize (Para ils) = Para $ strNormalize ils
-blockNormalize (Header n attr (Space : ils)) =
- blockNormalize $ Header n attr ils
+blockNormalize (Plain ils) = Plain $ strNormalize $ stripSpaces ils
+blockNormalize (Para ils) = Para $ strNormalize $ stripSpaces ils
blockNormalize (Header n attr ils) =
- Header n attr $ strNormalize ils
-blockNormalize (Table (Space : ils) align width hdr cells) =
- blockNormalize $ Table ils align width hdr cells
+ Header n attr $ strNormalize $ stripSpaces ils
blockNormalize (Table ils align width hdr cells) =
- Table (strNormalize ils) align width hdr cells
+ Table (strNormalize $ stripSpaces ils) align width hdr cells
blockNormalize blk = blk
runToInlines :: ReaderOptions -> Docx -> Run -> [Inline]