f71a7151434ffc54f1887ff927e19cf546b3f13e
[wix.git] / src / Wix.lhs
1 \begin{code}
2 module Wix(main')
3 where
4 import Edu.Berkeley.Sbp.Haskell.SBP
5 import FromTree
6 import Doc
7 import Html
8 import Foreign.Java
9 import qualified Text.PrettyPrint.Leijen as PP
10
11 process :: String -> IO String
12 process file = do t <- parseFile file
13                   return
14                    $ toHtml
15                     $ ((fromTree $ coalesceFlatHeadlessNodes t) :: Doc)
16
17 foreign import jvm safe "HaskellHelper.putBack" putBack :: JString -> IO ()
18
19 main' file verbosity =
20              do t <- parseFile file
21                 if verbosity > 0
22                   then
23                      putStrLn $ (PP.displayS
24                               $  PP.renderPretty (0.9) 80 
25                               $  prettyPrintTree (coalesceFlatHeadlessNodes t))
26                               ""
27                   else
28                      return ()
29                 doc <- return ((fromTree $ coalesceFlatHeadlessNodes t) :: Doc)
30                 if verbosity > 1
31                   then
32                      putStrLn $ (PP.displayS
33                               $  PP.renderPretty (0.9) 80 
34                               $  PP.pretty doc)
35                               ""
36                   else
37                      return ()
38                 js <- packJString $ toHtml doc
39                 putBack js
40
41 \end{code}
42
43
44
45