Zotero and citeproc-js

20 views
Skip to first unread message

Simon Kornblith

unread,
May 30, 2010, 7:45:25 AM5/30/10
to citeproc-js
I just committed a patch to integrate citeproc-js into Zotero. At the
moment, it is not very well tested, but it (mostly works). There is,
however, are a couple of issues I have run into that needs further
investigation.

I'm still not sure what I'm supposed to be doing with updateItems().
It seems that processCitationCluster() will not automatically delete
items that are no longer cited from the bibliography, so it needs to
be called at some point with each document update. Currently, I call
processCitationCluster() for each new/changed citation upon document
update, then call updateItems() at the end to add user-specified items
that are not cited in the text but should be cited in the
bibliography, and remove items that were cited in the document on the
previous update but are no longer there. This appears to work well
when I use the Chicago styles, but produces an error
(state.registry.registry[Item.id] is undefined) at node-key.js:102
when I use IEEE. If I instead call updateItems() before
processCitationCluster(), the IEEE style works, but I get an error
(this.namereg[pkey] is undefined) at disambig_names.js:68 with the
Chicago style. Unfortunately, I don't know enough about the innards of
citeproc-js to know what these errors mean.

Additionally, all of my punctuation is ending up outside the quotes in
the Chicago Full Note with Bibliography style, although that's
probably my fault.

Finally, is there a way to disable sorting of specific citation
clusters, a feature that Zotero previously provided via a checkbox in
the add citation dialog?

Let me know if you have any insights into what's going on here.

Thanks,
Simon

Frank Bennett

unread,
May 30, 2010, 11:05:08 AM5/30/10
to citeproc-js
On May 30, 8:45 pm, Simon Kornblith <si...@simonster.com> wrote:
> I just committed a patch to integrate citeproc-js into Zotero. At the  
> moment, it is not very well tested, but it (mostly works). There is,  
> however, are a couple of issues I have run into that needs further  
> investigation.
>
> I'm still not sure what I'm supposed to be doing with updateItems().  
> It seems that processCitationCluster() will not automatically delete  
> items that are no longer cited from the bibliography, so it needs to  
> be called at some point with each document update. Currently, I call

The deletes are meant to happen automatically, so there's something
amiss in the processor. I'll do some testing tomorrow and report
back.

Frank Bennett

unread,
May 30, 2010, 11:38:47 AM5/30/10
to citeproc-js
(In my last mail, I should have mentioned what a great thing it is to
see the
processor running in Zotero. This really is wonderful.)

The errors suggest a call to an item that is unknown to the
processor's
internal registry. The registry should be maintained by
processCitationCluster().
updateItems() should be needed only for adjusting the list of uncited
items;
it shouldn't be necessary to call it after every citation operation.

I've built a couple of tests to get started exploring this, which I've
just
checked in. The bugreports_AutomaticallyDeleteItemsFails.txt test
sets
a three-cite citation, then reduces it to two. Only the two remaining
items
turn up in the bibliography, so I'm puzzled why things are not
deleting
properly for you.

For an initial question, do your trials involve uncited items (i.e.
items in the
bibliography only), or are they based on cited items only?

>
> > Additionally, all of my punctuation is ending up outside the quotes in  
> > the Chicago Full Note with Bibliography style, although that's  
> > probably my fault.

CSL controls that. The default is punctuation-in-quote="false", so if
the option
isn't set, that sounds like the normal behavior.

>
> > Finally, is there a way to disable sorting of specific citation  
> > clusters, a feature that Zotero previously provided via a checkbox in  
> > the add citation dialog?

Not yet, but there will be soon.

Rintze Zelle

unread,
May 30, 2010, 12:14:28 PM5/30/10
to citep...@googlegroups.com
On Sun, May 30, 2010 at 5:38 PM, Frank Bennett <bierc...@gmail.com> wrote:
> > Additionally, all of my punctuation is ending up outside the quotes in  
> > the Chicago Full Note with Bibliography style, although that's  
> > probably my fault.

CSL controls that.  The default is punctuation-in-quote="false", so if
the option
isn't set, that sounds like the normal behavior.

