From 12e7ec40707bfb716bb9add82e4320558e065492 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 8 Aug 2013 10:42:52 -0700 Subject: Added Text.Pandoc.Compat.TagSoupEntity. This allows pandoc to compile with tagsoup 0.13.x. Thanks to Dirk Ullrich for the patch. --- pandoc.cabal | 3 ++- src/Text/Pandoc/Compat/TagSoupEntity.hs | 15 +++++++++++++++ src/Text/Pandoc/Parsing.hs | 2 +- src/Text/Pandoc/Readers/DocBook.hs | 2 +- src/Text/Pandoc/Readers/OPML.hs | 2 +- src/Text/Pandoc/XML.hs | 2 +- 6 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/Text/Pandoc/Compat/TagSoupEntity.hs diff --git a/pandoc.cabal b/pandoc.cabal index 192b6c5fd..19f8c14ef 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -253,7 +253,7 @@ Library citeproc-hs >= 0.3.7 && < 0.4, pandoc-types >= 1.12 && < 1.13, aeson >= 0.6 && < 0.7, - tagsoup >= 0.12.5 && < 0.13, + tagsoup >= 0.12.5 && < 0.14, base64-bytestring >= 0.1 && < 1.1, zlib >= 0.5 && < 0.6, highlighting-kate >= 0.5.5 && < 0.6, @@ -336,6 +336,7 @@ Library Text.Pandoc.Slides, Text.Pandoc.Highlighting, Text.Pandoc.Compat.Monoid, + Text.Pandoc.Compat.TagSoupEntity, Paths_pandoc Buildable: True 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 -- cgit v1.2.3