summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-05-17 10:46:48 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-05-17 10:46:48 +0200
commit6e207e4793215c14d6dd429b88551173ca948abe (patch)
tree9639713d964cff4a02deb08df3c465c15528dc88 /src
parent01fdbd507817e43cb61796d384fda7434cf4799e (diff)
downloadhakyll-6e207e4793215c14d6dd429b88551173ca948abe.tar.gz
Some better error messages
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Web/Pandoc.hs24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/Hakyll/Web/Pandoc.hs b/src/Hakyll/Web/Pandoc.hs
index 7fc15a0..d107702 100644
--- a/src/Hakyll/Web/Pandoc.hs
+++ b/src/Hakyll/Web/Pandoc.hs
@@ -22,34 +22,40 @@ import Prelude hiding (id)
import Control.Applicative ((<$>))
import Control.Arrow ((>>^), (&&&))
import Control.Category (id)
+import Data.Maybe (fromMaybe)
import Text.Pandoc
import Hakyll.Core.Compiler
+import Hakyll.Core.Identifier
import Hakyll.Web.Pandoc.FileType
import Hakyll.Web.Page.Internal
-- | Read a string using pandoc, with the default options
--
readPandoc :: FileType -- ^ File type, determines how parsing happens
+ -> Maybe Identifier -- ^ Optional, for better error messages
-> String -- ^ String to read
-> Pandoc -- ^ Resulting document
readPandoc = readPandocWith defaultHakyllParserState
-- | Read a string using pandoc, with the supplied options
--
-readPandocWith :: ParserState -- ^ Parser options
- -> FileType -- ^ File type, determines how parsing happens
- -> String -- ^ String to read
- -> Pandoc -- ^ Resulting document
-readPandocWith state fileType' = case fileType' of
+readPandocWith :: ParserState -- ^ Parser options
+ -> FileType -- ^ File type, determines parsing method
+ -> Maybe Identifier -- ^ Optional, for better error messages
+ -> String -- ^ String to read
+ -> Pandoc -- ^ Resulting document
+readPandocWith state fileType' id' = case fileType' of
Html -> readHtml state
LaTeX -> readLaTeX state
- LiterateHaskell t -> readPandocWith state {stateLiterateHaskell = True} t
+ LiterateHaskell t ->
+ readPandocWith state {stateLiterateHaskell = True} t id'
Markdown -> readMarkdown state
Rst -> readRST state
t -> error $
- "Hakyll.Web.readPandocWith: I don't know how to read " ++ show t
+ "Hakyll.Web.readPandocWith: I don't know how to read a file of the " ++
+ "type " ++ show t ++ fromMaybe "" (fmap ((" for: " ++) . show) id')
-- | Write a document (as HTML) using pandoc, with the default options
--
@@ -73,9 +79,9 @@ pageReadPandoc = pageReadPandocWith defaultHakyllParserState
--
pageReadPandocWith :: ParserState -> Compiler (Page String) (Page Pandoc)
pageReadPandocWith state =
- id &&& getFileType >>^ pageReadPandocWith'
+ id &&& getIdentifier &&& getFileType >>^ pageReadPandocWith'
where
- pageReadPandocWith' (p, t) = readPandocWith state t <$> p
+ pageReadPandocWith' (p, (i, t)) = readPandocWith state t (Just i) <$> p
-- | Render the resource using pandoc
--