git.iko.soy/typeable/pandoc
on master help sign in
Remove TagSoup compat
3f8d3d8Jesse Rosenthal
pandoc.cabal−1
@@ -415,7 +415,6 @@ Library
415 Text.Pandoc.Slides,
415 Text.Pandoc.Slides,
416 Text.Pandoc.Highlighting,
416 Text.Pandoc.Highlighting,
417 Text.Pandoc.Compat.Time,
417 Text.Pandoc.Compat.Time,
418− Text.Pandoc.Compat.TagSoupEntity,
419 Paths_pandoc
418 Paths_pandoc
420
419
421 Buildable: True
420 Buildable: True
src/Text/Pandoc/Compat/TagSoupEntity.hsdeleted−15
@@ -1,15 +0,0 @@
1−{-# LANGUAGE CPP #-}
2−module Text.Pandoc.Compat.TagSoupEntity (lookupEntity
3− ) where
4−
5−import qualified Text.HTML.TagSoup.Entity as TE
6−
7−lookupEntity :: String -> Maybe Char
8−#if MIN_VERSION_tagsoup(0,13,0)
9−lookupEntity = str2chr . TE.lookupEntity
10− where str2chr :: Maybe String -> Maybe Char
11− str2chr (Just [c]) = Just c
12− str2chr _ = Nothing
13−#else
14−lookupEntity = TE.lookupEntity
15−#endif
src/Text/Pandoc/Parsing.hs+3−3
@@ -184,7 +184,7 @@ import Text.Pandoc.Shared
184import qualified Data.Map as M
184import qualified Data.Map as M
185import Text.TeXMath.Readers.TeX.Macros (applyMacros, Macro,
185import Text.TeXMath.Readers.TeX.Macros (applyMacros, Macro,
186 parseMacroDefinitions)
186 parseMacroDefinitions)
187−import Text.Pandoc.Compat.TagSoupEntity ( lookupEntity )
187+import Text.HTML.TagSoup.Entity ( lookupEntity )
188import Text.Pandoc.Asciify (toAsciiChar)
188import Text.Pandoc.Asciify (toAsciiChar)
189import Data.Monoid ((<>))
189import Data.Monoid ((<>))
190import Data.Default
190import Data.Default
@@ -578,8 +578,8 @@ characterReference = try $ do
578 '#':_ -> ent
578 '#':_ -> ent
579 _ -> ent ++ ";"
579 _ -> ent ++ ";"
580 case lookupEntity ent' of
580 case lookupEntity ent' of
581− Just c -> return c
581+ Just (c : _) -> return c
582− Nothing -> fail "entity not found"
582+ _ -> fail "entity not found"
583
583
584-- | Parses an uppercase roman numeral and returns (UpperRoman, number).
584-- | Parses an uppercase roman numeral and returns (UpperRoman, number).
585upperRoman :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
585upperRoman :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
src/Text/Pandoc/Readers/DocBook.hs+3−3
@@ -5,7 +5,7 @@ import Text.Pandoc.Options
5import Text.Pandoc.Definition
5import Text.Pandoc.Definition
6import Text.Pandoc.Builder
6import Text.Pandoc.Builder
7import Text.XML.Light
7import Text.XML.Light
8−import Text.Pandoc.Compat.TagSoupEntity (lookupEntity)
8+import Text.HTML.TagSoup.Entity (lookupEntity)
9import Data.Either (rights)
9import Data.Either (rights)
10import Data.Generics
10import Data.Generics
11import Data.Char (isSpace)
11import Data.Char (isSpace)
@@ -564,7 +564,7 @@ normalizeTree = everywhere (mkT go)
564 go xs = xs
564 go xs = xs
565
565
566convertEntity :: String -> String
566convertEntity :: String -> String
567−convertEntity e = maybe (map toUpper e) (:[]) (lookupEntity e)
567+convertEntity e = maybe (map toUpper e) id (lookupEntity e)
568
568
569-- convenience function to get an attribute value, defaulting to ""
569-- convenience function to get an attribute value, defaulting to ""
570attrValue :: String -> Element -> String
570attrValue :: String -> Element -> String
@@ -916,7 +916,7 @@ elementToStr x = x
916parseInline :: Content -> DB Inlines
916parseInline :: Content -> DB Inlines
917parseInline (Text (CData _ s _)) = return $ text s
917parseInline (Text (CData _ s _)) = return $ text s
918parseInline (CRef ref) =
918parseInline (CRef ref) =
919− return $ maybe (text $ map toUpper ref) (text . (:[])) $ lookupEntity ref
919+ return $ maybe (text $ map toUpper ref) (text) $ lookupEntity ref
920parseInline (Elem e) =
920parseInline (Elem e) =
921 case qName (elName e) of
921 case qName (elName e) of
922 "equation" -> equation displayMath
922 "equation" -> equation displayMath
src/Text/Pandoc/Readers/OPML.hs+2−2
@@ -7,7 +7,7 @@ import Text.Pandoc.Builder
7import Text.Pandoc.Readers.HTML (readHtml)
7import Text.Pandoc.Readers.HTML (readHtml)
8import Text.Pandoc.Readers.Markdown (readMarkdown)
8import Text.Pandoc.Readers.Markdown (readMarkdown)
9import Text.XML.Light
9import Text.XML.Light
10−import Text.Pandoc.Compat.TagSoupEntity (lookupEntity)
10+import Text.HTML.TagSoup.Entity (lookupEntity)
11import Data.Generics
11import Data.Generics
12import Control.Monad.State
12import Control.Monad.State
13import Data.Default
13import Data.Default
@@ -53,7 +53,7 @@ normalizeTree = everywhere (mkT go)
53 go xs = xs
53 go xs = xs
54
54
55convertEntity :: String -> String
55convertEntity :: String -> String
56−convertEntity e = maybe (map toUpper e) (:[]) (lookupEntity e)
56+convertEntity e = maybe (map toUpper e) id (lookupEntity e)
57
57
58-- convenience function to get an attribute value, defaulting to ""
58-- convenience function to get an attribute value, defaulting to ""
59attrValue :: String -> Element -> String
59attrValue :: String -> Element -> String
src/Text/Pandoc/XML.hs+2−2
@@ -38,7 +38,7 @@ module Text.Pandoc.XML ( escapeCharForXML,
38
38
39import Text.Pandoc.Pretty
39import Text.Pandoc.Pretty
40import Data.Char (ord, isAscii, isSpace)
40import Data.Char (ord, isAscii, isSpace)
41−import Text.Pandoc.Compat.TagSoupEntity (lookupEntity)
41+import Text.HTML.TagSoup.Entity (lookupEntity)
42
42
43-- | Escape one character as needed for XML.
43-- | Escape one character as needed for XML.
44escapeCharForXML :: Char -> String
44escapeCharForXML :: Char -> String
@@ -101,7 +101,7 @@ toEntities (c:cs)
101fromEntities :: String -> String
101fromEntities :: String -> String
102fromEntities ('&':xs) =
102fromEntities ('&':xs) =
103 case lookupEntity ent' of
103 case lookupEntity ent' of
104− Just c -> c : fromEntities rest
104+ Just c -> c ++ fromEntities rest
105 Nothing -> '&' : fromEntities xs
105 Nothing -> '&' : fromEntities xs
106 where (ent, rest) = case break (\c -> isSpace c || c == ';') xs of
106 where (ent, rest) = case break (\c -> isSpace c || c == ';') xs of
107 (zs,';':ys) -> (zs,ys)
107 (zs,';':ys) -> (zs,ys)