More specifically, punctuation-in-quote is set in the locales files. See http://citationstyles.org/downloads/specification.html#localized-options and, for an example, http://bitbucket.org/bdarcus/csl-locales/src/tip/trunk/locales-en-US.xml.

Rintze

Simon Kornblith

unread,
May 30, 2010, 3:18:43 PM5/30/10
to citep...@googlegroups.com


You're right, updating via processCitationCluster() does seem to
automatically delete items (I think that the previous issue was due to
a bug in my code), and updateUncitedItems() works for the uncited
entries, so I can get rid of the updateItems() calls altogether. Now
my only issues are the aforementioned error at node-key.js:102, which
appears when calling processCitationCluster() with a new citation
cluster with multiple items in IEEE (but not Chicago), and some weird
problems with et al. handling/disambiguation that I still need to get
a good test case for.

Simon

Frank Bennett

unread,
May 30, 2010, 7:42:31 PM5/30/10
to citeproc-js
A bit of progress on this. I've ferreted out the data from a call in
the browser, and set it up in the test bed. It runs fine, so the data
itself isn't the problem. But in the browser installation,
registry.init() is not being run to insert the items into the internal
registry of items, while in the test bed, it is. This certainly looks
like the source of the trouble. My test bed must be doing a safety-
catch run of updateItems(), which masked this bug from view.

Should have a fix, or an update to the manual that addresses the
issue, in a day or two.

Frank

Frank Bennett

unread,
May 31, 2010, 4:29:55 AM5/31/10
to citeproc-js
The changesets for the just-pushed 1.0.7 release should address the
problem with first-reference multiple citations in IEEE.

Frank

Frank Bennett

unread,
May 31, 2010, 9:08:36 PM5/31/10
to citeproc-js
Er, for posterity, that should have been 1.0.17. Sorry for the extra
traffic.

Frank Bennett

unread,
Jun 5, 2010, 4:13:53 AM6/5/10
to citeproc-js
On May 31, 12:38 am, Frank Bennett <biercena...@gmail.com> wrote:
> On May 31, 12:05 am, Frank Bennett <biercena...@gmail.com> wrote:
[snip]
> > > Finally, is there a way to disable sorting of specific citation  
> > > clusters, a feature that Zotero previously provided via a checkbox in  
> > > the add citation dialog?
>
> Not yet, but there will be soon.

I've looked into this, and unless I'm missing something, it's no
longer required. The explanation is below, following a listing-up of
relevant sources.

***
Sources
***
The original sortCitation() function went in with #1669 on 28 August
2007:

https://www.zotero.org/trac/browser/extension/branches/1.0/chrome/content/zotero/addCitationDialog.js?rev=1669

I found two threads of discussion, started in February and in April of
2008:

http://forums.zotero.org/discussion/2251/ooo-citation-removereorder-items-from-multiple-sources/
http://forums.zotero.org/discussion/2748/word-plugin-failing-to-correctly-sort-edited-multiple-citations/

In response, Trevor filed two tickets, one of which was later changed
from "Toggle alphabetization on and off in multiple source citations"
to "Ability to re-order citations":

https://www.zotero.org/trac/ticket/1001
https://www.zotero.org/trac/ticket/1002

***
Explanation
***

Three separate issues tended to get tangled up together in the
discussions:

(1) the UI ordering of multiple cites (as entered by the user);
(2) the sorting or non-sorting of references in style output; and
(3) the re-sorting of items following an edit.

The gist of the discussions, though, appears to have centered on two
general requests:

(a) When sorting (or re-sorting) failed, users wanted to have manual
control, through the plugin UI, so that they could fix things up by
hand; and

(b) In styles that do not sort citations, some users wanted a
convenient means of changing the order of references.

****
Issue (a)
****

In Zotero 1.0 and 2.0, the UI ordering (1) and the ordering in style
output (2) seem to have been determined by the same internal array,
and (if I understand things correctly?) un-ticking the "Keep Sources
Sorted" selection allowed whatever sequence the user set in the UI to
feed into the style output for that citation. The tick-box seems to
have provided a way of fixing up citation ordering in the event of
sorting failulre or breakage, as noted in one of the threads as
recently as two days ago:

