Posted on 12 April 2023
Tags:

I have the power of equations!

we use the code from these two posts to enable mathjax and syntax highlighting with hakyll (errors, omissions, and indentation butchery below are my own, I am not (yet?) a professional haskell programmer)


syntaxHighlightingStyle :: Style
syntaxHighlightingStyle = haddock

mathExtensions = 
  [ Ext_tex_math_dollars
  , Ext_tex_math_double_backslash
  , Ext_latex_macros
  ]
codeExtensions = 
  [ Ext_fenced_code_blocks
  , Ext_backtick_code_blocks
  , Ext_fenced_code_attributes
  ]

defaultExtensions = writerExtensions defaultHakyllWriterOptions
newExtensions = foldr enableExtension defaultExtensions (mathExtensions <> codeExtensions)

pandocWriterSoupedUpOptions = defaultHakyllWriterOptions {
                            writerHTMLMathMethod = MathJax "", 
                            writerExtensions = newExtensions, 
                            writerH
-- [...]           
  create ["css/syntax.css"] $ do
    route idRoute
    compile $ do
      makeItem $ styleToCss syntaxHighlightingStyle

and without further ado, we have

the equations! #

\[\begin{eqnarray} x+1 = 2 \\ y+2 = 3 \end{eqnarray}\]

matrices! #

\[\begin{bmatrix} 1 & 2 & 3\\ a & b & c \end{bmatrix}\]

and even extremely fancy matrices! #

the code for this was inspired from this stackexchange post:

\[\begin{align*} & \begin{bmatrix} m_{0} & m_{1} & m_{2} & m_{3} \\ m_{4} & m_{5} & m_{6} & m_{7} \\ m_{8} & m_{9} & m_{10} & m_{11} \\ m_{12} & m_{13} & m_{14} & m_{15} \end{bmatrix} \\ \begin{bmatrix} v_{0} & v_{1} & v_{2} & v_{3} \end{bmatrix} & \mspace{5mu} \bigl[\begin{matrix} {r_{0}} & \mspace{15mu} {r_{1}} & \mspace{15mu} {r_{2}} & \mspace{15mu} {r_{3}} \end{matrix} \mspace{15mu} \bigr] \end{align*}\]