Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Don't escape text contents of script tags!"

This reverts commit fb438c9.
We'll use tagsoup-0.12.5 instead.
  • Loading branch information...
commit dcf7f7c617f87abc8d577640c736cf651f219b9d 1 parent fb438c9
@jgm authored
Showing with 1 addition and 21 deletions.
  1. +1 −21 standalone-html.hs
View
22 standalone-html.hs
@@ -10,7 +10,6 @@ import Data.ByteString (ByteString)
import Data.ByteString.UTF8 (toString, fromString)
import System.FilePath (takeExtension, dropExtension)
import Data.Char (toLower, isAscii, isAlphaNum)
-import Data.Monoid
import Codec.Compression.GZip as Gzip
import qualified Data.ByteString.Lazy as L
@@ -199,29 +198,10 @@ getRaw t src = do
raw <- getItem src'
return (decompress raw, mime)
-renderNormal :: [Tag ByteString] -> ByteString
-renderNormal = renderTagsOptions renderOptions{ optMinimize = (\t -> t == "br" || t == "img" || t == "meta" || t == "link" ) }
-
--- Workaround problem in tagsoup; text inside <script> should not be escaped.
-renderScriptTag :: Tag ByteString -> ByteString
-renderScriptTag (TagText s) =
- renderTagsOptions renderOptions{ optEscape = id } [TagText s]
-renderScriptTag x = renderNormal [x]
-
-render :: [Tag ByteString] -> ByteString
-render (t:ts) | isTagOpenName "script" t =
- renderNormal [t] `mappend`
- mconcat (map renderScriptTag contents) `mappend`
- render rest
- where (contents, rest) = break (isTagCloseName "script") ts
-render (t:ts) = renderNormal nonscripts `mappend` render rest
- where (nonscripts, rest) = break (isTagOpenName "script") (t:ts)
-render [] = mempty
-
main :: IO ()
main = do
inp <- B.getContents
let tags = parseTags inp
out <- mapM convertTag tags
- B.putStr $ render out
+ B.putStr $ renderTagsOptions renderOptions{ optMinimize = (\t -> t == "br" || t == "img" || t == "meta" || t == "link" ) } out
Please sign in to comment.
Something went wrong with that request. Please try again.