on master help sign in
Avoid name clashes with pandoc
commitf910233e0ff0e276a10a1a8f37cf4c02499ef9ae authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSat 12 Feb 2011, 15:21 (16 years ago) parent645ac84
2 files changed+33−33
examples/hakyll/hakyll.hs+3−3 src/Hakyll/Web/Pandoc.hs+30−30
examples/hakyll/hakyll.hs+3−3
@@ -2,7 +2,7 @@
22import Hakyll
33import Control.Monad (forM_)
44import Control.Arrow ((>>>), arr)
5−import Text.Pandoc (writerTableOfContents, writerTemplate, writerStandalone)
5+import Text.Pandoc
66
77main :: IO ()
88main = hakyll $ do
@@ -25,7 +25,7 @@ main = hakyll $ do
2525 -- Tutorial
2626 route "tutorial.markdown" $ setExtension "html"
2727 compile "tutorial.markdown" $ pageRead
28− >>> pageRenderPandocWith defaultParserState withToc
28+ >>> pageRenderPandocWith defaultHakyllParserState withToc
2929 >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
3030 >>> defaultApplyTemplate "templates/default.html"
3131 >>> defaultRelativizeUrls
@@ -36,7 +36,7 @@ main = hakyll $ do
3636 -- Templates
3737 compile "templates/*" defaultTemplateRead
3838 where
39− withToc = defaultWriterOptions
39+ withToc = defaultHakyllWriterOptions
4040 { writerTableOfContents = True
4141 , writerTemplate = "<h2>Table of contents</h2>\n$toc$\n$body$"
4242 , writerStandalone = True
src/Hakyll/Web/Pandoc.hs+30−30
@@ -14,8 +14,8 @@ module Hakyll.Web.Pandoc
1414 , pageRenderPandocWith
1515
1616 -- * Default options
17− , defaultParserState
18− , defaultWriterOptions
17+ , defaultHakyllParserState
18+ , defaultHakyllWriterOptions
1919 ) where
2020
2121import Prelude hiding (id)
@@ -23,8 +23,7 @@ import Control.Applicative ((<$>))
2323import Control.Arrow ((>>^), (&&&))
2424import Control.Category (id)
2525
26−import Text.Pandoc (Pandoc)
27−import qualified Text.Pandoc as P
26+import Text.Pandoc
2827
2928import Hakyll.Core.Compiler
3029import Hakyll.Web.FileType
@@ -35,20 +34,20 @@ import Hakyll.Web.Page
3534readPandoc :: FileType -- ^ File type, determines how parsing happens
3635 -> String -- ^ String to read
3736 -> Pandoc -- ^ Resulting document
38−readPandoc = readPandocWith defaultParserState
37+readPandoc = readPandocWith defaultHakyllParserState
3938
4039-- | Read a string using pandoc, with the supplied options
4140--
42−readPandocWith :: P.ParserState -- ^ Parser options
43− -> FileType -- ^ File type, determines how parsing happens
44− -> String -- ^ String to read
45− -> Pandoc -- ^ Resulting document
41+readPandocWith :: ParserState -- ^ Parser options
42+ -> FileType -- ^ File type, determines how parsing happens
43+ -> String -- ^ String to read
44+ -> Pandoc -- ^ Resulting document
4645readPandocWith state fileType' = case fileType' of
47− Html -> P.readHtml state
48− LaTeX -> P.readLaTeX state
49− LiterateHaskell t -> readPandocWith state {P.stateLiterateHaskell = True} t
50− Markdown -> P.readMarkdown state
51− Rst -> P.readRST state
46+ Html -> readHtml state
47+ LaTeX -> readLaTeX state
48+ LiterateHaskell t -> readPandocWith state {stateLiterateHaskell = True} t
49+ Markdown -> readMarkdown state
50+ Rst -> readRST state
5251 t -> error $
5352 "Hakyll.Web.readPandocWith: I don't know how to read " ++ show t
5453
@@ -56,23 +55,23 @@ readPandocWith state fileType' = case fileType' of
5655--
5756writePandoc :: Pandoc -- ^ Document to write
5857 -> String -- ^ Resulting HTML
59−writePandoc = writePandocWith defaultWriterOptions
58+writePandoc = writePandocWith defaultHakyllWriterOptions
6059
6160-- | Write a document (as HTML) using pandoc, with the supplied options
6261--
63−writePandocWith :: P.WriterOptions -- ^ Writer options for pandoc
64− -> Pandoc -- ^ Document to write
65− -> String -- ^ Resulting HTML
66−writePandocWith = P.writeHtmlString
62+writePandocWith :: WriterOptions -- ^ Writer options for pandoc
63+ -> Pandoc -- ^ Document to write
64+ -> String -- ^ Resulting HTML
65+writePandocWith = writeHtmlString
6766
6867-- | Read the resource using pandoc
6968--
7069pageReadPandoc :: Compiler (Page String) (Page Pandoc)
71−pageReadPandoc = pageReadPandocWith defaultParserState
70+pageReadPandoc = pageReadPandocWith defaultHakyllParserState
7271
7372-- | Read the resource using pandoc
7473--
75−pageReadPandocWith :: P.ParserState -> Compiler (Page String) (Page Pandoc)
74+pageReadPandocWith :: ParserState -> Compiler (Page String) (Page Pandoc)
7675pageReadPandocWith state =
7776 id &&& getFileType >>^ pageReadPandocWith'
7877 where
@@ -81,30 +80,31 @@ pageReadPandocWith state =
8180-- | Render the resource using pandoc
8281--
8382pageRenderPandoc :: Compiler (Page String) (Page String)
84−pageRenderPandoc = pageRenderPandocWith defaultParserState defaultWriterOptions
83+pageRenderPandoc =
84+ pageRenderPandocWith defaultHakyllParserState defaultHakyllWriterOptions
8585
8686-- | Render the resource using pandoc
8787--
88−pageRenderPandocWith :: P.ParserState
89− -> P.WriterOptions
88+pageRenderPandocWith :: ParserState
89+ -> WriterOptions
9090 -> Compiler (Page String) (Page String)
9191pageRenderPandocWith state options =
9292 pageReadPandocWith state >>^ fmap (writePandocWith options)
9393
9494-- | The default reader options for pandoc parsing in hakyll
9595--
96−defaultParserState :: P.ParserState
97−defaultParserState = P.defaultParserState
96+defaultHakyllParserState :: ParserState
97+defaultHakyllParserState = defaultParserState
9898 { -- The following option causes pandoc to read smart typography, a nice
9999 -- and free bonus.
100− P.stateSmart = True
100+ stateSmart = True
101101 }
102102
103103-- | The default writer options for pandoc rendering in hakyll
104104--
105−defaultWriterOptions :: P.WriterOptions
106−defaultWriterOptions = P.defaultWriterOptions
105+defaultHakyllWriterOptions :: WriterOptions
106+defaultHakyllWriterOptions = defaultWriterOptions
107107 { -- This option causes literate haskell to be written using '>' marks in
108108 -- html, which I think is a good default.
109− P.writerLiterateHaskell = True
109+ writerLiterateHaskell = True
110110 }