Search code examples
pandoc-citeproc

pandoc-citeproc as API: processCites' does not add references


I have a small text file in markdown :

---
title: postWithReference
author: auf
date: 2010-07-29
keywords: homepage
abstract: |
    What are the objects of
    ontologists .

bibliography: "/home/frank/Workspace8/SSG/site/resources/BibTexLatex.bib"
csl: "/home/frank/Workspace8/SSG/site/resources/chicago-fullnote-bibliography-bb.csl"
---

An example post. With a reference to [@Frank2010a] and more[@navratil08].

## References

and process it in Haskell with processCites' which has a single argument, namely the Pandoc data resulting from readMarkdown. The bibliography and the csl style should be taken from the input file.

The process does not produce errors, but the result of processCites is the same text as the input; references are not treated at all. For the same input the references are resolved with the standalone pandoc (this excludes errors in the bibliography and the csl style)

pandoc -f markdown -t html  --filter=pandoc-citeproc -o p1.html postWithReference.md 

The issue is therefore in the API. The code I have is:

markdownToHTML4 :: Text -> PandocIO Value
markdownToHTML4 t = do
  pandoc   <- readMarkdown markdownOptions  t
  let meta2 = flattenMeta (getMeta pandoc)

  -- test if biblio is present and apply 
  let bib = Just $ ( meta2) ^? key "bibliography" . _String
  pandoc2 <- case bib of
    Nothing -> return pandoc
    _ -> do
                res <- liftIO $ processCites' pandoc --  :: Pandoc -> IO Pandoc
                when (res == pandoc) $ 
                    liftIO $ putStrLn "*** markdownToHTML3 result without references ***" 
                return res

  htmltex <- writeHtml5String html5Options pandoc2

  let withContent = ( meta2) & _Object . at "contentHtml" ?~ String ( htmltex)
  return  withContent

getMeta :: Pandoc -> Meta
getMeta (Pandoc m _) = m

What do I misunderstand? are there any reader options necessary for citeproc? The bibliography is a BibLatex file.

I found in hakyll code a comment, which I cannot understand in light of the code there - perhaps somebody knows what the intention is.

-- 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!

Solution

  • The original problem was very simple: I had not included the option Ext_citations in the markdownOptions. When it is included, the example works (thanks to help I received from the pandoc-citeproc issue page). The referenced code is updated...