Permalink
Browse files

Handle scripts as well.

  • Loading branch information...
1 parent 1808aa4 commit a01d720e63fdcdb4b784a0d77ec7e32e069028b1 @jgm committed Jul 13, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 standalone-html.hs
View
@@ -171,7 +171,14 @@ convertTag t@(TagOpen "script" as) =
(B.pack $ escapeURIString isAscii $ B.unpack raw)
return $ TagOpen "script" (("src",enc) : [(x,y) | (x,y) <- as, x /= "src"])
_ -> return t
-convertTag t@(TagOpen "style" as) = return t -- TODO
+convertTag t@(TagOpen "style" as) =
+ case fromAttrib "href" t of
+ src | not (B.null src) -> do
+ (raw, mime) <- getRaw t src
+ let enc = "data:" `B.append` mime `B.append` "," `B.append`
+ (B.pack $ escapeURIString isAscii $ B.unpack raw)
+ return $ TagOpen "style" (("href",enc) : [(x,y) | (x,y) <- as, x /= "href"])
+ _ -> return t
convertTag t = return t
getRaw :: Tag ByteString -> ByteString -> IO (ByteString, ByteString)

0 comments on commit a01d720

Please sign in to comment.