@@ -22,34 +22,40 @@ import Prelude hiding (id)
22import Control.Applicative ((<$>))
22import Control.Applicative ((<$>))
23import Control.Arrow ((>>^), (&&&))
23import Control.Arrow ((>>^), (&&&))
24import Control.Category (id)
24import Control.Category (id)
25+import Data.Maybe (fromMaybe)
26import Text.Pandoc
27import Text.Pandoc
28import Hakyll.Core.Compiler
29import Hakyll.Core.Compiler
30+import Hakyll.Core.Identifier
29import Hakyll.Web.Pandoc.FileType
31import Hakyll.Web.Pandoc.FileType
30import Hakyll.Web.Page.Internal
32import Hakyll.Web.Page.Internal
32-- | Read a string using pandoc, with the default options
34-- | Read a string using pandoc, with the default options
34readPandoc :: FileType -- ^ File type, determines how parsing happens
36readPandoc :: FileType -- ^ File type, determines how parsing happens
37+ -> Maybe Identifier -- ^ Optional, for better error messages
35 -> String -- ^ String to read
38 -> String -- ^ String to read
36 -> Pandoc -- ^ Resulting document
39 -> Pandoc -- ^ Resulting document
37readPandoc = readPandocWith defaultHakyllParserState
40readPandoc = readPandocWith defaultHakyllParserState
39-- | Read a string using pandoc, with the supplied options
42-- | Read a string using pandoc, with the supplied options
41−readPandocWith :: ParserState -- ^ Parser options
44+readPandocWith :: ParserState -- ^ Parser options
42− -> FileType -- ^ File type, determines how parsing happens
45+ -> FileType -- ^ File type, determines parsing method
46+ -> Maybe Identifier -- ^ Optional, for better error messages
43− -> String -- ^ String to read
47+ -> String -- ^ String to read
44− -> Pandoc -- ^ Resulting document
48+ -> Pandoc -- ^ Resulting document
45−readPandocWith state fileType' = case fileType' of
49+readPandocWith state fileType' id' = case fileType' of
46 Html -> readHtml state
50 Html -> readHtml state
47 LaTeX -> readLaTeX state
51 LaTeX -> readLaTeX state
48− LiterateHaskell t -> readPandocWith state {stateLiterateHaskell = True} t
53+ readPandocWith state {stateLiterateHaskell = True} t id'
49 Markdown -> readMarkdown state
54 Markdown -> readMarkdown state
50 Rst -> readRST state
55 Rst -> readRST state
51 t -> error $
56 t -> error $
52− "Hakyll.Web.readPandocWith: I don't know how to read " ++ show t
57+ "Hakyll.Web.readPandocWith: I don't know how to read a file of the " ++
58+ "type " ++ show t ++ fromMaybe "" (fmap ((" for: " ++) . show) id')
54-- | Write a document (as HTML) using pandoc, with the default options
60-- | Write a document (as HTML) using pandoc, with the default options
@@ -73,9 +79,9 @@ pageReadPandoc = pageReadPandocWith defaultHakyllParserState
74pageReadPandocWith :: ParserState -> Compiler (Page String) (Page Pandoc)
80pageReadPandocWith :: ParserState -> Compiler (Page String) (Page Pandoc)
75pageReadPandocWith state =
81pageReadPandocWith state =
76− id &&& getFileType >>^ pageReadPandocWith'
82+ id &&& getIdentifier &&& getFileType >>^ pageReadPandocWith'
78− pageReadPandocWith' (p, t) = readPandocWith state t <$> p
84+ pageReadPandocWith' (p, (i, t)) = readPandocWith state t (Just i) <$> p
80-- | Render the resource using pandoc
86-- | Render the resource using pandoc