diff options
author | knih <ken@succ0.org> | 2018-04-28 19:43:56 +0900 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2018-04-28 13:53:13 +0200 |
commit | ed2535f63690c1f67858d859e7e376e49823157a (patch) | |
tree | 01333f34b4c0aaf7eb410106d5f5e70753127aab /lib/Hakyll/Web/Pandoc | |
parent | 73e427687b7e8c7a500bd50ad118a3e2e8fe5a8d (diff) | |
download | hakyll-ed2535f63690c1f67858d859e7e376e49823157a.tar.gz |
Fix path resolution in Pandoc.Biblio
Diffstat (limited to 'lib/Hakyll/Web/Pandoc')
-rw-r--r-- | lib/Hakyll/Web/Pandoc/Biblio.hs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/Hakyll/Web/Pandoc/Biblio.hs b/lib/Hakyll/Web/Pandoc/Biblio.hs index f53fa2b..5127d88 100644 --- a/lib/Hakyll/Web/Pandoc/Biblio.hs +++ b/lib/Hakyll/Web/Pandoc/Biblio.hs @@ -25,17 +25,19 @@ module Hakyll.Web.Pandoc.Biblio -------------------------------------------------------------------------------- import Control.Monad (liftM, replicateM) import Data.Binary (Binary (..)) -import Data.Default (def) import Data.Typeable (Typeable) import Hakyll.Core.Compiler +import Hakyll.Core.Compiler.Internal import Hakyll.Core.Identifier import Hakyll.Core.Item +import Hakyll.Core.Provider import Hakyll.Core.Writable import Hakyll.Web.Pandoc import Hakyll.Web.Pandoc.Binary () import qualified Text.CSL as CSL import Text.CSL.Pandoc (processCites) -import Text.Pandoc (Pandoc, ReaderOptions (..)) +import Text.Pandoc (Pandoc, ReaderOptions (..), + enableExtension, Extension (..)) -------------------------------------------------------------------------------- @@ -83,7 +85,7 @@ instance Writable Biblio where -------------------------------------------------------------------------------- biblioCompiler :: Compiler (Item Biblio) biblioCompiler = do - filePath <- toFilePath <$> getUnderlying + filePath <- getResourceFilePath makeItem =<< unsafeCompiler (Biblio <$> CSL.readBiblioFile idpred filePath) where -- This is a filter on citations. We include all citations. @@ -98,7 +100,9 @@ readPandocBiblio :: ReaderOptions -> Compiler (Item Pandoc) readPandocBiblio ropt csl biblio item = do -- Parse CSL file, if given - style <- unsafeCompiler $ CSL.readCSLFile Nothing . toFilePath . itemIdentifier $ csl + provider <- compilerProvider <$> compilerAsk + style <- unsafeCompiler $ + CSL.readCSLFile Nothing . (resourceFilePath provider) . 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 @@ -115,4 +119,8 @@ pandocBiblioCompiler cslFileName bibFileName = do csl <- load $ fromFilePath cslFileName bib <- load $ fromFilePath bibFileName liftM writePandoc - (getResourceBody >>= readPandocBiblio def csl bib) + (getResourceBody >>= readPandocBiblio ropt csl bib) + where ropt = defaultHakyllReaderOptions + { -- The following option enables citation rendering + readerExtensions = enableExtension Ext_citations $ readerExtensions defaultHakyllReaderOptions + } |