diff options
author | John MacFarlane <jgm@berkeley.edu> | 2013-08-08 10:42:52 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2013-08-08 10:42:52 -0700 |
commit | 12e7ec40707bfb716bb9add82e4320558e065492 (patch) | |
tree | 12c6125683dadc91f33d76cf122e3fded9fff966 /src/Text | |
parent | 802dc9a8b9f206eb3be592ab19067f637eb2a3ee (diff) | |
download | pandoc-12e7ec40707bfb716bb9add82e4320558e065492.tar.gz |
Added Text.Pandoc.Compat.TagSoupEntity.
This allows pandoc to compile with tagsoup 0.13.x.
Thanks to Dirk Ullrich for the patch.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Compat/TagSoupEntity.hs | 15 | ||||
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/DocBook.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/OPML.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/XML.hs | 2 |
5 files changed, 19 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Compat/TagSoupEntity.hs b/src/Text/Pandoc/Compat/TagSoupEntity.hs new file mode 100644 index 000000000..80985aef9 --- /dev/null +++ b/src/Text/Pandoc/Compat/TagSoupEntity.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE CPP #-} +module Text.Pandoc.Compat.TagSoupEntity (lookupEntity + ) where + +import qualified Text.HTML.TagSoup.Entity as TE + +lookupEntity :: String -> Maybe Char +#if MIN_VERSION_tagsoup(0,13,0) +lookupEntity = str2chr . TE.lookupEntity + where str2chr :: Maybe String -> Maybe Char + str2chr (Just [c]) = Just c + str2chr _ = Nothing +#else +lookupEntity = TE.lookupEntity +#endif diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 4ade6def8..2f42aba41 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -161,7 +161,7 @@ import Data.List ( intercalate, transpose ) import Text.Pandoc.Shared import qualified Data.Map as M import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions) -import Text.HTML.TagSoup.Entity ( lookupEntity ) +import Text.Pandoc.Compat.TagSoupEntity ( lookupEntity ) import Data.Default import qualified Data.Set as Set import Control.Monad.Reader diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index 0058e889c..6a799e270 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -4,7 +4,7 @@ import Text.Pandoc.Options import Text.Pandoc.Definition import Text.Pandoc.Builder import Text.XML.Light -import Text.HTML.TagSoup.Entity (lookupEntity) +import Text.Pandoc.Compat.TagSoupEntity (lookupEntity) import Data.Generics import Data.Monoid import Data.Char (isSpace) diff --git a/src/Text/Pandoc/Readers/OPML.hs b/src/Text/Pandoc/Readers/OPML.hs index c9726d195..35d01e877 100644 --- a/src/Text/Pandoc/Readers/OPML.hs +++ b/src/Text/Pandoc/Readers/OPML.hs @@ -6,7 +6,7 @@ import Text.Pandoc.Builder import Text.Pandoc.Readers.HTML (readHtml) import Text.Pandoc.Readers.Markdown (readMarkdown) import Text.XML.Light -import Text.HTML.TagSoup.Entity (lookupEntity) +import Text.Pandoc.Compat.TagSoupEntity (lookupEntity) import Data.Generics import Data.Monoid import Control.Monad.State diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs index 89ae81a10..c11af9a19 100644 --- a/src/Text/Pandoc/XML.hs +++ b/src/Text/Pandoc/XML.hs @@ -38,7 +38,7 @@ module Text.Pandoc.XML ( escapeCharForXML, import Text.Pandoc.Pretty import Data.Char (ord, isAscii, isSpace) -import Text.HTML.TagSoup.Entity (lookupEntity) +import Text.Pandoc.Compat.TagSoupEntity (lookupEntity) -- | Escape one character as needed for XML. escapeCharForXML :: Char -> String |