summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2014-06-19 19:28:55 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2014-06-19 19:28:55 -0400
commita934db9a320ec76e15e62954b75d0e8d2d972244 (patch)
tree02cfc3c3dcc1f1a339956766419f183d9ad6f592 /src
parent0e7d2dbd4304902cb6c6d4e9618592b5148dc598 (diff)
Introduce blockNormalize
This will help take care of spaces introduced at the beginning of strings.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index c43879ed9..9c1d0c5e6 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -150,6 +150,19 @@ strNormalize (Str "" : ils) = strNormalize ils
strNormalize ((Str s) : (Str s') : l) = strNormalize ((Str (s++s')) : l)
strNormalize (il:ils) = il : (strNormalize 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 (Table (Space : ils) align width hdr cells) =
+ blockNormalize $ Table ils align width hdr cells
+blockNormalize (Table ils align width hdr cells) =
+ Table (strNormalize ils) align width hdr cells
+blockNormalize blk = blk
+
runToInlines :: ReaderOptions -> Docx -> Run -> [Inline]
runToInlines _ _ (Run rs runElems)
| isJust (rStyle rs) && (fromJust (rStyle rs)) `elem` codeSpans =
@@ -296,7 +309,7 @@ makeImagesSelfContained _ inline = inline
bodyToBlocks :: ReaderOptions -> Docx -> Body -> [Block]
bodyToBlocks opts docx (Body bps) =
bottomUp removeEmptyPars $
- bottomUp strNormalize $
+ bottomUp blockNormalize $
bottomUp spanRemove $
bottomUp divRemove $
map (makeHeaderAnchors) $