andras-simonyi / citeproc-el

A CSL 1.0.2 Citation Processor for Emacs.
GNU General Public License v3.0
84 stars 9 forks source link

Possible bug for textual citations? Extra author reference #139

Closed jkitchin closed 1 week ago

jkitchin commented 1 year ago

In this code:


#+BEGIN_SRC bibtex :tangle test.bib
@article{kitchin-2015-examp,
  author =   {Kitchin, John R.},
  title =    {Examples of Effective Data Sharing in Scientific Publishing},
  journal =  {ACS Catalysis},
  volume =   {5},
  number =   {6},
  pages =    {3894-3899},
  year =     2015,
  doi =      {10.1021/acscatal.5b00538},
  url =      { http://dx.doi.org/10.1021/acscatal.5b00538 },
  keywords =     {DESC0004031, early-career, orgmode, Data sharing },
  eprint =   { http://dx.doi.org/10.1021/acscatal.5b00538 },
}
#+END_SRC

#+BEGIN_SRC emacs-lisp :results code
(org-babel-tangle)

(defun render (csl-style data sentcase)
  (let* ((proc (citeproc-create csl-style
                (citeproc-hash-itemgetter-from-any "test.bib" sentcase)
                (citeproc-locale-getter-from-dir "../../../../org-ref/citeproc/csl-locales/")
                "en-US"))
     (cites (list (citeproc-citation-create :cites data
                        :mode 'textual
                                                  :suppress-affixes t
                        :capitalize-first nil
                        :suppress-affixes nil)))
     (rendered-citations (progn (citeproc-append-citations cites proc)
                    (citeproc-render-citations proc 'org nil))))
    rendered-citations))

;; https://raw.githubusercontent.com/citation-style-language/styles/master/elsevier-harvard.csl
(render "elsevier-harvard.csl" '(((id . "kitchin-2015-examp")
                  (prefix . "See ")
                  (suffix . "")
                  (locator . "2")
                  (label . "page")
                  (suppress-author)))
    nil)
#+END_SRC

#+RESULTS:
#+begin_src emacs-lisp
("Kitchin See [[citeproc_bib_item_1][Kitchin, 2015, p. 2]]")
#+end_src

It appears there is an extra author (Kitchin) at the beginning of the output. I would have thought it should just be "See [[citeproc_bib_item_1][Kitchin, 2015, p. 2]]"

Is this a bug?

andras-simonyi commented 1 week ago

Not a bug, the problem's cause is that the current API doesn't support using `suppress-author' in cite alists, it is only allowed as a citation mode -- see the explanation given in the duplicate issue #151. Closing.