diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-27 11:14:04 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-27 11:14:04 +0100 |
commit | bda268273b6cc18d8d1d9fb3170f92a06f6f45b8 (patch) | |
tree | 2b0c83eec9d5efc300cc67afd09af39cf15e1fcd /src | |
parent | d25dcb698e37765f35edf4c6e9b38e1d9dbb578e (diff) | |
download | hakyll-bda268273b6cc18d8d1d9fb3170f92a06f6f45b8.tar.gz |
Make pandoc functions work on pages by default
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Web/Page/Read.hs | 2 | ||||
-rw-r--r-- | src/Hakyll/Web/Pandoc.hs | 46 |
2 files changed, 29 insertions, 19 deletions
diff --git a/src/Hakyll/Web/Page/Read.hs b/src/Hakyll/Web/Page/Read.hs index c886fab..82224a4 100644 --- a/src/Hakyll/Web/Page/Read.hs +++ b/src/Hakyll/Web/Page/Read.hs @@ -6,7 +6,7 @@ module Hakyll.Web.Page.Read import Control.Applicative ((<$>), (<*>)) import Control.Arrow (second, (***)) -import Control.Monad.State +import Control.Monad.State (State, get, put, evalState) import Data.List (isPrefixOf) import Data.Map (Map) import qualified Data.Map as M diff --git a/src/Hakyll/Web/Pandoc.hs b/src/Hakyll/Web/Pandoc.hs index 52572a7..57fd1ac 100644 --- a/src/Hakyll/Web/Pandoc.hs +++ b/src/Hakyll/Web/Pandoc.hs @@ -1,25 +1,31 @@ -- | Module exporting pandoc bindings -- module Hakyll.Web.Pandoc - ( readPandoc + ( -- * The basic building blocks + readPandoc , readPandocWith , writePandoc , writePandocWith - , targetReadPandoc - , targetReadPandocWith - , targetRenderPandoc - , targetRenderPandocWith + + -- * Functions working on pages/targets + , pageReadPandoc + , pageReadPandocWith + , pageRenderPandoc + , pageRenderPandocWith + + -- * Default options , defaultParserState , defaultWriterOptions ) where -import Control.Applicative ((<$>), (<*>)) +import Control.Applicative ((<$>)) import Text.Pandoc (Pandoc) import qualified Text.Pandoc as P -import Hakyll.Web.FileType import Hakyll.Core.Target +import Hakyll.Web.FileType +import Hakyll.Web.Page -- | Read a string using pandoc, with the default options -- @@ -58,26 +64,30 @@ writePandocWith = P.writeHtmlString -- | Read the resource using pandoc -- -targetReadPandoc :: TargetM a Pandoc -targetReadPandoc = targetReadPandocWith defaultParserState +pageReadPandoc :: Page String -> TargetM a (Page Pandoc) +pageReadPandoc = pageReadPandocWith defaultParserState -- | Read the resource using pandoc -- -targetReadPandocWith :: P.ParserState -> TargetM a Pandoc -targetReadPandocWith state = - readPandocWith state <$> getFileType <*> getResourceString +pageReadPandocWith :: P.ParserState -> Page String -> TargetM a (Page Pandoc) +pageReadPandocWith state page = do + fileType' <- getFileType + return $ readPandocWith state fileType' <$> page -- | Render the resource using pandoc -- -targetRenderPandoc :: TargetM a String -targetRenderPandoc = - targetRenderPandocWith defaultParserState defaultWriterOptions +pageRenderPandoc :: Page String -> TargetM a (Page String) +pageRenderPandoc = pageRenderPandocWith defaultParserState defaultWriterOptions -- | Render the resource using pandoc -- -targetRenderPandocWith :: P.ParserState -> P.WriterOptions -> TargetM a String -targetRenderPandocWith state options = - writePandocWith options <$> targetReadPandocWith state +pageRenderPandocWith :: P.ParserState + -> P.WriterOptions + -> Page String + -> TargetM a (Page String) +pageRenderPandocWith state options page = do + pandoc <- pageReadPandocWith state page + return $ writePandocWith options <$> pandoc -- | The default reader options for pandoc parsing in hakyll -- |