Add standalone utility to convert telml to html
Getty Ritter
6 years ago
11 | 11 |
cabal-version: >= 1.10
|
12 | 12 |
build-type: Simple
|
13 | 13 |
extra-source-files: README.md, ChangeLog.md
|
| 14 |
|
| 15 |
executable telml2html
|
| 16 |
default-language: Haskell2010
|
| 17 |
ghc-options: -Wall
|
| 18 |
hs-source-dirs: telml2html
|
| 19 |
main-is: Main.hs
|
| 20 |
build-depends: base
|
| 21 |
, telml
|
| 22 |
, telml-markup
|
| 23 |
, blaze-markup
|
14 | 24 |
|
15 | 25 |
library
|
16 | 26 |
default-language: Haskell2010
|
| 1 |
module Main where
|
| 2 |
|
| 3 |
import Control.Monad ((>=>))
|
| 4 |
import qualified Data.TeLML as TeLML
|
| 5 |
import qualified Data.TeLML.Markup as TeLML
|
| 6 |
import qualified Text.Blaze.Renderer.String as B
|
| 7 |
import qualified System.Exit as Sys
|
| 8 |
|
| 9 |
doRender :: String -> Either String String
|
| 10 |
doRender = TeLML.parse >=> TeLML.render >=> return . B.renderMarkup
|
| 11 |
|
| 12 |
main :: IO ()
|
| 13 |
main = do
|
| 14 |
cs <- getContents
|
| 15 |
case doRender cs of
|
| 16 |
Left err -> Sys.die err
|
| 17 |
Right x -> putStrLn x
|