hakyll-contrib-links 0.1.0.0 → 0.2.0.0
raw patch · 2 files changed
+30/−17 lines, 2 files
Files
Hakyll/Contrib/Markdown/Link.hs view
@@ -34,11 +34,13 @@ import Hakyll.Core.Resource(Resource) import Hakyll.Core.Writable(Writable(..)) import Hakyll.Web.Pandoc ( defaultHakyllParserState+ , defaultHakyllWriterOptions , pageReadPandocWithA- , writePandoc+ , writePandocWith ) import Hakyll.Web.Template(applySelf) import Hakyll.Web.Page(addDefaultFields, readPageCompiler, Page)+import Text.Pandoc(WriterOptions) import Text.Pandoc.Parsing(toKey, ParserState(..)) import Text.Pandoc.Definition hiding (Link) import Text.Parsec.String (Parser)@@ -77,9 +79,18 @@ -- | Compiles a pandoc page with a give list of links database. pageWithLinksCompiler :: [Identifier [Link]] -- ^ The links db's -> Compiler Resource (Page String)-pageWithLinksCompiler ids = cached cacheName $- readStatePage >>> includeList ids >>> pageCompilerA+pageWithLinksCompiler = pageWithLinksCompiler' defaultHakyllParserState+ defaultHakyllWriterOptions +-- | Similar to `pageWithLinksCompiler` but takes additional parser+-- and writer option.+pageWithLinksCompiler' :: ParserState -- ^ parser state+ -> WriterOptions -- ^ pandoc writer options+ -> [Identifier [Link]] -- ^ The links db's+ -> Compiler Resource (Page String)+pageWithLinksCompiler' popts wopts ids = cached cacheName $+ readStatePage popts >>> includeList ids >>> pageCompilerA wopts+ -- | A compiler that modified the Pandoc parser state to accomodate a -- set of link definitions. include :: Identifier [Link] -- ^ The link database identifier@@ -99,17 +110,19 @@ includeList = foldl1 (>>>) . map include --- | A version of page compiler useful for including-readStatePage :: Compiler Resource (ParserState, Page String)-readStatePage = proc res -> do page <- readPageCompiler -< res- returnA -< (defaultHakyllParserState, page)-+-- | Tags along a given parser state to the page.+readStatePage :: ParserState+ -> Compiler Resource (ParserState, Page String)+readStatePage pstate = proc res -> do page <- readPageCompiler -< res+ returnA -< (pstate, page) --- | Compilers with a given parser state.-pageCompilerA :: Compiler (ParserState, Page String) (Page String)-pageCompilerA = second fieldsAndTemplate >>> pageReadPandocWithA >>> writer+-- | Compiles a given page with pandoc. The writer option can be+-- configured using its argument.+pageCompilerA :: WriterOptions -- ^ Configure writer options+ -> Compiler (ParserState, Page String) (Page String)+pageCompilerA wopts = second fieldsAndTemplate >>> pageReadPandocWithA >>> writer where fieldsAndTemplate = addDefaultFields >>> arr applySelf- writer = arr $ fmap writePandoc+ writer = arr $ fmap $ writePandocWith wopts -- | Convert the link to string. toString :: Link -> String@@ -180,9 +193,9 @@ -- -- > [linkname]: <url> Comment ----- Multiple lines are folded if the are intended atleast by a space.--- All lines that start with a @'--'@ (two hyphens) are treated as--- comments and skipped.+-- Multiple lines are folded if the are indented by atleast by a+-- space. All lines that start with a @'--'@ (two hyphens) are+-- treated as comments and skipped. -- | Convert a set of lines to links. links :: String -> [Link]
hakyll-contrib-links.cabal view
@@ -1,5 +1,5 @@ name: hakyll-contrib-links-version: 0.1.0.0+version: 0.2.0.0 synopsis: A hakyll library that helps maintain a separate links database. description: Often when building packages we would like to collect all@@ -40,4 +40,4 @@ Source-repository this type: darcs location: http://patch-tag.com/r/ppk/hakyll-contrib-links- tag: 0.1.0.0-RELEASE+ tag: 0.2.0.0-RELEASE