emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "David Lukeš" <dafydd.lukes@gmail.com>
To: "Bruce D'Arcus" <bdarcus@gmail.com>
Cc: Ihor Radchenko <yantar92@gmail.com>,
	org-mode-email <emacs-orgmode@gnu.org>
Subject: Re: oc-basic: CSL-JSON year as number vs. string (nativecomp?)
Date: Mon, 20 Jun 2022 16:13:45 +0200	[thread overview]
Message-ID: <CAEPTPExAz6TDiZQ24kobh1jQ9Jfd-BYgpz3nknFV-hUziic8QA@mail.gmail.com> (raw)
In-Reply-To: <CAF-FPGOf7Lnk5nAsTss7vphK5s88Dze5T2uxQ3qsVc5JUpfCfg@mail.gmail.com>

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

> I created CSL, and have helped develop the data schema.

Well, that's what I call a reliable source :) I suppose this is as
good a time as any to say thanks for all that!

> it's likely we'll change the date property to prefer an
> EDTF string

Will that be stored in the `raw` or `literal` field? In that case, the
current implementation should work with (not too wild) EDTF strings.
If not, code will have to be added to extract the value from the
appropriate field.

> I'd prefer an explicit cond here. format "%s" may silently
> work on malformed json files and will mask issues with
> bibliography from the user.

Sure, good idea :)

> Would you mind creating a patch and possibly supplying a test
> that will make sure that the example file and similar are correctly
> parsed?

I'm attaching a patch (just the patch for now, no commit message), let
me know what you think, in particular the error message. What would be
an acceptable way to wrap the format string?

As for tests -- if `oc-basic.el` already had some, I'd try to see if I
can come up with something by analogy. But as it stands, I know too
little about Elisp, nothing about Elisp testing, and have too little
spare time, sorry :(



[-- Attachment #2: oc-basic.el.patch --]
[-- Type: text/x-patch, Size: 1177 bytes --]

diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el
index a937f75..f10b95b 100644
--- a/lisp/oc-basic.el
+++ b/lisp/oc-basic.el
@@ -189,7 +189,14 @@ Return a hash table with citation references as keys and fields alist as values.
                                 (cons 'year
                                        ((consp date)
-                                        (caar date))
+                                         (let ((year (caar date)))
+                                           (cond
+                                             ((numberp year) (number-to-string year))
+                                             ((stringp year) year)
+                                             (t
+                                               (error
+                                                 "First element of CSL-JSON date-parts should be a number or string, got %s: %S"
+                                                 (type-of year) year)))))
                                        ((stringp date)

  reply	other threads:[~2022-06-20 14:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-18  6:34 oc-basic: CSL-JSON year as number vs. string (nativecomp?) David Lukeš
2022-06-19  1:44 ` Ihor Radchenko
2022-06-19  1:55   ` Bruce D'Arcus
2022-06-19  3:31     ` David Lukeš
2022-06-19 13:39       ` Bruce D'Arcus
2022-06-20 12:06         ` Ihor Radchenko
2022-06-20 13:11           ` Bruce D'Arcus
2022-06-20 14:13             ` David Lukeš [this message]
2022-06-20 14:24               ` Bruce D'Arcus
2022-06-21  3:28               ` Ihor Radchenko
2022-06-21 12:02                 ` David Lukeš
2022-07-31  4:05                   ` Ihor Radchenko
2022-06-20 12:04       ` Ihor Radchenko

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:

  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=CAEPTPExAz6TDiZQ24kobh1jQ9Jfd-BYgpz3nknFV-hUziic8QA@mail.gmail.com \
    --to=dafydd.lukes@gmail.com \
    --cc=bdarcus@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@gmail.com \


* 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


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).