hakyll 4.0.0.0 → 4.1.0.0
raw patch · 3 files changed
+51/−44 lines, 3 filesdep ~pandocPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: pandoc
API changes (from Hackage documentation)
- Hakyll.Web.Pandoc: defaultHakyllParserState :: ParserState
+ Hakyll.Web.Pandoc: defaultHakyllReaderOptions :: ReaderOptions
- Hakyll.Web.Pandoc: pandocCompilerWith :: ParserState -> WriterOptions -> Compiler (Item String)
+ Hakyll.Web.Pandoc: pandocCompilerWith :: ReaderOptions -> WriterOptions -> Compiler (Item String)
- Hakyll.Web.Pandoc: pandocCompilerWithTransform :: ParserState -> WriterOptions -> (Pandoc -> Pandoc) -> Compiler (Item String)
+ Hakyll.Web.Pandoc: pandocCompilerWithTransform :: ReaderOptions -> WriterOptions -> (Pandoc -> Pandoc) -> Compiler (Item String)
- Hakyll.Web.Pandoc: readPandocWith :: ParserState -> Item String -> Item Pandoc
+ Hakyll.Web.Pandoc: readPandocWith :: ReaderOptions -> Item String -> Item Pandoc
- Hakyll.Web.Pandoc: renderPandocWith :: ParserState -> WriterOptions -> Item String -> Item String
+ Hakyll.Web.Pandoc: renderPandocWith :: ReaderOptions -> WriterOptions -> Item String -> Item String
- Hakyll.Web.Pandoc.Biblio: readPandocBiblio :: ParserState -> Item CSL -> Item Biblio -> (Item String) -> Compiler (Item Pandoc)
+ Hakyll.Web.Pandoc.Biblio: readPandocBiblio :: ReaderOptions -> Maybe (Item CSL) -> Item Biblio -> (Item String) -> Compiler (Item Pandoc)
Files
- hakyll.cabal +3/−3
- src/Hakyll/Web/Pandoc.hs +33/−30
- src/Hakyll/Web/Pandoc/Biblio.hs +15/−11
hakyll.cabal view
@@ -1,5 +1,5 @@ Name: hakyll-Version: 4.0.0.0+Version: 4.1.0.0 Synopsis: A static website compiler library Description:@@ -99,7 +99,7 @@ old-locale >= 1.0 && < 1.1, old-time >= 1.0 && < 1.2, cmdargs >= 0.10 && < 0.11,- pandoc >= 1.9.3 && < 1.10,+ pandoc >= 1.10 && < 1.11, parsec >= 3.0 && < 3.2, process >= 1.0 && < 1.2, random >= 1.0 && < 1.1,@@ -198,7 +198,7 @@ old-locale >= 1.0 && < 1.1, old-time >= 1.0 && < 1.2, cmdargs >= 0.10 && < 0.11,- pandoc >= 1.9.3 && < 1.10,+ pandoc >= 1.0 && < 1.11, parsec >= 3.0 && < 3.2, process >= 1.0 && < 1.2, random >= 1.0 && < 1.1,
src/Hakyll/Web/Pandoc.hs view
@@ -15,13 +15,14 @@ , pandocCompilerWithTransform -- * Default options- , defaultHakyllParserState+ , defaultHakyllReaderOptions , defaultHakyllWriterOptions ) where -------------------------------------------------------------------------------- import Control.Applicative ((<$>))+import qualified Data.Set as S import Text.Pandoc @@ -35,28 +36,30 @@ -- | Read a string using pandoc, with the default options readPandoc :: Item String -- ^ String to read -> Item Pandoc -- ^ Resulting document-readPandoc = readPandocWith defaultHakyllParserState+readPandoc = readPandocWith defaultHakyllReaderOptions -------------------------------------------------------------------------------- -- | Read a string using pandoc, with the supplied options-readPandocWith :: ParserState -- ^ Parser options- -> Item String -- ^ String to read- -> Item Pandoc -- ^ Resulting document-readPandocWith state item = fmap (reader state (itemFileType item)) item+readPandocWith :: ReaderOptions -- ^ Parser options+ -> Item String -- ^ String to read+ -> Item Pandoc -- ^ Resulting document+readPandocWith ropt item = fmap (reader ropt (itemFileType item)) item where- reader s t = case t of- Html -> readHtml s- LaTeX -> readLaTeX s- LiterateHaskell t' -> reader s {stateLiterateHaskell = True} t'- Markdown -> readMarkdown s- Rst -> readRST s- Textile -> readTextile s+ reader ro t = case t of+ Html -> readHtml ro+ LaTeX -> readLaTeX ro+ LiterateHaskell t' -> reader (addExt ro Ext_literate_haskell) t'+ Markdown -> readMarkdown ro+ Rst -> readRST ro+ Textile -> readTextile ro _ -> error $- "Hakyll.Web.readPandocWith: I don't know how to read a file of the " ++- "type " ++ show t ++ " for: " ++ show (itemIdentifier item)+ "Hakyll.Web.readPandocWith: I don't know how to read a file of " +++ "the type " ++ show t ++ " for: " ++ show (itemIdentifier item) + addExt ro e = ro {readerExtensions = S.insert e $ readerExtensions ro} + -------------------------------------------------------------------------------- -- | Write a document (as HTML) using pandoc, with the default options writePandoc :: Item Pandoc -- ^ Document to write@@ -69,63 +72,63 @@ writePandocWith :: WriterOptions -- ^ Writer options for pandoc -> Item Pandoc -- ^ Document to write -> Item String -- ^ Resulting HTML-writePandocWith options = fmap $ writeHtmlString options+writePandocWith wopt = fmap $ writeHtmlString wopt -------------------------------------------------------------------------------- -- | Render the resource using pandoc renderPandoc :: Item String -> Item String renderPandoc =- renderPandocWith defaultHakyllParserState defaultHakyllWriterOptions+ renderPandocWith defaultHakyllReaderOptions defaultHakyllWriterOptions -------------------------------------------------------------------------------- -- | Render the resource using pandoc-renderPandocWith :: ParserState -> WriterOptions -> Item String -> Item String-renderPandocWith state options = writePandocWith options . readPandocWith state+renderPandocWith :: ReaderOptions -> WriterOptions -> Item String -> Item String+renderPandocWith ropt wopt = writePandocWith wopt . readPandocWith ropt -------------------------------------------------------------------------------- -- | Read a page render using pandoc pandocCompiler :: Compiler (Item String) pandocCompiler =- pandocCompilerWith defaultHakyllParserState defaultHakyllWriterOptions+ pandocCompilerWith defaultHakyllReaderOptions defaultHakyllWriterOptions -------------------------------------------------------------------------------- -- | A version of 'pandocCompiler' which allows you to specify your own pandoc -- options-pandocCompilerWith :: ParserState -> WriterOptions -> Compiler (Item String)-pandocCompilerWith state options = pandocCompilerWithTransform state options id+pandocCompilerWith :: ReaderOptions -> WriterOptions -> Compiler (Item String)+pandocCompilerWith ropt wopt = pandocCompilerWithTransform ropt wopt id -------------------------------------------------------------------------------- -- | An extension of 'pandocCompilerWith' which allows you to specify a custom -- pandoc transformation for the content-pandocCompilerWithTransform :: ParserState -> WriterOptions+pandocCompilerWithTransform :: ReaderOptions -> WriterOptions -> (Pandoc -> Pandoc) -> Compiler (Item String)-pandocCompilerWithTransform state options f = cached cacheName $- writePandocWith options . fmap f . readPandocWith state <$> getResourceBody+pandocCompilerWithTransform ropt wopt f = cached cacheName $+ writePandocWith wopt . fmap f . readPandocWith ropt <$> getResourceBody where cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc" -------------------------------------------------------------------------------- -- | The default reader options for pandoc parsing in hakyll-defaultHakyllParserState :: ParserState-defaultHakyllParserState = defaultParserState+defaultHakyllReaderOptions :: ReaderOptions+defaultHakyllReaderOptions = def { -- The following option causes pandoc to read smart typography, a nice -- and free bonus.- stateSmart = True+ readerSmart = True } -------------------------------------------------------------------------------- -- | The default writer options for pandoc rendering in hakyll defaultHakyllWriterOptions :: WriterOptions-defaultHakyllWriterOptions = defaultWriterOptions+defaultHakyllWriterOptions = def { -- This option causes literate haskell to be written using '>' marks in -- html, which I think is a good default.- writerLiterateHaskell = True+ writerExtensions = S.insert Ext_literate_haskell (writerExtensions def) }
src/Hakyll/Web/Pandoc/Biblio.hs view
@@ -5,8 +5,8 @@ -- @.bib@) and a CSL file (@.csl@). Both need to be compiled with their -- respective compilers ('biblioCompiler' and 'cslCompiler'). Then, you can -- refer to these files when you use 'pageReadPandocBiblio'. This function also--- takes a parser state for completeness -- you can use--- 'defaultHakyllParserState' if you're unsure.+-- takes the reader options for completeness -- you can use+-- 'defaultHakyllReaderOptions' if you're unsure. {-# LANGUAGE Arrows #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}@@ -22,9 +22,10 @@ -------------------------------------------------------------------------------- import Control.Applicative ((<$>)) import Data.Binary (Binary (..))+import Data.Traversable (traverse) import Data.Typeable (Typeable) import qualified Text.CSL as CSL-import Text.Pandoc (Pandoc, ParserState (..))+import Text.Pandoc (Pandoc, ReaderOptions (..)) import Text.Pandoc.Biblio (processBiblio) @@ -84,19 +85,22 @@ ---------------------------------------------------------------------------------readPandocBiblio :: ParserState- -> Item CSL+readPandocBiblio :: ReaderOptions+ -> Maybe (Item CSL) -> Item Biblio -> (Item String) -> Compiler (Item Pandoc)-readPandocBiblio state csl biblio item = do+readPandocBiblio ropt csl biblio item = do+ -- Parse CSL file, if given+ style <- unsafeCompiler $+ traverse (CSL.readCSLFile . toFilePath . itemIdentifier) csl+ -- We need to know the citation keys, add then *before* actually parsing the -- actual page. If we don't do this, pandoc won't even consider them -- citations! let Biblio refs = itemBody biblio- cits = map CSL.refId refs- state' = state {stateCitations = stateCitations state ++ cits}- pandoc = itemBody $ readPandocWith state' item- cslPath = toFilePath $ itemIdentifier csl- pandoc' <- unsafeCompiler $ processBiblio cslPath Nothing refs pandoc+ ropt' = ropt {readerReferences = readerReferences ropt ++ refs}+ pandoc = itemBody $ readPandocWith ropt' item+ pandoc' = processBiblio style refs pandoc+ return $ fmap (const pandoc') item