diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-08-10 10:49:18 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-08-10 10:49:18 -0700 |
commit | 0ad576eb1a914104448239b0f80f6026d4b6cc54 (patch) | |
tree | 2fd1381ab8a2b5b61e4e94c220863cb9d6749a12 | |
parent | aa08b4cd677b975cf63c451a3414df447e31b55c (diff) | |
download | pandoc-0ad576eb1a914104448239b0f80f6026d4b6cc54.tar.gz |
Docx writer: Moved invalid character stripping to `formattedString`.
This avoids an inefficient generic traversal.
Updates f3aa03e.
Closes #2356.
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index da4c78cef..0cb313e7b 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -181,8 +181,8 @@ renumIds f renumMap = map (renumId f renumMap) -- | Certain characters are invalid in XML even if escaped. -- See #1992 -stripInvalidChars :: Pandoc -> Pandoc -stripInvalidChars = bottomUp (filter isValidChar) +stripInvalidChars :: String -> String +stripInvalidChars = filter isValidChar -- | See XML reference isValidChar :: Char -> Bool @@ -208,7 +208,7 @@ writeDocx :: WriterOptions -- ^ Writer options -> IO BL.ByteString writeDocx opts doc@(Pandoc meta _) = do let datadir = writerUserDataDir opts - let doc' = stripInvalidChars . walk fixDisplayMath $ doc + let doc' = walk fixDisplayMath $ doc username <- lookup "USERNAME" <$> getEnvironment utctime <- getCurrentTime distArchive <- getDefaultReferenceDocx Nothing @@ -974,7 +974,7 @@ formattedString str = do return [ mknode "w:r" [] $ props ++ [ mknode (if inDel then "w:delText" else "w:t") - [("xml:space","preserve")] str ] ] + [("xml:space","preserve")] (stripInvalidChars str) ] ] setFirstPara :: WS () setFirstPara = modify $ \s -> s { stFirstPara = True } |