summaryrefslogtreecommitdiff
path: root/src/WWW
diff options
context:
space:
mode:
Diffstat (limited to 'src/WWW')
-rw-r--r--src/WWW/Base.hs11
-rw-r--r--src/WWW/HW.hs19
-rw-r--r--src/WWW/Templates.hs2
3 files changed, 31 insertions, 1 deletions
diff --git a/src/WWW/Base.hs b/src/WWW/Base.hs
index 7c752da..ab4f214 100644
--- a/src/WWW/Base.hs
+++ b/src/WWW/Base.hs
@@ -3,11 +3,14 @@ module WWW.Base
, baseHakyll
, domain
, wwwRoot
+ , myHakyllReaderOptions
+ , myHakyllWriterOptions
) where
import Prolog
import Hakyll
import System.Process
+import Text.Pandoc.Options
-- | mathematicaster.org
@@ -34,3 +37,11 @@ baseConfig p = defaultConfiguration
baseHakyll :: MonadIO m => FilePath -> Rules a -> m ()
baseHakyll p = liftIO . hakyllWith (baseConfig p)
+
+myHakyllReaderOptions :: ReaderOptions
+myHakyllReaderOptions = defaultHakyllReaderOptions
+
+myHakyllWriterOptions :: WriterOptions
+myHakyllWriterOptions = defaultHakyllWriterOptions
+ { writerHTMLMathMethod = MathJax mempty
+ }
diff --git a/src/WWW/HW.hs b/src/WWW/HW.hs
index 1ce601f..9387961 100644
--- a/src/WWW/HW.hs
+++ b/src/WWW/HW.hs
@@ -1,6 +1,8 @@
module WWW.HW
( removeEnv
, removeSolutions
+ , setDocLocation
+ , setDocLocation_
-- * LaTeX utils
, LaTeX (..)
, texmap
@@ -9,13 +11,28 @@ module WWW.HW
, module Hakyll.TeX.LaTeX
) where
--- import Prolog
+import Prolog
+import Hakyll
import Hakyll.TeX.HaTeX
import Hakyll.TeX.LaTeX
+import Network.URI
import Text.LaTeX.Base.Syntax
+import Text.LaTeX.Packages.Hyperref
removeEnv :: (String -> Bool) -> LaTeX -> LaTeX
removeEnv p = texmap (\case { TeXEnv s _ _ -> p s; _ -> False }) $ pure mempty
removeSolutions :: LaTeX -> LaTeX
removeSolutions = removeEnv (== "solution")
+
+setDocLocation :: URI -> (String -> [TeXArg] -> Bool) -> Item LaTeX -> Compiler (Item LaTeX)
+setDocLocation u p (Item i l) = Item i <$> texmapM (\case { TeXComm _ _ -> True; _ -> False }) mapper l
+ where
+ mapper = \case
+ TeXComm s args | p s args -> do
+ relpath <- getRoute i >>= maybe (fail $ show i <> " has no route") pure >>= maybe (fail $ "Cannot parse " <> show i <> " as a relative URI") pure . parseRelativeReference
+ pure $ TeXComm s [ FixArg $ url $ toSL $ relpath `relativeTo` u ]
+ x -> pure x
+
+setDocLocation_ :: URI -> Item LaTeX -> Compiler (Item LaTeX)
+setDocLocation_ u = setDocLocation u $ \s _ -> s == "doclink"
diff --git a/src/WWW/Templates.hs b/src/WWW/Templates.hs
index 0068a07..f73236e 100644
--- a/src/WWW/Templates.hs
+++ b/src/WWW/Templates.hs
@@ -13,6 +13,7 @@ import Prolog
import Hakyll
import Hakyll.TeX.TikZ (tikzTemplate)
+import Hakyll.Web.Template.Util (slug)
defaultTemplate :: Template
@@ -29,5 +30,6 @@ myContext :: Context String
myContext = fold
[ constField "personalEmail" "chris@mathematicaster.org"
, constField "workEmail" "coc0014@auburn.edu"
+ , slug
, defaultContext
]