module Text.HTML.Yuuko where import Text.XML.HXT.Arrow import qualified Text.XML.HXT.Arrow.XPathSimple as XS import System.IO.Unsafe in_html :: [(String, String)] in_html = [(a_parse_html, v_1)] in_xml :: [(String, String)] in_xml = [(a_ignore_none_xml_contents, v_1)] yuuko :: String -> String -> [String] yuuko = yuuko_base in_html show_tree yuuko_xml :: String -> String -> [String] yuuko_xml = yuuko_base in_xml show_tree yuuko_for_text :: String -> String -> [String] yuuko_for_text = yuuko_base in_html getText show_tree :: IOStateArrow () XmlTree String show_tree = writeDocumentToString write_args where write_args = [ (a_no_xml_pi, v_0) , (a_output_xml, v_0) ] yuuko_base :: [(String, String)] -> (IOStateArrow () XmlTree String) -> String -> String -> [String] yuuko_base args formatter expr s = unsafePerformIO $ runX process where read_args = [ (a_validate, v_0) , (a_issue_warnings, v_0) ] ++ args process = readString read_args s >>> XS.getXPathTreesInDoc expr >>> formatter