@@ -181,8 +181,8 @@ renumIds f renumMap = map (renumId f renumMap)
181181
182182-- | Certain characters are invalid in XML even if escaped.
183183-- See #1992
184−stripInvalidChars :: Pandoc -> Pandoc
185−stripInvalidChars = bottomUp (filter isValidChar)
184+stripInvalidChars :: String -> String
185+stripInvalidChars = filter isValidChar
186186
187187-- | See XML reference
188188isValidChar :: Char -> Bool
@@ -208,7 +208,7 @@ writeDocx :: WriterOptions -- ^ Writer options
208208 -> IO BL.ByteString
209209writeDocx opts doc@(Pandoc meta _) = do
210210 let datadir = writerUserDataDir opts
211− let doc' = stripInvalidChars . walk fixDisplayMath $ doc
211+ let doc' = walk fixDisplayMath $ doc
212212 username <- lookup "USERNAME" <$> getEnvironment
213213 utctime <- getCurrentTime
214214 distArchive <- getDefaultReferenceDocx Nothing
@@ -974,7 +974,7 @@ formattedString str = do
974974 return [ mknode "w:r" [] $
975975 props ++
976976 [ mknode (if inDel then "w:delText" else "w:t")
977− [("xml:space","preserve")] str ] ]
977+ [("xml:space","preserve")] (stripInvalidChars str) ] ]
978978
979979setFirstPara :: WS ()
980980setFirstPara = modify $ \s -> s { stFirstPara = True }