diff --git a/Bookshelf.cabal b/Bookshelf.cabal
--- a/Bookshelf.cabal
+++ b/Bookshelf.cabal
@@ -1,26 +1,32 @@
 name:           Bookshelf
-version:        0.1.5
+version:        0.1.6
 synopsis:       A simple document organizer with some wiki functionality
 description:    A simple document organizer with some wiki functionality
 category:       Text
 license:        GPL
 license-file:   LICENSE
+stability:      experimental
+copyright:      Copyright (c) 2009-2012 Emil Axelsson
 author:         Emil Axelsson <emax@chalmers.se>
 maintainer:     Emil Axelsson <emax@chalmers.se>
-homepage:       http://www.cs.chalmers.se/~emax/bookshelf/Manual.shelf.html
-build-depends:  base < 5, filepath, directory, utf8-string, parseargs, pandoc == 1.3
+homepage:       http://www.cse.chalmers.se/~emax/bookshelf/Manual.shelf.html
 build-type:     Simple
+cabal-version:  >= 1.6
+tested-with:    GHC==7.4.2
 
 data-files:
   bookshelf.css
-  Documentation/Manual.shelf
-  Documentation/Credits.shelf
-  Documentation/Test/Document1.txt
-  Documentation/Test/Document2.txt
-  Documentation/Test/Document2.shelf
-  Documentation/Test/Notes.shelf
-  Documentation/Test/Symbols.shelf
+  Documentation/*.shelf
+  Documentation/Test/*.txt
+  Documentation/Test/*.shelf
 
-extra-source-files: Types.hs, Generate.hs, Directory.hs
-executable:         bookshelf
-main-is:            Bookshelf.hs
+extra-source-files: Types.hs, Generate.hs
+
+source-repository head
+  type:      darcs
+  location:  http://projects.haskell.org/Bookshelf/
+
+executable bookshelf
+  build-depends:  base < 5, filepath, directory, parseargs, pandoc >= 1.8, pandoc-types >= 1.8
+  main-is:        Bookshelf.hs
+
diff --git a/Bookshelf.hs b/Bookshelf.hs
--- a/Bookshelf.hs
+++ b/Bookshelf.hs
@@ -1,4 +1,4 @@
--- Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
+-- Copyright (C) 2009-2012 Emil Axelsson <emax@chalmers.se>
 --
 -- This program is free software; you can redistribute it and/or modify
 -- it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 -- |
--- Copyright  : Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
+-- Copyright  : Copyright (C) 2009-2012 Emil Axelsson <emax@chalmers.se>
 -- License    : GNU GPL, version 2 or above
 --
 -- Maintainer : Emil Axelsson <emax@chalmers.se>
@@ -26,15 +26,16 @@
 
 import Control.Monad
 import Data.List
+import System.Directory
 import System.Environment
 import System.FilePath
-import qualified System.IO.UTF8 as UTF8
 
 import System.Console.ParseArgs
 
+import Text.Pandoc
+
 import Types
 import Generate
-import Directory
 
 
 
@@ -44,6 +45,7 @@
 moveDown context dir = context
     { relPath_ = relPath context </> dir
     , cssLink_ = liftM (".." </>) $ cssLink context
+    , mathjaxLink_ = liftM (".." </>) $ mathjaxLink context
     }
 
 
@@ -123,9 +125,9 @@
 convertShelfDoc :: ShelfInfo -> IO MetaInfo
 convertShelfDoc shelfInfo = do
     let name = shelfDocument shelfInfo
-    markdown <- UTF8.readFile name
+    markdown <- readFile name
     let (html,links,meta) = markdownToHtml shelfInfo markdown
-    UTF8.writeFile (name ++ ".html") html
+    writeFile (name ++ ".html") html
     forM_ links $ \link -> do
       existsFile <- doesFileExist link
       existsDir  <- doesDirectoryExist link
@@ -150,7 +152,7 @@
     setCurrentDirectory path
     shelfMetas <- mapM (convertShelfDoc . shelfInfoS) shelfs
     infoMetas  <- mapM (convertShelfDoc . shelfInfoI) infos
-    UTF8.writeFile "index.html" $ makeIndex
+    writeFile "index.html" $ makeIndex
       context
       (zip shelfs shelfMetas)
       (zip infos  infoMetas)
@@ -182,6 +184,13 @@
           , argDesc  = "Command used for editing source files"
           }
 
+    , Arg { argIndex = "MathJax"
+          , argName  = Just "mathjax"
+          , argAbbr  = Just 'm'
+          , argData  = argDataOptional "MathJax.js file" ArgtypeString
+          , argDesc  = "Path or URL to MathJax.js file"
+          }
+
     , Arg { argIndex = "NoScript"
           , argName  = Just "no-script"
           , argAbbr  = Just 'n'
@@ -201,17 +210,23 @@
 
 main :: IO ()
 main = do
-    pwd  <- getCurrentDirectory
-    args <- parseArgsIO ArgsComplete argSpec
+    pwd   <- getCurrentDirectory
+    args  <- parseArgsIO ArgsComplete argSpec
+    tmpl  <- getDefaultTemplate Nothing "html"
+    tmpl' <- case tmpl of
+        Left msg   -> error $ show msg
+        Right tmpl -> return tmpl
 
     let Just path    = getArg args "Source"
         css          = getArg args "CSS"
+        mathjax      = getArg args "MathJax"
         edit         = getArg args "Editor"
         script       = not $ gotArg args "NoScript"
         path'        = pwd </> path
         dirs         = splitDirectories path'
         css'         = liftM (".." </>) css
-        mkContext ds = Context css' edit script (joinPath $ init ds) (last ds)
+        mathjax'     = liftM (".." </>) mathjax
+        mkContext ds = Context tmpl' css' mathjax' edit script (joinPath $ init ds) (last ds)
 
     isDir  <- doesDirectoryExist path
     isFile <- doesFileExist path
@@ -230,10 +245,10 @@
   where
     err msg = error ("**Error: " ++ msg)
 
-  -- XXX If the "not a directory" error is removed, it handles single shelf
-  --     files as well. In this case, it treats the parent directory as the
-  --     root, which is not ideal. It also ignores links to main documents, and
-  --     it doesn't regenerate the index (which might then become inconsistent
-  --     if meta information is changed). Don't forget to update the `argSpec`
-  --     text if this feature is reintroduced.
+  -- TODO If the "not a directory" error is removed, it handles single shelf
+  --      files as well. In this case, it treats the parent directory as the
+  --      root, which is not ideal. It also ignores links to main documents, and
+  --      it doesn't regenerate the index (which might then become inconsistent
+  --      if meta information is changed). Don't forget to update the `argSpec`
+  --      text if this feature is reintroduced.
 
diff --git a/Directory.hs b/Directory.hs
deleted file mode 100644
--- a/Directory.hs
+++ /dev/null
@@ -1,50 +0,0 @@
--- Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
---
--- This program is free software; you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation; either version 2 of the License, or
--- (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--- GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License
--- along with this program; if not, write to the Free Software
--- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
--- |
--- Copyright  : Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
--- License    : GNU GPL, version 2 or above
---
--- Maintainer : Emil Axelsson <emax@chalmers.se>
---
--- A UTF8-friendly wrapper around (the needed part of) the @System.Directory@
--- API. @System.Directory@ works with byte-oriented strings, so in order to make
--- something user-presentable from them, they must be decoded.
-
-module Directory where
-
-
-
-import Control.Monad
-import qualified System.Directory as Dir
-
-import Codec.Binary.UTF8.String
-
-
-
-getCurrentDirectory = liftM decodeString Dir.getCurrentDirectory
-
-setCurrentDirectory = Dir.setCurrentDirectory . encodeString
-
-doesFileExist = Dir.doesFileExist . encodeString
-
-doesDirectoryExist = Dir.doesDirectoryExist . encodeString
-
-getDirectoryContents =
-    liftM (map decodeString) . Dir.getDirectoryContents . encodeString
-
-removeFile = Dir.removeFile . encodeString
-
diff --git a/Documentation/Credits.shelf b/Documentation/Credits.shelf
--- a/Documentation/Credits.shelf
+++ b/Documentation/Credits.shelf
@@ -4,4 +4,5 @@
 
   * Thomas Girod
   * Eugene Kirpichov
+  * Maxime Rio
 
diff --git a/Documentation/Manual.shelf b/Documentation/Manual.shelf
--- a/Documentation/Manual.shelf
+++ b/Documentation/Manual.shelf
@@ -1,7 +1,7 @@
 % Bookshelf manual
-% Emil Axelsson
-% May 13, 2009
 
+
+
 Introduction
 ============
 
@@ -24,18 +24,21 @@
 
     bookshelf --css bookshelf.css --editor gedit Shelf
 
-The first parameter tells Bookshelf which style sheet to use for the generated pages. The recommended style sheet for Bookshelf is [`bookshelf.css`](http://www.cs.chalmers.se/~emax/bookshelf.css). The second parameter tells what editor to use when editing the source files. This command will appear in an edit/regenerate script at the end of each generated page.
+The first parameter tells Bookshelf which style sheet to use for the generated pages. The recommended style sheet for Bookshelf is [`bookshelf.css`](http://www.cse.chalmers.se/~emax/bookshelf.css). The second parameter tells what editor to use when editing the source files. This command will appear in an edit/regenerate script at the end of each generated page.
 
 Running Bookshelf without arguments results in the following message which shows the complete usage:
 
     bookshelf [options] <source>
-      [-c,--css <CSS file>]           Path or URL to CSS style sheet
-      [-e,--editor <editor command>]  Command used for editing source files
-      [-n,--no-script]                Do not display the edit/regenerate script
-      <source>                        Root directory of bookshelf to be generated
+      [-c,--css <CSS file>]             Path or URL to CSS style sheet
+      [-e,--editor <editor command>]    Command used for editing source files
+      [-m,--mathjax <MathJax.js file>]  Path or URL to MathJax.js file
+      [-n,--no-script]                  Do not display the edit/regenerate script
+      <source>                          Root directory of bookshelf to be generated
 
-The markdown syntax is described [here](http://daringfireball.net/projects/markdown/syntax), and the extensions supported by [Pandoc](http://johnmacfarlane.net/pandoc/) (the converter used internally by Bookshelf) are described [here](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown-vsstandard-markdown).
+An optional parameter is provided to indicate a link where to find [MathJax](http://www.mathjax.org/) javascript file, to use it for math rendering with Pandoc.
 
+The markdown syntax is described [here](http://daringfireball.net/projects/markdown/syntax), and the extensions supported by [Pandoc](http://johnmacfarlane.net/pandoc/) (the converter used internally by Bookshelf) are described [here](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown).
+
 Operation
 =========
 
@@ -81,22 +84,24 @@
 Demonstration
 =============
 
-The contents in [Documentation](.) has been generated by Bookshelf. In addition to the current manual, it contains a sub-directory [Test](Test/) that demonstrates some of Bookshelf's features. The source of the documentation directory can be found [here](http://www.cs.chalmers.se/~emax/darcs/Bookshelf/Documentation).
+The contents in [Documentation](.) has been generated by Bookshelf. In addition to the current manual, it contains a sub-directory [Test](Test/) with some example files in it. The source of the documentation directory can be found [here](http://projects.haskell.org/Bookshelf/Documentation/).
 
 Installation
 ============
 
-The easiest way to install Bookshelf is using the [Cabal install](http://hackage.haskell.org/trac/hackage/wiki/CabalInstall) tool. Cabal install is available in the [Haskell Platform](http://hackage.haskell.org/platform/).
-
-Bookshelf can be installed directly from [Hackage](http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Bookshelf):
+First, make sure to have the [Haskell Platform](http://hackage.haskell.org/platform/) installed. To install Bookshelf directly from [Hackage](http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Bookshelf), run:
 
     cabal install Bookshelf
 
-Alternatively, it can be downloaded from its [repository](http://www.cs.chalmers.se/~emax/darcs/Bookshelf), and installed by running
+Alternatively, fetch the [repository](http://projects.haskell.org/Bookshelf)
 
+    darcs get http://projects.haskell.org/Bookshelf
+
+and run
+
     cabal install
 
-in the `Bookshelf` directory.
+inside the `Bookshelf` directory.
 
 Credits
 =======
diff --git a/Documentation/Test/Document2.shelf b/Documentation/Test/Document2.shelf
--- a/Documentation/Test/Document2.shelf
+++ b/Documentation/Test/Document2.shelf
@@ -1,11 +1,12 @@
 Meta
 ====
 
-  * Title: An interesting document
+  * Title: Document title
   * Authors:
-      * Adam Helf
-  * Date:
-  * Comment: This is a cool document.
+      * Author1
+      * Author2
+  * Date: 2012
+  * Comment: This is a dummy document.
 
 Notes
 =====
diff --git a/Documentation/Test/Symbols.shelf b/Documentation/Test/Symbols.shelf
deleted file mode 100644
--- a/Documentation/Test/Symbols.shelf
+++ /dev/null
@@ -1,65 +0,0 @@
-% Symbols
-
-Arrows
-======
-
-← ↑ → ↓
-
-↔ ↕
-
-⇐ ⇑ ⇒ ⇓
-
-⇔ ⇕
-
-Mathematical operators
-======================
-
-∀ ∃ ⋀ ⋁ ¬ ≡
-
-⋂ ⋃ ⊂ ⊃ ⊆ ⊇ ∈ ∉
-
-∼ ≈ ≤ ≥
-
-· ∘ ∙ ⊕ ⊖ ⊗ ×
-
-¹ ² ³
-
-√ ∞
-
-Greek letters
-=============
-
-Sound       Symbol
-----------  ---------------------
-alpha       Α α
-beta        Β β
-gamma       Γ γ
-delta       Δ δ
-epsilon     Ε ε
-zeta        Ζ ζ
-eta         Η η
-theta       Θ θ
-iota        Ι ι
-kappa       Κ κ
-lambda      Λ λ
-mu          Μ μ
-nu          Ν ν
-xi          Ξ ξ
-omicron     Ο ο
-pi          Π π
-rho         Ρ ρ
-sigma       Σ σ
-tau         Τ τ
-upsilon     Υ υ
-phi         Φ φ
-chi         Χ χ
-psi         Ψ ψ
-omega       Ω ω
-
-Misc.
-=====
-
-® ©
-
-æ Æ ø Ø
-
diff --git a/Generate.hs b/Generate.hs
--- a/Generate.hs
+++ b/Generate.hs
@@ -1,4 +1,4 @@
--- Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
+-- Copyright (C) 2009-2012 Emil Axelsson <emax@chalmers.se>
 --
 -- This program is free software; you can redistribute it and/or modify
 -- it under the terms of the GNU General Public License as published by
@@ -15,12 +15,12 @@
 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 -- |
--- Copyright  : Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
+-- Copyright  : Copyright (C) 2009-2012 Emil Axelsson <emax@chalmers.se>
 -- License    : GNU GPL, version 2 or above
 --
 -- Maintainer : Emil Axelsson <emax@chalmers.se>
 --
--- Convertion of shelf documents to HTML.
+-- Conversion of shelf documents to HTML.
 
 module Generate where
 
@@ -91,21 +91,15 @@
 pandocStr :: String -> [Inline]
 pandocStr = intersperse Space . map Str . words
 
--- | Adds the given blocks at the beginning of the document.
-prependBlocks :: [Block] -> Pandoc -> Pandoc
-prependBlocks bs' (Pandoc meta bs) = Pandoc meta (bs' ++ bs)
 
 
-
 -- | Displays the relative path, with each directory name linked to its index
 -- file. If the `shelfDocument` field is not empty, a link to the document
 -- source will be added at the end of the relative path.
 makeContextPath :: ShelfInfo -> Block
 makeContextPath shelfInfo = Plain
     [ Emph
-         $ pandocStr "➤ Context:"
-        ++ [Space]
-        ++ concat (reverse [link n dir | (n,dir) <- [0..] `zip` reverse nodes])
+         $ concat (reverse [link n dir | (n,dir) <- [0..] `zip` reverse nodes])
         ++ fileLink
     , LineBreak
     ]
@@ -118,7 +112,7 @@
             (pandocStr dir)
             (index, "Go to directory '" ++ dir ++ "'")
         , Space
-        , HtmlInline "<b>/</b>"
+        , Str "/"
         , Space
         ]
       where
@@ -149,6 +143,7 @@
   where
     css     = cssLink       shelfInfo
     edit    = editor        shelfInfo
+    mathjax = mathjaxLink   shelfInfo
     name    = shelfDocument shelfInfo
     relPth  = relPath       shelfInfo
     rootPth = rootPath      shelfInfo
@@ -165,7 +160,8 @@
 
     opts = filter (not . null) $ map makeOpt
       [ ("--editor", edit)
-      , ("--css",    css)
+      , ("--css", css)
+      , ("--mathjax", mathjax)
       ]
 
     editCmd  = edit' ++ " " ++ show file
@@ -183,22 +179,19 @@
 bookshelfCreds :: String
 bookshelfCreds =
     "<div id=\"footer\">\n\
-    \  Organized by <a href=\"http://www.cs.chalmers.se/~emax/bookshelf/Manual.shelf.html\">Bookshelf</a>\n\
+    \  Organized by <a href=\"http://www.cse.chalmers.se/~emax/bookshelf/Manual.shelf.html\">Bookshelf</a>\n\
     \</div>\n"
 
 
 
 -- | Extracts title block information.
 extractMeta :: Pandoc -> MetaInfo
-extractMeta (Pandoc meta _) = MetaInfo title authors' date' [] []
+extractMeta (Pandoc meta _) = MetaInfo title authors date [] []
   where
     Meta title authors date = meta
 
-    authors' = map pandocStr authors
-    date'    = pandocStr date
 
 
-
 -- | Extracts meta information about the \"main\" document from a shelf
 -- document. The document body will be matched against the following form:
 --
@@ -239,34 +232,38 @@
       return is
 
     field f bs = Fold.concat $ do
-      Str f' : Space : rest <- plain bs
+      Str f' : Str ":" : rest <- plain bs
       guard (f==f')
       return rest
 
     parseList f bs = Fold.concat $ do
-      [Plain [Str f'], BulletList bulls] <- return bs
+      [Plain [Str f', Str ":"], BulletList bulls] <- return bs
       guard (f==f')
       mapM plain bulls
 
-    title    = field "Title:"   bsTit
-    date     = field "Date:"    bsDate
-    comment  = field "Comment:" bsComm
-    authors  = parseList "Authors:"  bsAuth
-    keywords = parseList "Keywords:" bsKeyw
+    title    = field "Title"   bsTit
+    date     = field "Date"    bsDate
+    comment  = field "Comment" bsComm
+    authors  = parseList "Authors"  bsAuth
+    keywords = parseList "Keywords" bsKeyw
 
 
 
--- | Makes an HTML header that links to the supplied CSS (if any).
-makeHeader :: Context -> String
-makeHeader context = case cssLink context of
-  Nothing -> ""
+-- | Give a css option for the template that links to the supplied CSS (if any).
+makeCss :: Context -> [(String, String)]
+makeCss context = case cssLink context of
+  Nothing -> []
   Just css
-    -> "<link rel=\"stylesheet\" href=\""
-    ++ css
-    ++ "\" type=\"text/css\" media=\"all\" />\n"
+    -> [("css", css)]
 
+-- | Give the math option to supply to the html writer
+makeMath :: Context -> HTMLMathMethod
+makeMath context = case mathjaxLink context of
+  Nothing -> PlainMath
+  Just l  -> MathJax l
 
 
+
 -- | @markdownToHtml shelfInfo markdown = (html,links,meta)@:
 --
 -- Converts a shelf document to HTML. The result also contains a list of all
@@ -282,17 +279,17 @@
     links    = queryWith localLink pandoc
     thisMeta = extractMeta pandoc
     mainMeta = parseMainMeta pandoc
-    context  = shelfContext shelfInfo
 
     contextBlocks
-       = [RawHtml "<div class=\"bookshelf-meta\">", makeContextPath shelfInfo]
+      =  [RawBlock "html" "<div class=\"bookshelf-meta\">", makeContextPath shelfInfo]
       ++ makeMainLink shelfInfo
-      ++ [RawHtml "</div>", Para [LineBreak]]
+      ++ [RawBlock "html" "</div>"]
 
+    before = writeHtmlString defaultWriterOptions (Pandoc (Meta [] [] []) contextBlocks)
+
     html
       = writeHtmlString wOpts
-      $ prependBlocks contextBlocks
-      $ processWith redirectLink
+      $ bottomUp redirectLink
       $ pandoc
 
     meta = case mainDocument shelfInfo of
@@ -303,11 +300,21 @@
       { stateSmart = True
       }
 
+    after      = editRegenerate shelfInfo ++ bookshelfCreds
+    cssInclude = makeCss $ shelfContext shelfInfo
+    mathMethod = makeMath $ shelfContext shelfInfo
+
+    wVars =
+      [ ("include-after",  after)
+      , ("include-before", before)
+      ] ++ cssInclude
+
     wOpts = defaultWriterOptions
       { writerStandalone      = True
+      , writerTemplate        = htmlTemplate $ shelfContext shelfInfo
+      , writerVariables       = wVars
       , writerTableOfContents = True
-      , writerHeader          = makeHeader context
-      , writerIncludeAfter    = editRegenerate shelfInfo ++ bookshelfCreds
+      , writerHTMLMathMethod  = mathMethod
       }
 
 
@@ -327,7 +334,7 @@
 -- The link text is taken from the `title` field in @meta@. The other fields of
 -- @meta@ will be put in a bullet list underneath. @file@ is the file name of
 -- document. @view@ is a supplementary name of the document that will appear in
--- the link title. The @info@ argument will inlined directly after the link.
+-- the link title. The @info@ argument will be inlined directly after the link.
 listDocument :: String -> MetaInfo -> String -> [Inline] -> [Block]
 listDocument file meta view info =
     [ Plain $ [Link (title meta) (file, "View '" ++ view ++ "'")] ++ info'
@@ -366,25 +373,37 @@
 
 makeIndex context shelfs infos ords dirs = writeHtmlString wOpts pandoc
   where
+    contextBlocks =
+      [ RawBlock "html" "<div class=\"bookshelf-meta\">"
+      , makeContextPath (ShelfInfo context Nothing "")
+      , RawBlock "html" "</div>"
+      ]
+
+    before = writeHtmlString defaultWriterOptions (Pandoc (Meta [] [] []) contextBlocks)
+
+    after = bookshelfCreds
+
+    wVars =
+      [ ("include-before", before)
+      , ("include-after",  after)
+      ] ++ makeCss context
+
     wOpts = defaultWriterOptions
       { writerStandalone      = True
+      , writerTemplate        = htmlTemplate context
+      , writerVariables       = wVars
       , writerTableOfContents = False
-      , writerHeader          = makeHeader context
-      , writerIncludeAfter    = bookshelfCreds
+      , writerHTMLMathMethod  = makeMath context
       }
 
-    pandoc  = Pandoc meta
-         $ [makeContextPath (ShelfInfo context Nothing "")]
-        ++ docBlocks
-        ++ dirBlocks
-
+    pandoc = Pandoc meta (docBlocks ++ dirBlocks)
       where
         dir  = last $ splitDirectories $ relPath context
         meta = Meta (pandocStr dir) [] []
 
     docBlocks = do
       guard (0 < length shelfs + length infos + length ords)
-      [ Header 1 [Str "Documents"]
+      [ Header 2 [Str "Documents"]
        , BulletList shelfBlocks
        , BulletList infoBlocks
        , BulletList ordBlocks
@@ -396,7 +415,7 @@
 
     dirBlocks = do
       guard (not $ null dirs)
-      [Header 1 [Str "Directories"]] ++ [BulletList $ map listDir $ sort dirs]
+      [Header 2 [Str "Directories"]] ++ [BulletList $ map listDir $ sort dirs]
 
     listShelfDoc (doc,meta) = listDocument docShelfHtml meta' doc' []
       where
diff --git a/Types.hs b/Types.hs
--- a/Types.hs
+++ b/Types.hs
@@ -1,4 +1,4 @@
--- Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
+-- Copyright (C) 2009-2012 Emil Axelsson <emax@chalmers.se>
 --
 -- This program is free software; you can redistribute it and/or modify
 -- it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 -- |
--- Copyright  : Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
+-- Copyright  : Copyright (C) 2009-2012 Emil Axelsson <emax@chalmers.se>
 -- License    : GNU GPL, version 2 or above
 --
 -- Maintainer : Emil Axelsson <emax@chalmers.se>
@@ -38,16 +38,20 @@
      deriving (Eq, Show)
 
 data Context = Context
-       { -- | Optional link to CSS file
-         cssLink_    :: Maybe FilePath
+       { -- | Pandoc HTML template
+         htmlTemplate :: String
+         -- | Optional link to CSS file
+       , cssLink_     :: Maybe FilePath
+         -- [ Optional link to MathJax.js file
+       , mathjaxLink_ :: Maybe FilePath
          -- | Optional editor command
-       , editor_     :: Maybe String
+       , editor_      :: Maybe String
          -- | Show the edit/regenerate script?
-       , showScript_ :: Bool
+       , showScript_  :: Bool
          -- | Path to root of bookshelf
-       , rootPath_   :: FilePath
+       , rootPath_    :: FilePath
          -- | Path to current node, relative to the root
-       , relPath_    :: FilePath
+       , relPath_     :: FilePath
        }
      deriving (Eq, Show)
 
@@ -63,25 +67,28 @@
 
 class HasContext a
   where
-    cssLink    :: a -> Maybe FilePath
-    editor     :: a -> Maybe String
-    showScript :: a -> Bool
-    rootPath   :: a -> FilePath
-    relPath    :: a -> FilePath
+    cssLink     :: a -> Maybe FilePath
+    mathjaxLink :: a -> Maybe FilePath
+    editor      :: a -> Maybe String
+    showScript  :: a -> Bool
+    rootPath    :: a -> FilePath
+    relPath     :: a -> FilePath
 
 instance HasContext Context
   where
-    cssLink    = cssLink_
-    editor     = editor_
-    showScript = showScript_
-    rootPath   = rootPath_
-    relPath    = relPath_
+    cssLink     = cssLink_
+    mathjaxLink = mathjaxLink_
+    editor      = editor_
+    showScript  = showScript_
+    rootPath    = rootPath_
+    relPath     = relPath_
 
 instance HasContext ShelfInfo
   where
-    cssLink    = cssLink_    . shelfContext
-    editor     = editor_     . shelfContext
-    showScript = showScript_ . shelfContext
-    rootPath   = rootPath_   . shelfContext
-    relPath    = relPath_    . shelfContext
+    cssLink     = cssLink_     . shelfContext
+    mathjaxLink = mathjaxLink_ . shelfContext
+    editor      = editor_      . shelfContext
+    showScript  = showScript_  . shelfContext
+    rootPath    = rootPath_    . shelfContext
+    relPath     = relPath_     . shelfContext
 
diff --git a/bookshelf.css b/bookshelf.css
--- a/bookshelf.css
+++ b/bookshelf.css
@@ -1,16 +1,22 @@
-/* Based on pandoc.css (http://johnmacfarlane.net/pandoc/) */
+html {
+  background-color: #ACF;
+}
 
 body {
   margin: auto;
+  background-color: #FFF;
+  padding-top: 0px;
+  padding-bottom: 0.5em;
   padding-right: 1em;
   padding-left: 1em;
-  max-width: 50em;
-  border-left: 1px solid black;
-  border-right: 1px solid black;
+  border-right: 2px solid #AAF;
+  border-left: 2px solid #AAF;
+  border-bottom: 1px solid #888;
+  max-width: 56em;
   font-family: verdana, sans-serif;
   font-size: 85%;
   line-height: 140%;
-  color: #333;
+  color: #222;
 }
 
 pre {
@@ -25,27 +31,33 @@
   font-size: 115%;
 }
 
