1 {-# LANGUAGE ScopedTypeVariables, RecordWildCards #-}
11 import Text.XML.HXT.Core
13 import CommandLine (Args(..), apply_args)
16 my_read :: String -> IOStateArrow s b XmlTree
18 readDocument [ withValidate no,
20 withInputEncoding utf8,
23 -- | If we're given an empty path, return a handle to
24 -- 'stdout'. Otherwise, open the given file and return a read/write
26 get_output_handle :: FilePath -> IO Handle
27 get_output_handle path =
31 openBinaryFile path WriteMode
34 -- | Convert the given article to either a URL or a filesystem
35 -- path. If the given article exists on the filesystem, we assume
36 -- it's a file. Otherwise, we check to see if it's a URL. Failing
37 -- that, we try to construct a URL from what we're given and do our
39 real_article_path :: String -> IO String
40 real_article_path = return . id
44 Args{..} <- apply_args
45 output_handle <- get_output_handle output
46 input_path <- real_article_path article
47 let html = my_read input_path
51 Just stuff -> epublish stuff output_handle