packages feed

agda-server-0.1.1: Standalone.hs

-- getResponse :: url -> params -> SnapState FullHtml


module Standalone
    ( standalone
    ) where

import Memo
import JSDictDef

import Text.XHtml.Strict (showHtmlFragment)
import Text.Pandoc
import qualified Data.Map as Map

---------------------------------------------------------------

standalone
    :: String
    -> Common
    -> FilePath
    -> FilePath
    -> Memo String
standalone ht common workdir filepath = do

    (filecont, inp', inp) <- loadAgdaFile workdir filepath

    (i2, thediv_) <- thediv'

    setMainDiv inp i2

    res <- fmap (\x -> pre << thediv_ [theclass "answer"] << x)
            $ common inp filecont

    let
        meta = Meta $ Map.fromList
            [ ("title", MetaInlines [Str inp']) ]

    return $ writeHtmlString `flip` Pandoc meta [ RawBlock (Format "html") $ showHtmlFragment res ]
      $ def
        { writerStandalone      = True
        , writerTableOfContents = True
        , writerSectionDivs     = True
        , writerTemplate        = ht
        }