diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-02-10 12:48:38 -0600 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-02-10 12:48:38 -0600 |
| commit | 0c677070edf9978cb85a0b521f7e6e0ef6d6b491 (patch) | |
| tree | 1bf0a024ea2c1ccc9c21c68b916e76017bafd310 /src/WWW/HW.hs | |
| parent | 75ac829ee7d661d758f7828e609e28ee4e05d038 (diff) | |
| download | main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.gz main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.bz2 main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.lz main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.xz main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.zst main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.zip | |
A lot of work on aliases and the like
Diffstat (limited to 'src/WWW/HW.hs')
| -rw-r--r-- | src/WWW/HW.hs | 19 |
1 files changed, 18 insertions, 1 deletions
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" |
