This repository has been archived by the owner on May 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
main.hs
77 lines (58 loc) · 2.14 KB
/
main.hs
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{-# LANGUAGE OverloadedStrings, LambdaCase #-}
import Data.Maybe
import Image.LaTeX.Render
import Image.LaTeX.Render.Pandoc
import Network.URI
import Text.Pandoc
import Hakyll
import Hakyll.Contrib.Agda
import Hakyll.Contrib.LaTeX
import qualified Data.Map as M
import qualified Data.Set as S
agdaOpts :: CommandLineOptions
agdaOpts = defaultOptions
defaultPreamble :: String
defaultPreamble = ""
formulaSettings :: String -> PandocFormulaOptions
formulaSettings pre
= defaultPandocFormulaOptions
{ formulaOptions = \case DisplayMath -> displaymath { preamble = pre }
_ -> math { preamble = pre }
}
readerSettings :: ReaderOptions
readerSettings = def { readerSmart = True
, readerOldDashes = True
, readerExtensions = S.insert Ext_pipe_tables pandocExtensions
}
writerSettings :: WriterOptions
writerSettings = def { writerHighlight = True }
agdaLibURI :: URI
Just agdaLibURI = parseURIReference "/agda-lib/"
main :: IO ()
main = do
renderEquations <- initFormulaCompilerDataURI 1000 defaultEnv
hakyll $ do
match "css/*" $ do
route idRoute
compile compressCssCompiler
match "static/*" $ do
route idRoute
compile copyFileCompiler
match "templates/*" $
compile templateCompiler
match ("pages/*.md" .||. "pages/*.lagda") $ do
route (setExtension "html")
compile $ do
pr <- fmap (fromMaybe defaultPreamble . M.lookup "preamble") (getMetadata =<< getUnderlying)
literateAgdaCompilerWithTransformM agdaOpts Markdown agdaLibURI readerSettings writerSettings
(traverse $ renderEquations $ formulaSettings pr)
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
match "toc.md" $ do
route (setExtension "html")
compile $ pandocCompiler >>=
loadAndApplyTemplate "templates/toc.html" defaultContext
match "index.md" $ do
route (setExtension "html")
compile $ pandocCompiler >>=
loadAndApplyTemplate "templates/cover.html" defaultContext