emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "András Simonyi" <andras.simonyi@gmail.com>
To: emacs-orgmode list <emacs-orgmode@gnu.org>
Subject: [PATCH] oc-csl: New custom option `org-cite-csl-sentence-case-bibtex-titles'
Date: Sat, 11 May 2024 17:33:23 +0200	[thread overview]
Message-ID: <CAOWRwxDBsTGw3wKBVnuV=Cx+UC5w0PkcimZQ-WLJtZc1UL5p5w@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 880 bytes --]

Dear All,

since bibtex and biblatex requires title fields to be in title case
but CSL assumes that they are in sentence-case, citeproc-el converts
title fields in bib(la)tex bibliography databases into sentence-case
before processing them except for entries with an explicit non-English
langid value. Although this seems to be reasonable behaviour, there
were several requests in the last couple of years to make it possible
to turn this conversion off (see, e.g., citeproc issues  #119 and
#142). The attached patch introduces a new custom option to configure
when to perform the conversion.

I'm a bit unsure about naming the option:
Perhaps `org-cite-csl-sentence-case-bibtex-titles-without-langid'
would be more precise but I found it absurdly long and technical, as
most users are probably unaware of the existence of langid fields.

best wishes,
András

[-- Attachment #2: 0001-oc-csl-New-custom-option-org-cite-csl-sentence-case-.patch --]
[-- Type: text/x-patch, Size: 2771 bytes --]

From 031428611c18bb4d97bbdbd11a7549ca2b96ccec Mon Sep 17 00:00:00 2001
From: Andras Simonyi <andras.simonyi@gmail.com>
Date: Sat, 11 May 2024 11:20:41 +0200
Subject: [PATCH] oc-csl: New custom option
 `org-cite-csl-sentence-case-bibtex-titles'

* lisp/oc-csl.el (org-cite-csl-sentence-case-bibtex-titles): New
variable.
(org-cite-csl--processor): Create the itemgetter using the new option.
* etc/ORG-NEWS (New option
~org-cite-csl-sentence-case-bibtex-titles~): Announce the change.
---
 etc/ORG-NEWS   |  9 +++++++++
 lisp/oc-csl.el | 18 +++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 36eeddda1..9ca71d0a2 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1128,6 +1128,15 @@ blocks that do not specify any ~:formatter~ parameter. Its default
 value (the new function ~org-columns-dblock-write-default~) yields the
 previous (fixed) formatting behaviour.
 
+*** New option ~org-cite-csl-sentence-case-bibtex-titles~
+
+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 defult value is ~t~.
+
 ** New features
 *** =ob-lua=: Support all types and multiple values in results
 
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 9bbe5e29d..7234174d0 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -321,6 +321,21 @@ in the bibliography measured in characters."
   :type 'string
   :package-version '(Org . "9.7"))
 
+(defcustom org-cite-csl-sentence-case-bibtex-titles 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, this conversion is limited to entries having a `langid'
+field specifying a variant of English."
+  :group 'org-cite
+  :package-version '(Org . "9.7")
+  :type 'boolean
+  :safe #'booleanp)
+
 \f
 ;;; Internal variables
 (defconst org-cite-csl--etc-dir
@@ -584,7 +599,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-sentence-case-bibtex-titles))
                (org-cite-csl--locale-getter)
                locale)))
         (plist-put info :cite-citeproc-processor processor)
-- 
2.34.1


             reply	other threads:[~2024-05-11 15:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-11 15:33 András Simonyi [this message]
2024-05-11 17:26 ` [PATCH] oc-csl: New custom option `org-cite-csl-sentence-case-bibtex-titles' Ihor Radchenko
2024-05-14  9:58   ` András Simonyi
2024-05-17 13:34     ` Ihor Radchenko
2024-05-15 11:48 ` Max Nikulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOWRwxDBsTGw3wKBVnuV=Cx+UC5w0PkcimZQ-WLJtZc1UL5p5w@mail.gmail.com' \
    --to=andras.simonyi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).