diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Web/Pandoc.hs | 1 | ||||
-rw-r--r-- | src/Hakyll/Web/Pandoc/FileType.hs | 2 | ||||
-rw-r--r-- | src/Hakyll/Web/Template/Context.hs | 17 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/Hakyll/Web/Pandoc.hs b/src/Hakyll/Web/Pandoc.hs index 78df1df..a1b8903 100644 --- a/src/Hakyll/Web/Pandoc.hs +++ b/src/Hakyll/Web/Pandoc.hs @@ -49,6 +49,7 @@ readPandocWith :: ReaderOptions -- ^ Parser options readPandocWith ropt item = fmap (reader ropt (itemFileType item)) item where reader ro t = case t of + DocBook -> readDocBook ro Html -> readHtml ro LaTeX -> readLaTeX ro LiterateHaskell t' -> reader (addExt ro Ext_literate_haskell) t' diff --git a/src/Hakyll/Web/Pandoc/FileType.hs b/src/Hakyll/Web/Pandoc/FileType.hs index 46c8e24..29d08fe 100644 --- a/src/Hakyll/Web/Pandoc/FileType.hs +++ b/src/Hakyll/Web/Pandoc/FileType.hs @@ -22,6 +22,7 @@ import Hakyll.Core.Item data FileType = Binary | Css + | DocBook | Html | LaTeX | LiterateHaskell FileType @@ -39,6 +40,7 @@ fileType :: FilePath -> FileType fileType = uncurry fileType' . splitExtension where fileType' _ ".css" = Css + fileType' _ ".dbk" = DocBook fileType' _ ".htm" = Html fileType' _ ".html" = Html fileType' f ".lhs" = LiterateHaskell $ case fileType f of diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs index 0cbe1ce..a0f2779 100644 --- a/src/Hakyll/Web/Template/Context.hs +++ b/src/Hakyll/Web/Template/Context.hs @@ -23,6 +23,7 @@ module Hakyll.Web.Template.Context , modificationTimeField , modificationTimeFieldWith , teaserField + , teaserFieldWithSeparator , missingField ) where @@ -318,9 +319,21 @@ modificationTimeFieldWith locale key fmt = field key $ \i -> do teaserField :: String -- ^ Key to use -> Snapshot -- ^ Snapshot to load -> Context String -- ^ Resulting context -teaserField key snapshot = field key $ \item -> do +teaserField = teaserFieldWithSeparator teaserSeparator + + +-------------------------------------------------------------------------------- +-- | A context with "teaser" key which contain a teaser of the item, defined as +-- the snapshot content before the teaser separator. The item is loaded from the +-- given snapshot (which should be saved in the user code before any templates +-- are applied). +teaserFieldWithSeparator :: String -- ^ Separator to use + -> String -- ^ Key to use + -> Snapshot -- ^ Snapshot to load + -> Context String -- ^ Resulting context +teaserFieldWithSeparator separator key snapshot = field key $ \item -> do body <- itemBody <$> loadSnapshot (itemIdentifier item) snapshot - case needlePrefix teaserSeparator body of + case needlePrefix separator body of Nothing -> fail $ "Hakyll.Web.Template.Context: no teaser defined for " ++ show (itemIdentifier item) |