andras-simonyi / citeproc-el

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

How does the "label" work #49

Closed jkitchin closed 3 years ago

jkitchin commented 3 years ago

I am not sure I am doing this right. Suppose I have this org-file, which tangles the test.bib file out, and has chicago-author-date-16th-edition.csl and locales-en-US.xml in the same directory.

#+BEGIN_SRC bibtex :tangle test.bib
@article{kitchin-2015-examp-effec,
  author =   {John R. Kitchin},
  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 =      {https://doi.org/10.1021/acscatal.5b00538},
  DATE_ADDED =   {Fri Jan 18 09:54:51 2019},
}
#+END_SRC

#+BEGIN_SRC emacs-lisp :var tangled=(org-babel-tangle)
(let* ((proc (citeproc-create "chicago-author-date-16th-edition.csl"
                  (citeproc-itemgetter-from-bibtex "test.bib")
                  (citeproc-locale-getter-from-dir ".")
                  "en-US"))
       (cites (list (citeproc-citation-create :cites '(((id . "kitchin-2015-examp-effec")
                            (prefix . "See ")
                            (suffix . "")
                            (locator . "2")
                            (label . "page")
                            (suppress-author)))
                          :mode 'nil
                          :capitalize-first nil
                          :suppress-affixes nil)))
       (rendered-citations (progn (citeproc-append-citations cites proc)
                  (citeproc-render-citations proc 'plain nil))))
  (car rendered-citations))
#+END_SRC

#+RESULTS:
: (See Kitchin 2015, 2)

I would have thought this would render as (See Kitchin 2015, pg. 2), but it doesn't. Am I doing something wrong with the label? or does it depend on the style used?

[EDIT]: I see it does depend on the style. With apa-5th-edition.csl, it renders as (See Kitchin, 2015, p. 2), but only when you use "page" as the label, if you use "pg." or "p." or "p" then it renders as (See Kitchin, 2015, 2). Is that intentional, or documented somewhere?

[EDIT 2]: I can further see that in oc-csl.el, it has an alist to standardize the label in those cases I mentioned to page. That seems like an ok thing to do. If that is the answer, feel free to close this.

andras-simonyi commented 3 years ago

Yes, label rendering indeed depends on the style and there is a canonical CSL list of locators that can be the value of the label field -- see the latest version here. Label normalization is based, as you write, on the alist in oc-csl.el (which actually mimics pandoc's mapping).