{-# LANGUAGE OverloadedStrings #-} module Handlingar ( main ) where import System.FilePath (dropFileName) import Text.Pandoc (runIOorExplode) import qualified Data.Text.IO as T import System.Directory (canonicalizePath, createDirectoryIfMissing, withCurrentDirectory) -- import Handlingar.TexOutput (handleTex) import Handlingar.HtmlOutput (handleHtml) -- TODO pandoc possibly contains a better way to handle attachements, -- something about media bag -- TODO mail attachments from any type supported by pandoc should -- work, fix a (MimeType -> PandocParser) function -- TODO input file shouldn't be locked to vimwiki -- TODO output other things than PDF -- - Plain text, requires own redering engine (pandoc plugin?) -- - HTML, should be multi page for each attachement -- - with support for RXML templates -- - Mail, where mail attachements are copied verbatim -- other attachements become mail attachments -- renumber :: Int -> [Blocks] -> [Blocks] main :: [String] -> IO () main args = do case args of [file, heading] -> do destination <- canonicalizePath "out" createDirectoryIfMissing True destination text <- T.readFile file withCurrentDirectory (dropFileName file) $ do runIOorExplode $ handleHtml text heading destination _ -> error "Usage: ./main handlingar "