git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug in fromEntities.

The previous version would turn "hi & low you know;" into "hi &".

commitf40b2eb2e763ed08768e08394e5a131bd4373126 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 14 Apr 2012, 22:52 (15 years ago) parente37c452
1 file changed+3−3
src/Text/Pandoc/XML.hs+3−3
src/Text/Pandoc/XML.hs+3−3
@@ -38,7 +38,7 @@ module Text.Pandoc.XML ( stripTags,
3838 fromEntities ) where
3939
4040import Text.Pandoc.Pretty
41−import Data.Char (ord, isAscii)
41+import Data.Char (ord, isAscii, isSpace)
4242import Text.HTML.TagSoup.Entity (lookupEntity)
4343
4444-- | Remove everything between <...>
@@ -106,8 +106,8 @@ fromEntities :: String -> String
106106fromEntities ('&':xs) =
107107 case lookupEntity ent of
108108 Just c -> c : fromEntities rest
109− Nothing -> '&' : fromEntities rest
110− where (ent, rest) = case break (==';') xs of
109+ Nothing -> '&' : fromEntities xs
110+ where (ent, rest) = case break (\c -> isSpace c || c == ';') xs of
111111 (zs,';':ys) -> (zs,ys)
112112 _ -> ("",xs)
113113fromEntities (x:xs) = x : fromEntities xs