packages feed

agda-server-0.1: Standalone.hs

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


module Standalone
    ( standalone
    ) where

import Memo
import JSDictDef

import Text.XHtml.Strict (showHtmlFragment)
import Text.Pandoc

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

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
            { docTitle = [Str inp']
            , docAuthors = []
            , docDate = []
            }

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