forked from Juris-M/citeproc-js-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
original.txt
1935 lines (1451 loc) · 56.1 KB
/
original.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--------------
Readable Flags
--------------
The instantiated processor has several readable flags that can be used
by the calling application to shape the user interface to the
processor. These include the following: [#]_
######################
``opt.sort_citations``
######################
True if the style is one that sorts citations in any way.
############################
``opt.citation_number_sort``
############################
True if citations are sorted by citation
.. [#] Note that these are information variables intended for reading
only; changing their value directly will have no effect on the
actual behavior of the processor.
The version of the processor itself can be obtained
from the attribute ``processor_version``. The supported
CSL version can be obtained from ``csl_version``.
#####################
Configuration methods
#####################
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
General configuration methods
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
!!!!!!!!!!!!!!!!!!!!!
``setOutputFormat()``
!!!!!!!!!!!!!!!!!!!!!
The default output format of the processor is HTML. Output formats for
RTF and plain text are defined in the distribution source file
``./src/formats.js``. Additional formats can be added if desired.
See `the file itself`__ for details; it's pretty
straightforward.
__ http://bitbucket.org/fbennett/citeproc-js/src/tip/src/formats.js
The output format of the processor can be changed to any of the
defined formats after instantiation, using the ``setOutputFormat()``
command:
.. sourcecode:: js
citeproc.setOutputFormat("rtf");
!!!!!!!!!!!!!!!!!!!!!!!!!!!
``rebuildProcessorState()``
!!!!!!!!!!!!!!!!!!!!!!!!!!!
Rebuilds the processor from scratch, based on a cached list of
citation objects. In a dynamic application, once the internal state of
processor is established, citations should edited with individual
invocations of ``processCitationCluster()``.
Returns an array of ``[citationID,noteIndex,string]`` triples in
document order, where ``string`` is the fully disambiguated citation
cluster for the given document position.
.. sourcecode:: js
citeproc.rebuildProcessorState(citations, mode, uncitedItemIDs);
**citations** (object, optional)
An array of citation input objects in document order. Each
citation object must be in the following form, with correct
values for ``citationID``, for each ``id``, and for ``noteIndex``.
Set ``noteIndex`` to ``0`` for in-text citations.
Default is to return an empty document update array.
.. sourcecode:: js
{
"citationID": "CITATION-1",
"citationItems": [
{
"id": "ITEM-1"
}
],
"properties": {
"noteIndex": 1
}
}
**mode** (string, optional)
One of ``text``, ``html`` or ``rtf``. The default is ``html``.
After invocation, the processor is returned to its previous
output mode setting.
**uncitedItemIDs** (array, optional)
An array of item IDs for uncited items to be included in
the document bibliography, if any.
!!!!!!!!!!!!!!!!!!!!!!!!!!!
``restoreProcessorState()``
!!!!!!!!!!!!!!!!!!!!!!!!!!!
This function is deprecated. Use ``rebuildProcessorState()`` instead.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Multilingual configuration methods
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
``citeproc.setLangPrefsForCites()``
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This function is used in Juris-M. Pending documentation here, please
refer to the `Juris-M source code`_ for examples of its use.
.. _Juris-M source code: https://github.com/juris-m/zotero
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
``citeproc.setLangPrefsForCiteAffixes()``
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This function is used in Juris-M. Pending documentation here, please
refer to the `Juris-M source code`_ for examples of its use.
.. _Juris-M source code: https://github.com/juris-m/zotero
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
``citeproc.setLangTagsForCslTransliteration()``
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This function is used in Juris-M. Pending documentation here, please
refer to the `Juris-M source code`_ for examples of its use.
.. _Juris-M source code: https://github.com/juris-m/zotero
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
``citeproc.setLangTagsForCslTranslation()``
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This function is used in Juris-M. Pending documentation here, please
refer to the `Juris-M source code`_ for examples of its use.
.. _Juris-M source code: https://github.com/juris-m/zotero
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
``citeproc.setLangTagsForCslSort()``
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This function is used in Juris-M. Pending documentation here, please
refer to the `Juris-M source code`_ for examples of its use.
.. _Juris-M source code: https://github.com/juris-m/zotero
######################
Runtime function hooks
######################
^^^^^^^^^^^^^^^^^^^^^^^^^^
Optional ``sys`` functions
^^^^^^^^^^^^^^^^^^^^^^^^^^
!!!!!!!!!!!!!!!!!!!!!
``getAbbreviation()``
!!!!!!!!!!!!!!!!!!!!!
The optional ``getAbbreviation()`` function returns short-forms
and other transforms of field content. Its signature is as follows:
.. sourcecode:: js
citeproc.sys.getAbbreviation(
styleID,
cacheObject,
jurisdiction,
category,
key,
noHints
);
*styleID* (required)
A machine-readable identifier for the current style. This
allows the function to associate abbreviation sets with
particular styles.
*cacheObject* (object, required)
A JavaScript object from which cached values can be obtained.
Caching may be desired when very large abbreviation lists are
used.
*jurisdiction* (string, required)
Either ``default`` or, for legal resources only, a jurisdiction
code drawn from the `LegalResourceRegistry`_.
*category* (string, required)
The abbreviation category of the field to be matched. Categories
and their associated variables are as follows:
**title**
The title category includes ``genre``, ``event``, ``medium``
and ``title-short``, as well as ``title`` itself.
**collection-title**
This category includes ``archive`` in addition to
``collection-title``.
**container-title**
Only the ``container-title`` variable itself is in this category.
**place**
Place variables are: ``publisher-place``, ``event-place``,
``jurisdiction``, ``archive-place``, ``language-name``,
``language-name-original``.
**institution-part**
Institution names in Juris-M may contain multiple elements,
separated by a pipe (aka field separator) ``|``. Individual
elements of any institution name are in this category, which
in Juris-M includes the ``publisher`` and ``authority`` variables.
**institution-entire**
The full form of Juris-M institution names is in this category.
**number**
All number variables. In standard CSL these are
``chapter-number``, ``collection-number``, ``edition``,
``issue``, ``number``, ``number-of-pages``,
``number-of-volumes``, ``volume`` and ``number``. In Juris-M,
the following are also numbers: ``call-number``, ``page``,
``page-first``, ``supplement``,
``publication-number``. Abbreviation is attempted only when
the variable content tests ``false`` for CSL ``is-numeric``.
*key* (string, required)
The field content to be abbreviated.
*noHints* (boolean, required)
The function may propose abbreviated forms for newly-encountered
keys, using a list of words and phrases. When this toggle is set
to ``true``, this "hinted" abbreviation is suppressed. The processor
sets this toggle on titles and short titles of non-legal items.
.. _LegalResourceRegistry: http://fbennett.github.io/legal-resource-registry/
!!!!!!!!!!!!!!!!!!!!!!
``sys.getHumanForm()``
!!!!!!!!!!!!!!!!!!!!!!
This function is used in Juris-M. Pending documentation here, please
refer to the `Juris-M source code`_ for examples of its use.
.. _Juris-M source code: https://github.com/juris-m/zotero
!!!!!!!!!!!!!!!!!!!!!!!!!
``sys.getLanguageName()``
!!!!!!!!!!!!!!!!!!!!!!!!!
This function is used in Juris-M. Pending documentation here, please
refer to the `Juris-M source code`_ for examples of its use.
.. _Juris-M source code: https://github.com/juris-m/zotero
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Legal configuration methods
^^^^^^^^^^^^^^^^^^^^^^^^^^^
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
``citeproc.setSuppressedJurisdictions()``
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This function is used in Juris-M. Pending documentation here, please
refer to the `Juris-M source code`_ for examples of its use.
.. _Juris-M source code: https://github.com/juris-m/zotero
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
``citeproc.retrieveStyleModule()``
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This function is used in Juris-M. Pending documentation here, please
refer to the `Juris-M source code`_ for examples of its use.
.. _Juris-M source code: https://github.com/juris-m/zotero
##############################
Loading items to the processor
##############################
^^^^^^^^^^^^^^^^^
``updateItems()``
^^^^^^^^^^^^^^^^^
Before citations or a bibliography can be generated, an ordered list
of reference items must ordinarily be loaded into the processor using
the ``updateItems()`` command, as shown below. This command takes a
list of item IDs as its sole argument, and will reconcile the internal
state of the processor to the provided list of items, making any
necessary insertions and deletions, and making any necessary
adjustments to internal registers related to disambiguation and so
forth.
.. admonition:: Hint
The sequence in which items are listed in the
argument to ``updateItems()`` will ordinarily be reflected in the ordering
of bibliographies only if the style installed in the processor
does not impose its own sort order.
.. sourcecode:: js
var my_ids = [
"ID-1",
"ID-53",
"ID-27"
]
citeproc.updateItems( my_ids );
To suppress sorting, give a second argument to the command
with a value of ``true``.
.. sourcecode:: js
citeproc.updateItems(my_ids, true);
Note that only IDs may be used to identify items. The ID is an
arbitrary, system-dependent identifier, used by the locally customized
``retrieveItem()`` method to retrieve
actual item data.
^^^^^^^^^^^^^^^^^^^^^^^^
``updateUncitedItems()``
^^^^^^^^^^^^^^^^^^^^^^^^
The ``updateUncitedItems()`` command has the same interface
as ``updateItems()`` (including the option to suppress sorting
by the style), but the reference items it adds are
not subject to deletion when no longer referenced by a
cite anywhere in the document.
#########################
Generating bibliographies
#########################
^^^^^^^^^^^^^^^^^^^^^^
``makeBibliography()``
^^^^^^^^^^^^^^^^^^^^^^
The ``makeBibliography()`` command does what its name implies.
If invoked without an argument,
it dumps a formatted bibliography containing all items currently
registered in the processor:
.. sourcecode:: js
var mybib = citeproc.makeBibliography();
.. _`commands-categories`:
.. admonition:: Important
Matches against the content of name and date variables
are not possible, but empty fields can be matched for all
variable types. See the ``quash`` example below
for details.
!!!!!!!!!!!!
Return value
!!!!!!!!!!!!
The value returned by this command is a two-element list, composed of
a JavaScript array containing certain formatting parameters, and a
list of strings representing bibliography entries. It is the responsibility
of the calling application to compose the list into a finish string
for insertion into the document. The first
element —- the array of formatting parameters —- contains the key/value
pairs shown below (the values shown are the processor defaults in the
HTML output mode):
.. sourcecode:: js
[
{
maxoffset: 0,
entryspacing: 0,
linespacing: 0,
hangingindent: 0,
second-field-align: false,
bibstart: "<div class=\"csl-bib-body\">\n",
bibend: "</div>",
bibliography_errors: []
},
[
"<div class=\"csl-entry\">Book A</div>",
"<div class=\"csl-entry\">Book C</div>"
]
]
*maxoffset*
Some citation styles apply a label (either a number or an
alphanumeric code) to each bibliography entry, and use this label
to cite bibliography items in the main text. In the bibliography,
the labels may either be hung in the margin, or they may be set
flush to the margin, with the citations indented by a uniform
amount to the right. In the latter case, the amount of indentation
needed depends on the maximum width of any label. The
``maxoffset`` value gives the maximum number of characters that
appear in any label used in the bibliography. The client that
controls the final rendering of the bibliography string should use
this value to calculate and apply a suitable indentation length.
*entryspacing*
An integer representing the spacing between entries in the bibliography.
*linespacing*
An integer representing the spacing between the lines within
each bibliography entry.
*hangingindent*
The number of em-spaces to apply in hanging indents within the
bibliography.
*second-field-align*
When the ``second-field-align`` CSL option is set, this returns
either "flush" or "margin". The calling application should
align text in bibliography output as described in the `CSL specification`__.
Where ``second-field-align`` is not set, this return value is set to ``false``.
*bibstart*
A string to be appended to the front of the finished bibliography
string.
*bibend*
A string to be appended to the end of the finished bibliography
string.
__ http://citationstyles.org/downloads/specification.html#bibliography-specific-options
!!!!!!!!!!!!!!!!
Selective output
!!!!!!!!!!!!!!!!
The ``makeBibliography()`` command accepts one optional argument,
which is a nested JavaScript object that may contain
*one of* the objects ``select``, ``include`` or ``exclude``, and
optionally an additional ``quash`` object. Each of these four objects
is an array containing one or more objects with ``field`` and ``value``
attributes, each with a simple string value (see the examples below).
The matching behavior for each of the four object types, with accompanying
input examples, is as follows:
``select``
For each item in the bibliography, try every match object in the array against
the item, and include the item if, and only if, *all* of the objects match.
.. admonition:: Hint
The target field in the data items registered in the processor
may either be a string or an array. In the latter case,
an array containing a value identical to the
relevant value is treated as a match.
.. sourcecode:: js
var myarg = {
"select" : [
{
"field" : "type",
"value" : "book"
},
{ "field" : "categories",
"value" : "1990s"
}
]
}
var mybib = cp.makeBibliography(myarg);
``include``
Try every match object in the array against the item, and include the
item if *any* of the objects match.
.. sourcecode:: js
var myarg = {
"include" : [
{
"field" : "type",
"value" : "book"
}
]
}
var mybib = cp.makeBibliography(myarg);
``exclude``
Include the item if *none* of the objects match.
.. sourcecode:: js
var myarg = {
"exclude" : [
{
"field" : "type",
"value" : "legal_case"
},
{
"field" : "type",
"value" : "legislation"
}
]
}
var mybib = cp.makeBibliography(myarg);
``quash``
Regardless of the result from ``select``, ``include`` or ``exclude``,
skip the item if *all* of the objects match.
.. admonition:: Hint
An empty string given as the field value will match items
for which that field is missing or has a nil value.
.. sourcecode:: js
var myarg = {
"include" : [
{
"field" : "categories",
"value" : "classical"
}
],
"quash" : [
{
"field" : "type",
"value" : "manuscript"
},
{
"field" : "issued",
"value" : ""
}
]
}
var mybib = cp.makeBibliography(myarg);
###################
Output of citations
###################
The available citation commands are:
* `appendCitationCluster()`_
* `processCitationCluster()`_
* `previewCitationCluster()`_
Citation commands generate strings for insertion into the text of a
target document. Citations can be added to a document in one of two
ways: as a batch process (BibTeX, for example, works in this way) or
interactively (Endnote, Mendeley and Zotero work in this way, through
a connection to the user's word processing software). These two modes
of operation are supported in ``citeproc-js`` by two separate
commands, respectively ``appendCitationCluster()``, and
``processCitationCluster()``. [#]_
The ``appendCitationCluster()`` and
``processCitationCluster()`` commands use a similar input format
for citation data, which is described below in the `Data Input`_
→ `Citation data object`_ section below.
.. [#] A third, simpler command (``makeCitationCluster()``), is not
covered by this manual. It is primarily useful as a tool for
testing the processor, as it lacks any facility for position
evaluation, which is needed in production environments.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``processCitationCluster()``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``processCitationCluster()`` command is used to generate and
maintain citations dynamically in the text of a document. It takes three
arguments: a citation object, a list of citation ID/note index pairs
representing existing citations that precede the target citation, and
a similar list of pairs for citations coming after the target. Like
the ``appendCitationCluster()`` command run without a flag, its
return value is an array of two elements: a data object, and
an array of one or more index/string pairs, one for each citation
affected by the citation edit or insertion operation. As shown below,
the data object currently has a single boolean value, ``bibchange``,
which indicates whether the document bibliography is in need of
refreshing as a result of the ``processCitationCluster()`` operation.
.. sourcecode:: js
var citationsPre = [ ["citation-abc",1], ["citation-def",2] ];
var citationsPost = [ ["citation-ghi",4] ];
citeproc.processCitationCluster(citation,citationsPre,citationsPost);
...
[
{
"bibchange": true
},
[
[ 1,"(Ronald Snoakes 1950)" ],
[ 3,"(Richard Snoakes 1950)" ]
]
]
A worked example showing the result of multiple transactions can be
found in the `processor test suite`__.
__ http://bitbucket.org/bdarcus/citeproc-test/src/tip/processor-tests/humans/integration_IbidOnInsert.txt
^^^^^^^^^^^^^^^^^^^^^^^^^^^
``appendCitationCluster()``
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``appendCitationCluster()`` command takes a single citation
object as argument, and an optional flag to indicate whether
a full list of bibliography items has already been registered
in the processor with the ``updateItems()`` command. If the flag
is true, the command should return an array containing exactly
one two-element array, consisting of the current index position
as the first element, and a string for insertion into the document
as the second. To wit:
.. sourcecode:: js
citeproc.appendCitationCluster(mycitation,true);
[
[ 5, "(J. Doe 2000)" ]
]
If the flag is false, invocations of the command may return
multiple elements in the list, when the processor sense that
the additional bibliography items added by the citation require
changes to other citations to achieve disambiguation. In this
case, a typical return value might look like this:
.. sourcecode:: js
citeproc.appendCitationCluster(mycitation);
[
[ 2, "(Jake Doe 2000)" ],
[ 5, "(John Doe 2000)" ]
]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``previewCitationCluster()``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``previewCitationCluster()`` command takes the same arguments
as ``processCitationCluster()``, plus a flag to indicate the
output mode.
The return value is a string representing the
citation as it would be rendered in the specified context. This command
will preview citations
exactly as they will appear in the document, and will have no
effect on processor state: the next edit will return updates
as if the preview command had not been run.
.. sourcecode:: js
var citationsPre = [ ["citation-abc",1], ["citation-def",2] ];
var citationsPost = [ ["citation-ghi",4] ];
citeproc.previewCitationCluster(citation,citationsPre,citationsPost,"html");
...
"(Richard Snoakes 1950)"
####################################
Handling items with no rendered form
####################################
The processor might fail to produce meaningful rendered output in three
situations:
1. When `makeBibliography()`_ is run,
and the configured style contains no ``bibliography`` node;
2. When `makeBibliography()`_ is run, and no variable other than
``citation-number`` produces output for an individual entry; or
3. When a `citation command`__ is used, but no element rendered for a
particular cite produces any output.
__ `Output of citations`_
The processor handles these three cases as described below.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No ``bibliography`` node in style
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When the `makeBibliography()`_ command is run on a style
that has no ``bibliography`` node, the command returns
a value of ``false``.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No item output for bibliography entry
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When the return value of the `makeBibliography()`_ command contains
entries that produce no output other than for the (automatically
generated) ``citation-number`` variable, an error object with
ID and position information on the offending entry,
and a bitwise error code (always CSL.ERROR_NO_RENDERED_FORM, currently)
is pushed to the ``bibliography_errors`` array in the data segment of the
return object:
.. sourcecode:: js
[
{
maxoffset: 0,
entryspacing: 0,
linespacing: 0,
hangingindent: 0,
second-field-align: false,
bibstart: "<div class=\"csl-bib-body\">\n",
bibend: "</div>",
bibliography_errors: [
{
index: 2,
itemID: "ITEM-2",
error_code: CSL.ERROR_NO_RENDERED_FORM
}
]
},
[
"[1] Snoakes, Big Book (2000)",
"[2] Doe, Bigger Book (2001)",
"[3] ",
"[4] Roe, Her Book (2002)"
]
]
The calling application may use the information in ``bibliography_errors``
to prompt the user concerning possible corrective action.
^^^^^^^^^^^^^^^^^^^^^^
No output for citation
^^^^^^^^^^^^^^^^^^^^^^
When a citation processing command produces no output for a citation,
an error object with ID and position information on the offending
cite, and a bitwise error code (always
``CSL.ERROR_NO_RENDERED_FORM``, currently) is pushed to the
``citation_errors`` array in the data segment of the return object.
Note that ``previewCitationCluster()`` returns only a string value,
with no data segment; citation errors are not available with this
command.
.. sourcecode:: js
[
{
bibchange: true,
citation_errors: [
{
citationID: "citationID_12345",
index: 4,
noteIndex: 3, // for example
itemID: "itemID_67890",
citationItem_pos: 0,
error_code: CSL.ERROR_NO_RENDERED_FORM
}
]
},
[
[ 1,"(Ronald Snoakes 1950)" ],
[ 4,"[CSL STYLE ERROR: reference with no printed form.]" ],
[ 5,"(Richard Snoakes 1950)" ]
]
]
----------
Data Input
----------
###########
Item fields
###########
The locally defined ``retrieveItem()`` function must return data
for the target item as a simple JavaScript array containing recognized
CSL fields. [#]_ The layout of the three field types is described below.
^^^^^^^^^^^^^^^^^^^^^^^^^^
Text and numeric variables
^^^^^^^^^^^^^^^^^^^^^^^^^^
Text and numeric variables are not distinguished in the data layer; both
should be presented as simple strings.
.. sourcecode:: js
{ "title" : "My Anonymous Life",
"volume" : "10"
}
.. _clean-names:
^^^^^
Names
^^^^^
When present in the item data, CSL name variables must
be delivered as a list of JavaScript arrays, with one
array for each name represented by the variable.
Simple personal names are composed of ``family`` and ``given`` elements,
containing respectively the family and given name of the individual.
.. sourcecode:: js
{ "author" : [
{ "family" : "Doe", "given" : "Jonathan" },
{ "family" : "Roe", "given" : "Jane" }
],
"editor" : [
{ "family" : "Saunders",
"given" : "John Bertrand de Cusance Morant" }
]
}
Institutional and other names that should always be presented
literally (such as "The Artist Formerly Known as Prince",
"Banksy", or "Ramses IV") should be delivered as a single
``literal`` element in the name array:
.. sourcecode:: js
{ "author" : [
{ "literal" : "Society for Putting Things on Top of Other Things" }
]
}
!!!!!!!!!!!!!!!!!!!!
Names with particles
!!!!!!!!!!!!!!!!!!!!
Name particles, such as the "von" in "Werner von Braun", can
be delivered separately from the family and given name,
as ``dropping-particle`` and ``non-dropping-particle`` elements.
.. sourcecode:: js
{ "author" : [
{ "family" : "Humboldt",
"given" : "Alexander",
"dropping-particle" : "von"
},
{ "family" : "Gogh",
"given" : "Vincent",
"non-dropping-particle" : "van"
},
{ "family" : "Stephens",
"given" : "James",
"suffix" : "Jr."
},
{ "family" : "van der Vlist",
"given" : "Eric"
}
]
}
!!!!!!!!!!!!!!!!!!!!!!!
Names with an articular
!!!!!!!!!!!!!!!!!!!!!!!
Name suffixes such as the "Jr." in "Frank Bennett, Jr." and the "III"
in "Horatio Ramses III" can be delivered as a ``suffix`` element.
.. admonition:: Hint
A simplified format for delivering particles and name suffixes
to the processor is described below in the section
`Dirty Tricks`_ → `Input data rescue`_ → `Names`__.
__ `dirty-names`_
.. sourcecode:: js
{ "author" : [
{ "family" : "Bennett",
"given" : "Frank G.",
"suffix" : "Jr.",
"comma-suffix": "true"
},
{ "family" : "Ramses",
"given" : "Horatio",
"suffix" : "III"
}
]
}
Note the use of the ``comma-suffix`` field in the example above. This
hint must be included for suffixes that are preceded by a comma, which
render differently from "ordinary" suffixes in the ordinary long
form.
.. _`input-byzantine`:
!!!!!!!!!!!!!!!!!!!!!
"non-Byzantine" names
!!!!!!!!!!!!!!!!!!!!!
Names not written in the Latin or Cyrillic
scripts [#]_ are always displayed
with the family name first. No special hint is needed in
the input data; the processor is sensitive to the character
set used in the name elements, and will handle such names
appropriately.
.. sourcecode:: js
{ "author" : [
{ "family" : "村上",
"given" : "春樹"
}
]
}
.. admonition:: Hint
When the romanized transliteration is selected from a multilingual
name field, the ``static-ordering`` flag is not required. See the section
`Dirty Tricks`_ → `Multilingual content`_ below for further details.
Sometimes it might be desired to handle a Latin or Cyrillic
transliteration as if it were a fixed (non-Byzantine) name. This
behavior can be prompted by including a ``static-ordering`` element in
the name array. The actual value of the element is irrelevant, so
long as it returns true when tested by the JavaScript interpreter.
.. sourcecode:: js
{ "author" : [
{ "family" : "Murakami",
"given" : "Haruki",
"static-ordering" : 1
}
]
}
.. _`input-dates`:
^^^^^
Dates
^^^^^
Date fields are JavaScript objects, within which the "date-parts" element
is a nested JavaScript array containing a start
date and optional end date, each of which consists of a year,
an optional month and an optional day, in that order if present.
.. admonition:: Hint