Copyright | Copyright (C) 2023 Yoo Chung |
---|---|
License | All rights reserved |
Maintainer | web@chungyc.org |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Various Hakyll compilers and functions to assist use of Hakyll compilers.
Synopsis
- haskellCompiler :: [String] -> Compiler (Item ByteString)
- mathReaderWith :: ReaderOptions -> ReaderOptions
- mathWriterWith :: WriterOptions -> WriterOptions
- getTocOptionsWith :: WriterOptions -> Compiler WriterOptions
- siteContext :: Context String
- cleanupIndexUrl :: String -> String
Compilers
:: [String] | Extra flags to pass to |
-> Compiler (Item ByteString) |
Run the Haskell code in the underlying file and use its output.
For example,
>>>
let _ = compile $ haskellCompiler []
The Haskell code will be executed using runhaskell
.
It will run with -XGHC2021
and -XOverloadedStrings
.
Extra flags can also be passed to runhaskell
.
For example,
>>>
let _ = compile $ haskellCompiler ["-XTypeFamilies"]
This can compile both Haskell code and literate Haskell code.
Pandoc options
Pandoc reader and writer options that can be used with pandocCompilerWith
.
mathReaderWith :: ReaderOptions -> ReaderOptions Source #
Add support for properly parsing math in the reader options.
Should be used in conjunction with mathWriterWith
for proper math rendering.
For example:
>>>
let readerOptions = mathReaderWith defaultHakyllReaderOptions
>>>
let writerOptions = mathWriterWith defaultHakyllWriterOptions
>>>
let _ = pandocCompilerWith readerOptions writerOptions
mathWriterWith :: WriterOptions -> WriterOptions Source #
Add support for writing out math to HTML in the writer options.
Should be used in conjunction with mathReaderWith
to read input that is to be rendered as math.
For example:
>>>
let readerOptions = mathReaderWith defaultHakyllReaderOptions
>>>
let writerOptions = mathWriterWith defaultHakyllWriterOptions
>>>
let _ = pandocCompilerWith readerOptions writerOptions
Pages which use math should define the include-math
metadata field
to ensure that the resources necessary for rendering math is included.
getTocOptionsWith :: WriterOptions -> Compiler WriterOptions Source #
Rewrite the writer options to include a table of contents
if the source has a toc
field in its metadata.
If there is no such field, the given writer options are returned as is.
For example:
>>>
let _ = getTocOptionsWith defaultHakyllWriterOptions
Custom contexts
siteContext :: Context String Source #
Default context used for the site. Adds customizations specific to this site to "defaultContext". In particular,
- Cleans
index.html
URLs into directory URLs ending with/
.
Use this when compiling items for this site instead of "defaultContext".
Utilities
cleanupIndexUrl :: String -> String Source #
If the given URL is local and ends with index.html
, strip the latter.
For example:
>>>
cleanupIndexUrl "/article/index.html"
"/article/">>>
cleanupIndexUrl "/article/page.html"
"/article/page.html">>>
cleanupIndexUrl "http://chungyc.org/article/index.html"
"http://chungyc.org/article/index.html"
URLs are cleaned up by default with "siteContext", so one will usually not call this directly.