pandoc / lua-filters

A collection of lua filters for pandoc
MIT License
603 stars 165 forks source link

section-refs: subsequent-author-substitute appears where it shouldn’t #38

Closed njbart closed 4 years ago

njbart commented 5 years ago

When using a CSL style where subsequent-author-substitute is active (such as chicago-author-date.csl), in some contexts the substitute (“———”) appears though the item in question is not preceded by an earlier item that starts with the same author’s name.

In the example below, e.g., it appears as if “Doe’s Second Book” were written by “Abel”.

MWE:

pandoc -s -F pandoc-citeproc --lua-filter ~/.pandoc/section-refs.lua -t plain << EOT

# Section One

Foo [@abel; @doe2].

## References {-}

# Section Two

Foo [@doe1; @doe2].

## References {-}

---
references:
- id: doe1
  type: book
  author:
  - family: Doe
    given: Jane
  issued:
    - year: 2017
  title: Doe’s first book
- id: doe2
  type: book
  author:
  - family: Doe
    given: Jane
  issued:
    - year: 2018
  title: Doe’s second book
- id: abel
  type: book
  author:
  - family: Abel
    given: Niels
  issued:
    - year: 2018
  title: Abel’s Book
...
EOT

Expected output:

SECTION ONE

Foo (Abel 2018; Doe 2018).

References

Abel, Niels. 2018. _Abel’s Book_.

Doe, Jane. 2018. _Doe’s Second Book_.

SECTION TWO

Foo (Doe 2017, 2018).

References

Doe, Jane. 2017. _Doe’s First Book_.

———. 2018. _Doe’s Second Book_.

Actual output:

SECTION ONE

Foo (Abel 2018; Doe 2018).

References

Abel, Niels. 2018. _Abel’s Book_.

———. 2018. _Doe’s Second Book_.

SECTION TWO

Foo (Doe 2017, 2018).

References

Doe, Jane. 2017. _Doe’s First Book_.

———. 2018. _Doe’s Second Book_.

I do realize this might be difficult to fix given the general approach of this filter – but at the very least it seems to merit a note warning users not to expect correct results when using “subsequent-author-substitute” styles.

tarleb commented 5 years ago

CC @jkr