Go through a good bit of nonsense to get it successfully parsing our three test cases.
[dead/lwn-epub.git] / src / Main.hs
1 {-# LANGUAGE ScopedTypeVariables #-}
2 module Main
3 where
4
5 import Data.Maybe (fromJust)
6 import Text.XML.HXT.Core -- (SysConfigList, IOStateArrow, XmlTree, readDocument)
7
8 import Epublishable
9 import LWN.ArticlePage
10 import LWN.FullPage
11
12 my_read :: String -> IOStateArrow s b XmlTree
13 my_read =
14 readDocument [ withValidate no,
15 withParseHTML yes,
16 withInputEncoding utf8,
17 withWarnings no ]
18
19 main :: IO ()
20 main = do
21 let article_html = my_read "test/fixtures/501317-article.html"
22 ioap <- parse article_html
23 let article_page :: ArticlePage = fromJust $ ioap
24 epublish article_page "single_article.epub"
25
26 let page_html = my_read "test/fixtures/500848-page.html"
27 ioap_f <- parse page_html
28 let full_page :: FullPage = fromJust $ ioap_f
29 epublish full_page "full_page.epub"
30
31 let bigpage_html = my_read "test/fixtures/50844-bigpage.html"
32 ioap_bp <- parse bigpage_html
33 let bigpage :: FullPage = fromJust $ ioap_bp
34 epublish bigpage "bigpage.epub"
35
36 putStrLn "Done."