summaryrefslogtreecommitdiff
path: root/hs/src/Handlingar.hs
blob: 157e95d284fbf870a69bbca024822f2d71a18820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{-# LANGUAGE OverloadedStrings #-}

module Handlingar
( main
) where

import System.FilePath (dropFileName)
import System.Posix.Directory (changeWorkingDirectory, getWorkingDirectory)
import Text.Pandoc (runIOorExplode)
import qualified Data.Text.IO as T
import System.FilePath ((</>))

-- 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

            here <- getWorkingDirectory
            changeWorkingDirectory $ dropFileName file

            text <- T.readFile file
            -- TODO mkdir
            runIOorExplode $ handleHtml text heading (here </> "out")

            changeWorkingDirectory here

        _ -> error "Usage: ./main handlingar <input-file> <heading>"