on master help sign in
Avoid name clashes with pandoc
f910233Jasper Van der Jeugt
examples/hakyll/hakyll.hs+3−3
@@ -2,7 +2,7 @@
2import Hakyll
2import Hakyll
3import Control.Monad (forM_)
3import Control.Monad (forM_)
4import Control.Arrow ((>>>), arr)
4import Control.Arrow ((>>>), arr)
5−import Text.Pandoc (writerTableOfContents, writerTemplate, writerStandalone)
5+import Text.Pandoc
6
6
7main :: IO ()
7main :: IO ()
8main = hakyll $ do
8main = hakyll $ do
@@ -25,7 +25,7 @@ main = hakyll $ do
25 -- Tutorial
25 -- Tutorial
26 route "tutorial.markdown" $ setExtension "html"
26 route "tutorial.markdown" $ setExtension "html"
27 compile "tutorial.markdown" $ pageRead
27 compile "tutorial.markdown" $ pageRead
28− >>> pageRenderPandocWith defaultParserState withToc
28+ >>> pageRenderPandocWith defaultHakyllParserState withToc
29 >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
29 >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
30 >>> defaultApplyTemplate "templates/default.html"
30 >>> defaultApplyTemplate "templates/default.html"
31 >>> defaultRelativizeUrls
31 >>> defaultRelativizeUrls
@@ -36,7 +36,7 @@ main = hakyll $ do
36 -- Templates
36 -- Templates
37 compile "templates/*" defaultTemplateRead
37 compile "templates/*" defaultTemplateRead
38 where
38 where
39− withToc = defaultWriterOptions
39+ withToc = defaultHakyllWriterOptions
40 { writerTableOfContents = True
40 { writerTableOfContents = True
41 , writerTemplate = "<h2>Table of contents</h2>\n$toc$\n$body$"
41 , writerTemplate = "<h2>Table of contents</h2>\n$toc$\n$body$"
42 , writerStandalone = True
42 , writerStandalone = True
src/Hakyll/Web/Pandoc.hs+30−30
@@ -14,8 +14,8 @@ module Hakyll.Web.Pandoc
14 , pageRenderPandocWith
14 , pageRenderPandocWith
15
15
16 -- * Default options
16 -- * Default options
17− , defaultParserState
17+ , defaultHakyllParserState
18− , defaultWriterOptions
18+ , defaultHakyllWriterOptions
19 ) where
19 ) where
20
20
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)
25
25
26−import Text.Pandoc (Pandoc)
26+import Text.Pandoc
27−import qualified Text.Pandoc as P
28
27
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
39
38
40-- | Read a string using pandoc, with the supplied options
39-- | Read a string using pandoc, with the supplied options
41--
40--
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
54
53
@@ -56,23 +55,23 @@ readPandocWith state fileType' = case fileType' of
56--
55--
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
60
59
61-- | Write a document (as HTML) using pandoc, with the supplied options
60-- | Write a document (as HTML) using pandoc, with the supplied options
62--
61--
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
67
66
68-- | Read the resource using pandoc
67-- | Read the resource using pandoc
69--
68--
70pageReadPandoc :: Compiler (Page String) (Page Pandoc)
69pageReadPandoc :: Compiler (Page String) (Page Pandoc)
71−pageReadPandoc = pageReadPandocWith defaultParserState
70+pageReadPandoc = pageReadPandocWith defaultHakyllParserState
72
71
73-- | Read the resource using pandoc
72-- | Read the resource using pandoc
74--
73--
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'
78 where
77 where
@@ -81,30 +80,31 @@ pageReadPandocWith state =
81-- | Render the resource using pandoc
80-- | Render the resource using pandoc
82--
81--
83pageRenderPandoc :: Compiler (Page String) (Page String)
82pageRenderPandoc :: Compiler (Page String) (Page String)
84−pageRenderPandoc = pageRenderPandocWith defaultParserState defaultWriterOptions
83+pageRenderPandoc =
84+ pageRenderPandocWith defaultHakyllParserState defaultHakyllWriterOptions
85
85
86-- | Render the resource using pandoc
86-- | Render the resource using pandoc
87--
87--
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)
93
93
94-- | The default reader options for pandoc parsing in hakyll
94-- | The default reader options for pandoc parsing in hakyll
95--
95--
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
101 }
101 }
102
102
103-- | The default writer options for pandoc rendering in hakyll
103-- | The default writer options for pandoc rendering in hakyll
104--
104--
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
110 }
110 }