http://forums.zotero.org/discussion/2748/word-plugin-failing-to-correctly-sort-edited-multiple-citations/#Comment_63157

The workaround using the tick-box isn't needed, though, if the
citaition sort required by the style always comes out correctly. As
far as I can tell, in citeproc-js, it does.

If users come up with a need to exceptionally suspend sorting for
individual citations in a style that normally requires it, it's easy
enough to add this. But that issue doesn't seem to be raised by the
threads linked above.

****
Issue (b)
****

The demand for a means of re-ordering cites in a multiple citation is
a separate thing, and the current 2.1a1 implementation will make it
easier to implement, because the ordering in the UI (1) is now
separated from the ordering in the styled output (2) --- even in a
style that sorts citations, the UI ordering will not change, and it
can be reshuffled freely with no effect on the citations that show
through in the document.

***
To sum up ...
***

I think if the "Keep Sources Cited" tick-box is eliminated, and re-
ordering of cites in the UI is implemented, users will have no
complaints.

Apologies for the long note, but I think that's the whole memo on this
one -- the aim of the above is to try and save you some time by
pulling the various threads (ah, pun) together in one place.

Frank

Simon Kornblith

unread,
Jun 5, 2010, 6:11:23 PM6/5/10
to citep...@googlegroups.com


There are no threads complaining about the absence of a "Keep Sources
Cited" box because it was always there, so users never had a chance to
complain that it wasn't. We hope to provide a better UI for reordering
references in citations (which is long due), but there definitely
needs to be a way to override the default sort. In APA, references in
citations are supposed to be sorted in the same order they appear in
the reference list, but when prefixes are involved, e.g., for a
citation like

(Minor, 2001; see also Adams, 1999; Storandt, 2007)

sorting this way will not suffice. It would be great if we could avoid
making users edit these citations manually.

Simon

Frank Bennett

unread,
Jun 5, 2010, 6:28:02 PM6/5/10
to citeproc-js
On Jun 6, 7:11 am, Simon Kornblith <si...@simonster.com> wrote:
> On Jun 5, 2010, at 1:13 AM, Frank Bennett wrote:
>
>
>
> > On May 31, 12:38 am, Frank Bennett <biercena...@gmail.com> wrote:
> >> On May 31, 12:05 am, Frank Bennett <biercena...@gmail.com> wrote:
> > [snip]
> >>>> Finally, is there a way to disable sorting of specific citation
> >>>> clusters, a feature that Zotero previously provided via a  
> >>>> checkbox in
> >>>> the add citation dialog?
>
> >> Not yet, but there will be soon.
>
> > I've looked into this, and unless I'm missing something, it's no
> > longer required.  The explanation is below, following a listing-up of
> > relevant sources.
>
> > ***
> > Sources
> > ***
> > The original sortCitation() function went in with #1669 on 28 August
> > 2007:
>
> >https://www.zotero.org/trac/browser/extension/branches/1.0/chrome/con...
>
> > I found two threads of discussion, started in February and in April of
> > 2008:
>
> >http://forums.zotero.org/discussion/2251/ooo-citation-removereorder-i...
> >http://forums.zotero.org/discussion/2748/word-plugin-failing-to-corre...
> >http://forums.zotero.org/discussion/2748/word-plugin-failing-to-corre...
Ah, got it. I'll add a toggle to citeproc-js to allow override of the
citation sort. It shouldn't affect the cite reordering code that I
just filed.

>
> Simon

Frank Bennett

unread,
Jun 5, 2010, 10:14:33 PM6/5/10
to citeproc-js
That was quick! I see that you'll need a smarter flag to set
io.sortable from. It's a little tricky, since a sort on citation-
number sometimes means in-document reference order, and sometimes not,
depending on what's done to sort the bibliography. Errands and other
work are calling today, but I'll come up with a flag you can rely on
tomorrow.

Frank

>
>
>
> > Simon
Reply all
Reply to author
Forward
0 new messages