-h1 a, h2 a, h3 a, h4 a, h5 a {
-  text-decoration: none;
-  color: #7a5ada;
-}
-
-h1, h2, h3, h4, h5 {
+h1 a {
   font-family: verdana, sans-serif;
   font-weight: bold;
-  color: #7a5ada;
+  color: #FFF;
 }
 
+h2 a, h3 a, h4 a, h5 a {
+  text-decoration: none;
+  color: #26C;
+}
+
 h2, h3, h4, h5 {
+  font-family: verdana, sans-serif;
+  font-weight: bold;
+  color: #26C;
   border-bottom: 1px dotted #BBB;
 }
 
 h1 {
+  font-family: verdana, sans-serif;
+  font-weight: bold;
+  color: #FFF;
   font-size: 130%;
-  border: 1px solid #ddd;
-  border-bottom: 2px solid #AAA;
-  border-right: 2px solid #AAA;
-  background-color: #f4e0ca;
+  border: 1px solid #353;
+  border-bottom: 1px solid #353;
+  border-right: 1px solid #353;
+  background-color: #487;
   margin-top: 1.5em;
   padding: 0.2em;
 }
@@ -72,6 +84,9 @@
 }
 
 h1.title {
+  font-family: verdana, sans-serif;
+  font-weight: bold;
+  color: #26C;
   font-size: 170%;
   font-weight: bold;
   padding-top: 0.2em;
@@ -81,6 +96,17 @@
   background: none;
 }
 
+h2.author {
+  text-align: center;
+  border-bottom: none;
+}
+
+h3.date {
+  text-align: center;
+  border-bottom: none;
+  margin-left: 0px;
+}
+
 dt code {
   font-weight: bold;
 }
@@ -90,10 +116,9 @@
 }
 
 .bookshelf-meta {
-  border: 1px solid #ddd;
-  background-color: #dfc;
+  background-color: #DDD;
   color: #1111111;
-  padding: 0.2em;
+  font-size: 85%;
 }
 
 #footer {
@@ -105,7 +130,7 @@
 
 a {
   text-decoration: none;
-  color: #33f;
+  color: #33F;
 }
 
 a:hover {
