@@ -59,6 +59,8 @@ module Text.Pandoc.Shared (
5959 uniqueIdent,
6060 isHeaderBlock,
6161 headerShift,
62+ -- * TagSoup HTML handling
63+ renderTags',
6264 -- * File handling
6365 inDirectory,
6466 findDataFile,
@@ -89,6 +91,8 @@ import Text.Pandoc.Pretty (charWidth)
8991import System.Locale (defaultTimeLocale)
9092import Data.Time
9193import System.IO (stderr)
94+import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..),
95+ renderOptions)
9296
9397--
9498-- List processing
@@ -448,6 +452,22 @@ headerShift n = bottomUp shift
448452 shift (Header level inner) = Header (level + n) inner
449453 shift x = x
450454
455+--
456+-- TagSoup HTML handling
457+--
458+
459+-- | Render HTML tags.
460+renderTags' :: [Tag String] -> String
461+renderTags' = renderTagsOptions
462+ renderOptions{ optMinimize = \x ->
463+ let y = map toLower x
464+ in y == "hr" || y == "br" ||
465+ y == "img" || y == "meta" ||
466+ y == "link"
467+ , optRawTag = \x ->
468+ let y = map toLower x
469+ in y == "script" || y == "style" }
470+
451471--
452472-- File handling
453473--
@@ -501,3 +521,5 @@ safeRead s = case reads s of
501521 (d,x):_
502522 | all isSpace x -> return d
503523 _ -> fail $ "Could not read `" ++ s ++ "'"
524+
525+