\begin{code}
-- Copyright 2008 the Contributors, as shown in the revision logs.
-- Licensed under the Apache Public Source License 2.0 ("the License").
-- You may not use this file except in compliance with the License.

module Wix(main')
where
import Edu_Berkeley_Sbp_Haskell_SBP
import FromTree
import Doc
import Html
import Foreign.Java
import qualified Text.PrettyPrint.Leijen as PP

process :: String -> IO String
process file = do t <- parseFile file
                  return
                   $ toHtml
                    $ ((fromTree $ coalesceFlatHeadlessNodes t) :: Doc)

foreign import jvm safe "HaskellHelper.putBack" putBack :: JString -> IO ()

main' file verbosity =
             do t <- parseFile file
                if verbosity > 0
                  then
                     putStrLn $ (PP.displayS
                              $  PP.renderPretty (0.9) 80 
                              $  prettyPrintTree (coalesceFlatHeadlessNodes t))
                              ""
                  else
                     return ()
                doc <- return ((fromTree $ coalesceFlatHeadlessNodes t) :: Doc)
                if verbosity > 1
                  then
                     putStrLn $ (PP.displayS
                              $  PP.renderPretty (0.9) 80 
                              $  PP.pretty doc)
                              ""
                  else
                     return ()
                js <- packJString $ toHtml doc
                putBack js

\end{code}




