Dear Ihor and Max, thanks for the feedback and apologies for responding that late.
On Wed, 15 May 2024 at 13:48, Max Nikulin <maniku...@gmail.com> wrote: > Is it possible to keep title formatting from .bib files till it becomes > known that specific style requires sentence case for particular entry > type? I had a hope that it might alleviate the issue and to make things > working out of the box for more users. The problem is that many (maybe most) CSL styles simply assume that titles are in sentence-case in the input without making this explicit. The APA citation style is a prominent example: the APA guidelines require sentence-case titles but AFAICS the standard CSL implementations do not encode this explicitly. Of course it could be checked whether a CSL style contains explicit instructions about how to format titles and skip sentence-case conversion of input for those but this probably would not solve the problems of users who do not want the conversion at all. > > I'm a bit unsure about naming the option: > > Perhaps `org-cite-csl-sentence-case-bibtex-titles-without-langid' > > A variant: org-cite-csl-bibtex-title-to-sentence-case thanks, in the attached patch I went with (a slightly modified version of) this. > Does it means that you added one more argument to `citeproc-create' and > that consistent Org and citeproc-el versions must be used? no, at least in the sense that this argument has been there since 2021. > It may be tricky to preserve > backward-forward compatibility on this step, but it should make further > changes easier. It may be reasonable to explicitly add version of > "protocol" to the property list, so that citeproc-el may decide if error > should be signaled in the case of serious version difference. although I don't think backward compatibility could be a problem in that particular case, in the future a mechanism like this might be useful, so I plan to implement it, thanks for the suggestion. > It is not clear for me why `org-cite-csl-sentence-case-bibtex-titles' is > a part of Org, not of citeproc-el. The only thing that Org can do is to > pass it to citeproc-el. It is not configurable per .org file and likely > it should not be. From my point of view it might be more suitable per > .bib file. Anyway it is almost unrelated to Org. citeproc-el doesn't have customizable user options by design because it was conceived as a relatively low level rendering library. Also, it's used by several user-facing packages by now in addition to Org (org-ref, citar etc.) so I think it would be both confusing and difficult to try to keep this type of customizations in the library. > On Mon, 17 Jun 2024 at 13:37, Ihor Radchenko <yanta...@posteo.net> wrote: > > > Also, it would be nice to point out the CSL and Bibtex have different> > > > > > conventions for the title field. I added a few words about this now both in the docstring and in the ORG-NEWS entry -- I've attached the updated patch. best wishes, András
From e89c7872d8c287fb3affd9c815a1423b366c2bb9 Mon Sep 17 00:00:00 2001 From: Andras Simonyi <andras.simo...@gmail.com> Date: Wed, 19 Jun 2024 08:26:19 +0200 Subject: [PATCH] oc-csl: New custom option `org-cite-csl-bibtex-titles-to-sentence-case' * lisp/oc-csl.el (org-cite-csl-bibtex-titles-to-sentence-case): New variable. (org-cite-csl--processor): Create the itemgetter using the new option. * etc/ORG-NEWS (New option ~org-cite-csl-bibtex-titles-to-sentence-case~): Announce the change. --- etc/ORG-NEWS | 11 +++++++++++ lisp/oc-csl.el | 21 ++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index b81dabb15..78a60382d 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -61,6 +61,17 @@ The default value used to be pulled from =dvipng= process type from =latexmk= (when available), or running =latex= multiple times, so that all the references are resolved in the generated png. +*** New option ~org-cite-csl-bibtex-titles-to-sentence-case~ + +When this option is non-nil then title fields in bibtex bibliography +entries are converted to sentence-case before being formatted +according to a CSL style, except for entries with a =langid= field +specifying a non-English language. When nil, this conversion is +limited to entries having a =langid= field specifying a variant of +English. The default value is ~t~ as the CSL standard assumes that +English titles are specified in sentence-case but the bibtex +bibliography format requires them to be written in title-case. + ** New functions and changes in function arguments # This also includes changes in function behavior from Elisp perspective. diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el index b8691bf6f..338f72e9d 100644 --- a/lisp/oc-csl.el +++ b/lisp/oc-csl.el @@ -321,6 +321,24 @@ in the bibliography measured in characters." :type 'string :package-version '(Org . "9.7")) +(defcustom org-cite-csl-bibtex-titles-to-sentence-case t + "Convert bibtex title fields to sentence-case by default. + +When non-nil, title fields in bibtex bibliography entries are +converted to sentence-case before being formatted according to a +CSL style, except for entries with a `langid' field specifying a +non-English language. When nil, title conversion is limited to +entries having a `langid' field specifying a variant of English. + +Conversion of titles to sentence-case by default is in most cases +useful because the CSL standard assumes that English titles are +specified in sentence-case but the bibtex bibliography format +requires them to be written in title-case." + :group 'org-cite + :package-version '(Org . "9.8") + :type 'boolean + :safe #'booleanp) + ;;; Internal variables (defconst org-cite-csl--etc-dir @@ -579,7 +597,8 @@ property in INFO." (processor (citeproc-create (org-cite-csl--style-file info) - (citeproc-hash-itemgetter-from-any bibliography) + (citeproc-hash-itemgetter-from-any + bibliography (not org-cite-csl-bibtex-titles-to-sentence-case)) (org-cite-csl--locale-getter) locale))) (plist-put info :cite-citeproc-processor processor) -- 2.34.1