@@ -14,8 +14,8 @@ module Hakyll.Web.Pandoc
14 , pageRenderPandocWith
14 , pageRenderPandocWith
16 -- * Default options
16 -- * Default options
17− , defaultParserState
17+ , defaultHakyllParserState
18− , defaultWriterOptions
18+ , defaultHakyllWriterOptions
21import Prelude hiding (id)
21import Prelude hiding (id)
@@ -23,8 +23,7 @@ import Control.Applicative ((<$>))
23import Control.Arrow ((>>^), (&&&))
23import Control.Arrow ((>>^), (&&&))
24import Control.Category (id)
24import Control.Category (id)
26−import Text.Pandoc (Pandoc)
26+import Text.Pandoc
27−import qualified Text.Pandoc as P
29import Hakyll.Core.Compiler
28import Hakyll.Core.Compiler
30import Hakyll.Web.FileType
29import Hakyll.Web.FileType
@@ -35,20 +34,20 @@ import Hakyll.Web.Page
35readPandoc :: FileType -- ^ File type, determines how parsing happens
34readPandoc :: FileType -- ^ File type, determines how parsing happens
36 -> String -- ^ String to read
35 -> String -- ^ String to read
37 -> Pandoc -- ^ Resulting document
36 -> Pandoc -- ^ Resulting document
38−readPandoc = readPandocWith defaultParserState
37+readPandoc = readPandocWith defaultHakyllParserState
40-- | Read a string using pandoc, with the supplied options
39-- | Read a string using pandoc, with the supplied options
42−readPandocWith :: P.ParserState -- ^ Parser options
41+readPandocWith :: ParserState -- ^ Parser options
43− -> FileType -- ^ File type, determines how parsing happens
42+ -> FileType -- ^ File type, determines how parsing happens
44− -> String -- ^ String to read
43+ -> String -- ^ String to read
45− -> Pandoc -- ^ Resulting document
44+ -> Pandoc -- ^ Resulting document
46readPandocWith state fileType' = case fileType' of
45readPandocWith state fileType' = case fileType' of
47− Html -> P.readHtml state
46+ Html -> readHtml state
48− LaTeX -> P.readLaTeX state
47+ LaTeX -> readLaTeX state
49− LiterateHaskell t -> readPandocWith state {P.stateLiterateHaskell = True} t
48+ LiterateHaskell t -> readPandocWith state {stateLiterateHaskell = True} t
50− Markdown -> P.readMarkdown state
49+ Markdown -> readMarkdown state
51− Rst -> P.readRST state
50+ Rst -> readRST state
52 t -> error $
51 t -> error $
53 "Hakyll.Web.readPandocWith: I don't know how to read " ++ show t
52 "Hakyll.Web.readPandocWith: I don't know how to read " ++ show t
@@ -56,23 +55,23 @@ readPandocWith state fileType' = case fileType' of
57writePandoc :: Pandoc -- ^ Document to write
56writePandoc :: Pandoc -- ^ Document to write
58 -> String -- ^ Resulting HTML
57 -> String -- ^ Resulting HTML
59−writePandoc = writePandocWith defaultWriterOptions
58+writePandoc = writePandocWith defaultHakyllWriterOptions
61-- | Write a document (as HTML) using pandoc, with the supplied options
60-- | Write a document (as HTML) using pandoc, with the supplied options
63−writePandocWith :: P.WriterOptions -- ^ Writer options for pandoc
62+writePandocWith :: WriterOptions -- ^ Writer options for pandoc
64− -> Pandoc -- ^ Document to write
63+ -> Pandoc -- ^ Document to write
65− -> String -- ^ Resulting HTML
64+ -> String -- ^ Resulting HTML
66−writePandocWith = P.writeHtmlString
65+writePandocWith = writeHtmlString
68-- | Read the resource using pandoc
67-- | Read the resource using pandoc
70pageReadPandoc :: Compiler (Page String) (Page Pandoc)
69pageReadPandoc :: Compiler (Page String) (Page Pandoc)
71−pageReadPandoc = pageReadPandocWith defaultParserState
70+pageReadPandoc = pageReadPandocWith defaultHakyllParserState
73-- | Read the resource using pandoc
72-- | Read the resource using pandoc
75−pageReadPandocWith :: P.ParserState -> Compiler (Page String) (Page Pandoc)
74+pageReadPandocWith :: ParserState -> Compiler (Page String) (Page Pandoc)
76pageReadPandocWith state =
75pageReadPandocWith state =
77 id &&& getFileType >>^ pageReadPandocWith'
76 id &&& getFileType >>^ pageReadPandocWith'
@@ -81,30 +80,31 @@ pageReadPandocWith state =
81-- | Render the resource using pandoc
80-- | Render the resource using pandoc
83pageRenderPandoc :: Compiler (Page String) (Page String)
82pageRenderPandoc :: Compiler (Page String) (Page String)
84−pageRenderPandoc = pageRenderPandocWith defaultParserState defaultWriterOptions
83+pageRenderPandoc =
84+ pageRenderPandocWith defaultHakyllParserState defaultHakyllWriterOptions
86-- | Render the resource using pandoc
86-- | Render the resource using pandoc
88−pageRenderPandocWith :: P.ParserState
88+pageRenderPandocWith :: ParserState
89− -> P.WriterOptions
89+ -> WriterOptions
90 -> Compiler (Page String) (Page String)
90 -> Compiler (Page String) (Page String)
91pageRenderPandocWith state options =
91pageRenderPandocWith state options =
92 pageReadPandocWith state >>^ fmap (writePandocWith options)
92 pageReadPandocWith state >>^ fmap (writePandocWith options)
94-- | The default reader options for pandoc parsing in hakyll
94-- | The default reader options for pandoc parsing in hakyll
96−defaultParserState :: P.ParserState
96+defaultHakyllParserState :: ParserState
97−defaultParserState = P.defaultParserState
97+defaultHakyllParserState = defaultParserState
98 { -- The following option causes pandoc to read smart typography, a nice
98 { -- The following option causes pandoc to read smart typography, a nice
99 -- and free bonus.
99 -- and free bonus.
100− P.stateSmart = True
100+ stateSmart = True
103-- | The default writer options for pandoc rendering in hakyll
103-- | The default writer options for pandoc rendering in hakyll
105−defaultWriterOptions :: P.WriterOptions
105+defaultHakyllWriterOptions :: WriterOptions
106−defaultWriterOptions = P.defaultWriterOptions
106+defaultHakyllWriterOptions = defaultWriterOptions
107 { -- This option causes literate haskell to be written using '>' marks in
107 { -- This option causes literate haskell to be written using '>' marks in
108 -- html, which I think is a good default.
108 -- html, which I think is a good default.
109− P.writerLiterateHaskell = True
109+ writerLiterateHaskell = True