Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implements extraction and consolidation of JavaScript code in an HTML page.
- consolidate :: String -> Maybe URI -> IO String
- extract :: String -> Maybe URI -> IO String
- type TArr a b = IOStateArrow ConsState a b
- consolidateArr :: TArr XmlTree XmlTree
- extractJSArr :: TArr XmlTree (XmlTree, String)
- initialConsState :: Bool -> Maybe URI -> [Cookie] -> ConsState
- insertJSArr :: TArr (XmlTree, String) XmlTree
- parseHTML :: String -> Maybe URI -> TArr a XmlTree
- renderHTML :: ConsState -> TArr XmlTree XmlTree -> IO String
Simple API
consolidate :: String -> Maybe URI -> IO String Source
Takes an HTML page source as a string and an optional base URI (for resolving relative URI's) and produces an HTML page with all the scripts consolidated in one inline script element.
extract :: String -> Maybe URI -> IO String Source
Extacts and pretty-print all the JavaScript code in the given HTML page source as a single program. Takes an optional base URI for resolving relative URI's.
Advanced arrow-based API
type TArr a b = IOStateArrow ConsState a b Source
Our XML transformation arrow type
consolidateArr :: TArr XmlTree XmlTree Source
Main normalization arrow. Factored into extractJS and insertJS to allow custom transformation of JavaScript inbetween.
extractJSArr :: TArr XmlTree (XmlTree, String) Source
Extracts all the JavaScript from HTML. There shouldn't be any JavaScript in the resulting XmlTree
:: Bool | Whether to ignore errors (parse errors, resource not found etc.) |
-> Maybe URI | base URI |
-> [Cookie] | Cookies |
-> ConsState |
A constructor function for making an initial consolidation state (needed for running the arrows in the advanced API)