git.iko.soy/typeable/pandoc
on master help sign in
Docx writer: Moved invalid character stripping to `formattedString`.
0ad576eJohn MacFarlane
src/Text/Pandoc/Writers/Docx.hs+4−4
@@ -181,8 +181,8 @@ renumIds f renumMap = map (renumId f renumMap)
181
181
182-- | Certain characters are invalid in XML even if escaped.
182-- | Certain characters are invalid in XML even if escaped.
183-- See #1992
183-- See #1992
184−stripInvalidChars :: Pandoc -> Pandoc
184+stripInvalidChars :: String -> String
185−stripInvalidChars = bottomUp (filter isValidChar)
185+stripInvalidChars = filter isValidChar
186
186
187-- | See XML reference
187-- | See XML reference
188isValidChar :: Char -> Bool
188isValidChar :: Char -> Bool
@@ -208,7 +208,7 @@ writeDocx :: WriterOptions -- ^ Writer options
208 -> IO BL.ByteString
208 -> IO BL.ByteString
209writeDocx opts doc@(Pandoc meta _) = do
209writeDocx opts doc@(Pandoc meta _) = do
210 let datadir = writerUserDataDir opts
210 let datadir = writerUserDataDir opts
211− let doc' = stripInvalidChars . walk fixDisplayMath $ doc
211+ let doc' = walk fixDisplayMath $ doc
212 username <- lookup "USERNAME" <$> getEnvironment
212 username <- lookup "USERNAME" <$> getEnvironment
213 utctime <- getCurrentTime
213 utctime <- getCurrentTime
214 distArchive <- getDefaultReferenceDocx Nothing
214 distArchive <- getDefaultReferenceDocx Nothing
@@ -974,7 +974,7 @@ formattedString str = do
974 return [ mknode "w:r" [] $
974 return [ mknode "w:r" [] $
975 props ++
975 props ++
976 [ mknode (if inDel then "w:delText" else "w:t")
976 [ mknode (if inDel then "w:delText" else "w:t")
977− [("xml:space","preserve")] str ] ]
977+ [("xml:space","preserve")] (stripInvalidChars str) ] ]
978
978
979setFirstPara :: WS ()
979setFirstPara :: WS ()
980setFirstPara = modify $ \s -> s { stFirstPara = True }
980setFirstPara = modify $ \s -> s { stFirstPara = True }