From f70e1b7fd22c8dc1d98908b88e5ed719e630ae86 Mon Sep 17 00:00:00 2001 From: Justin Hsu Date: Wed, 20 Sep 2017 15:20:50 +0100 Subject: [PATCH] Update to new version of Hakyll. Whew. I need to refactor this. --- HakyllBibTex.hs | 10 +++++++--- site.hs | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/HakyllBibTex.hs b/HakyllBibTex.hs index 1f9b672..8566b48 100644 --- a/HakyllBibTex.hs +++ b/HakyllBibTex.hs @@ -18,6 +18,7 @@ import Data.Binary (Binary (..)) import Data.Char (isSpace) import Data.List.Split (splitOn) import Data.List (intercalate) +import Data.Map (empty) import Data.Typeable (Typeable) import Hakyll import qualified Bibtex as B @@ -38,13 +39,14 @@ instance Binary BibEntry where get = BibEntry <$> (B.Item <$> get <*> get <*> get) -------------------------------------------------------------------------------- +-- XXX refactor to use Context monoid XXX bibEntryContext :: Context BibEntry bibEntryContext = Context $ \key _ item -> let BibEntry t = itemBody item in case key of "identifier" -> return $ StringField $ B.identifier t _ -> case lookup key (B.fields t) of - Nothing -> empty + Nothing -> Control.Applicative.empty Just val -> case key of "author" -> return $ StringField $ formatAuthors val "month" -> return $ StringField $ expandMonth val @@ -62,6 +64,7 @@ bibFileEntryNames (BibFile es) = [B.identifier t | BibEntry t <- es] -------------------------------------------------------------------------------- +-- XXX refactor to use Text.CSL.readBiblioFile XXX parseBibFile :: String -> BibFile parseBibFile string = case Parsec.runParser (B.bibEntries <* Parsec.eof) [] "" string of @@ -124,7 +127,8 @@ trimSpace = f . f -------------------------------------------------------------------------------- latexToHtml tex = let p = case Pandoc.readLaTeX Pandoc.def tex of - Pandoc.Pandoc meta [Pandoc.Para para] -> + Right (Pandoc.Pandoc meta [Pandoc.Para para]) -> Pandoc.Pandoc meta [Pandoc.Plain para] - x -> x + Left _ -> + Pandoc.Pandoc (Pandoc.Meta Data.Map.empty) [] in Pandoc.writeHtmlString Pandoc.def p diff --git a/site.hs b/site.hs index 8ef9f2e..7a001f8 100644 --- a/site.hs +++ b/site.hs @@ -6,7 +6,6 @@ import Hakyll import HakyllBibTex import System.Process import Text.Pandoc.Options -import Text.Regex config :: Configuration config = defaultConfiguration