yuuko 2009.10.23.1 → 2009.10.23.2
raw patch · 6 files changed
+52/−8 lines, 6 filesdep +haskell98dep +utf8-preludenew-component:exe:yuuko
Dependencies added: haskell98, utf8-prelude
Files
- Nemesis +3/−0
- changelog.md +13/−0
- readme.md +3/−2
- src/Main.hs +11/−0
- src/Text/HTML/Yuuko.hs +14/−5
- yuuko.cabal +8/−1
Nemesis view
@@ -15,6 +15,9 @@ desc "start console" task "i" (sh "ghci -isrc -Wall src/Text/HTML/Yuuko.hs") + desc "start main"+ task "main" (sh "ghci -isrc -Wall src/Main.hs")+ desc "put all .hs files in manifest" task "manifest" $ do sh "find . | grep 'hs$' > manifest"
changelog.md view
@@ -1,3 +1,16 @@+2009.10.23.2+------------++### Feature++* add `yuuko` binary+* add `yuuko_xml` lib for handling xml, e.g. rss+* magic pure (with unsafePerformIO)++### Fix++* handle utf8 html+ 2009.10.23.1 ------------
readme.md view
@@ -7,9 +7,10 @@ ======= - yuuko "//body" "<html><body>hi</body></html>"+ > echo '<div>hi</div><div>there</div>' | yuuko //div - > ["hi"]+ hi+ there Tutorial ========
+ src/Main.hs view
@@ -0,0 +1,11 @@+module Main where++import Text.HTML.Yuuko+import System++main :: IO ()+main = do+ args <- getArgs+ case args of+ [] -> putStrLn "\n usage: echo '<div>hi</div>' | yuuko //div\n"+ expr:_ -> interact $ concatMap (++ "\n") . (yuuko expr)
src/Text/HTML/Yuuko.hs view
@@ -2,23 +2,32 @@ import Text.XML.HXT.Arrow import qualified Text.XML.HXT.Arrow.XPathSimple as XS+import System.IO.Unsafe -yuuko :: String -> String -> IO [String]-yuuko expr s = do+yuuko :: String -> String -> [String]+yuuko = yuuko_base [(a_parse_html, v_1)]++yuuko_xml :: String -> String -> [String]+yuuko_xml = yuuko_base [(a_ignore_none_xml_contents, v_1)]++yuuko_base :: [(String, String)] -> String -> String -> [String]+yuuko_base args expr s = unsafePerformIO $ runX process where read_args = [ (a_validate, v_0)- , (a_parse_html, v_1)- , (a_encoding, utf8) , (a_issue_warnings, v_0) ]+ ++ args write_args = - [ (a_encoding, utf8) ]+ [ (a_encoding, utf8)+ , (a_no_xml_pi, v_0 )+ ] process = readString read_args s >>> XS.getXPathTreesInDoc expr >>> writeDocumentToString write_args+
yuuko.cabal view
@@ -1,5 +1,5 @@ Name: yuuko-Version: 2009.10.23.1+Version: 2009.10.23.2 Build-type: Simple Synopsis: A transcendental HTML parser gently wrapping the HXT library Description:@@ -21,6 +21,13 @@ category: Text homepage: http://github.com/nfjinjing/yuuko data-files: readme.md, changelog.md, known-issues.md, Nemesis++Executable yuuko+ ghc-options: -Wall+ build-depends: base >= 4 && < 5, hxt, haskell98, utf8-prelude+ hs-source-dirs: src/+ main-is: Main.hs+ other-modules: Text.HTML.Yuuko library ghc-options: -Wall