pandoc-citeproc as API: processCites' 不添加引用

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

我在 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

并在 Haskell 中使用 processCites' 处理它,它有一个参数,即 readMarkdown 产生的 Pandoc 数据。参考书目和 csl 样式应取自输入文件。

过程没有产生错误,但是processCites的结果和输入的文本是一样的;引用根本不被处理。对于相同的输入,引用使用独立的 pandoc 解析(这不包括参考书目和 csl 样式中的错误)

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

因此问题在 API。我的代码是:

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

我误会了什么? citeproc 是否有任何必要的 reader 选项?参考书目是一个 BibLatex 文件。

我在 hakyll code 中发现了一条评论,根据那里的代码我无法理解它 - 也许有人知道意图是什么。

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

我有一个解决方法(不是原始问题的答案,我仍然希望有人能找出我的错误!)。用 System.readProess 调用独立 pandoc 并传递文本并返回结果很简​​单,甚至不读写文件:

processCites2x :: Maybe FilePath -> Maybe FilePath -> Text ->   ErrIO Text
-- porcess the cites in the text (not with the API)
-- using systemcall because the standalone pandoc works with 
-- call: pandoc -f markdown -t html  --filter=pandoc-citeproc
-- with the input text on stdin and the result on stdout
-- the csl and bib file are used from text, not from what is in the arguments

processCites2x _ _  t  = do
        putIOwords ["processCite2" ] -- - filein\n", showT styleFn2, "\n", showT bibfn2]

        let cmd = "pandoc"
        let cmdargs = ["--from=markdown", "--to=html5", "--filter=pandoc-citeproc" ]

        let cmdinp = t2s t
        res :: String <- callIO $ System.readProcess cmd cmdargs cmdinp

        return . s2t $ res
        -- error are properly caught and reported in ErrIO

t2ss2t是字符串和文本之间的转换实用程序,ErrIOErrorT Text a IOcallIO本质上是liftIO处理的错误。

原来的问题很简单:我没有在markdownOptions中包含选项Ext_citations。当包含它时,该示例就可以工作(感谢我从 pandoc-citeproc 问题页面收到的帮助)。参考代码已更新...