Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defaults files cannot specify order between filter and citeproc #8737

Closed
wenkokke opened this issue Mar 30, 2023 · 5 comments
Closed

Defaults files cannot specify order between filter and citeproc #8737

wenkokke opened this issue Mar 30, 2023 · 5 comments

Comments

@wenkokke
Copy link

You cannot specify the relative ordering of filters and citeproc in a defaults file.
For instance, with the following set up:

  • defaults.yaml
    input-file: sample.md
    output-file: sample.html
    filters: ["${.}/include-files.lua"]
    citeproc: true
  • sample.md
    ---
    bibliography: sample.bib
    ---
    ```{.include}
    chapters/chapter1.md
    ```
  • sample.bib
    @book{BenjaminHornigold,
      author = {Benjamin Hornigold},
      title  = {A proof of Pirate ipsum},
      year   = {1680},
    }
  • chapters/chapter1.md
    We all love @BenjaminHornigold's famous proof.
    But is it real?
    No. Probably not.
  • include-files.lua from pandoc/lua-filters

The expected output of pandoc -d defaults.yaml would be something like:

<p>
  We all love
  <span class="citation" data-cites="BenjaminHornigold">Hornigold (1680)</span
  >’s famous proof. But is it real? No. Probably not.
</p>
<div id="refs" class="references csl-bib-body hanging-indent" role="list">
  <div id="ref-BenjaminHornigold" class="csl-entry" role="listitem">
    Hornigold, Benjamin. 1680. <em>A Proof of Pirate Ipsum</em>.
  </div>
</div>

However, the actual the result is:

<p>
  We all love
  <span class="citation" data-cites="BenjaminHornigold">@BenjaminHornigold</span
  >’s famous proof. But is it real? No. Probably not.
</p>

Pandoc version?
I'm using Pandoc 3.1.1 on macOS.

$ pandoc --version
pandoc 3.1.1
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /Users/keri/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
@wenkokke wenkokke added the bug label Mar 30, 2023
@wenkokke
Copy link
Author

A zip archive with the files described above: bug-report.zip

@wenkokke
Copy link
Author

wenkokke commented Mar 30, 2023

The solution is to omit the citeproc: true key and define a Lua filter that runs citeproc...

-- File: citeproc.lua
function Pandoc (doc)
  return pandoc.utils.citeproc(doc)
end

...which you can then include in a specific position in your filters list:

# File: defaults.yaml
filters:
- "${.}/include-files.lua"
- "${.}/citeproc.lua"

@tarleb
Copy link
Collaborator

tarleb commented Mar 30, 2023

Thank you for this excellent report. The intended way to do this is the following (the type for the Lua filter can be omitted):

filters:
  - type: lua
    path: '${.}/include-files.lua'
  - type: citeproc

It seems that we need to make this more obvious in the manual, so I'll categorize this as a documentation bug.

@tarleb tarleb added the docs label Mar 30, 2023
@jgm
Copy link
Owner

jgm commented Mar 30, 2023

Also the docs entry for filters still has an example with pandoc-citeproc, which may be confusing.

@wlupton
Copy link
Contributor

wlupton commented Apr 6, 2023

Doesn't this also work?

filters:
  - '${.}/include-files.lua'
  - citeproc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants