-
Notifications
You must be signed in to change notification settings - Fork 0
/
unsrt_bst.rb
937 lines (847 loc) · 20.4 KB
/
unsrt_bst.rb
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
# coding: utf-8
#
# plain_bst.rb - RubyBTeX plain style file
#
# Copyright (c) 2014 Kazuto Tominaga
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
require_relative 'rubybsup.rb'
=begin
--- $entrytypes
Types of entries in .bib files. Any type can be added,
but it is better to stick to the standard entry types.
=end
$entrytypes = [ 'article', 'book', 'booklet', 'conference',
'inbook', 'incollection', 'inproceedings', 'manual', 'mastersthesis',
'misc', 'phdthesis', 'proceedings', 'techreport', 'unpublished' ]
=begin
--- $styles
Style definitions. The string for an entry type defines
the output format. It is a Ruby's double-quoted string,
so special sequences such as \n and #{...} are processed
by the Ruby interpreter, and the result is output.
Besides that, the following two types of sequences are
handled in special ways.
: (:<Part A>[:<Part B>:]<Part C>:)
This substring makes a call to the function named "f_<Part B>".
For example, (:[:c_title:]:) calls the function f_c_title.
These f_ functions must be defined in the class Formatter,
which is defined in this file. <Part B> can have an asterisk
at the end: it means that the field is optional; otherwise,
the field is required. This only affects whether to show
warning messages or not.
The call to the f_ function results in two cases.
* The call returned nil.
In this case, the substring is replaced with
the empty string (""). If the field is required,
a warning message is displayed.
* The call returned a non-nil string, say, <String>.
In this case, the substring is replaced with
<Part A><String><Part B>.
No nesting is allowed other than the form "(: [: :] :)".
The order of calling functions is not defined.
: . (period)
After all the replacements are done, periods are processed.
This period adds '.' to the preceding string if it does not
end with a period. Suppose the format string is "(:[:name:]:).".
If f_name returns "Kay Tom", the string becomes "Kay Tom.".
If f_name returns "Tom, K.", the string becomes "Tom, K.".
Writing "\." avoids this processing.
Style processing requires that curly braces are balanced.
(It handles escaping by backslash, so "{\{}" is valid.)
Hints for writing a style definition:
* Starting from required fields is an easy way.
* Separators such as commas usually go well when they are
included in optional fields.
* It's difficult to handle cases where required fields are
missing; better to compromise.
=end
$styles['article'] = "(:[:author_or_journal:]:).\n" +
"(:\\newblock [:c_title*:].\n:)" +
"(:\\newblock [:articleoptions*:],\n:)" +
"\\newblock (:[:month*:] :)(:[:year:]:).\n" +
"(:\\newblock [:note*:].\n:)"
$styles['book'] = "(:[:author_editor:]:).\n" +
"\\newblock (:\\emph{[:title:]}:)(:, [:bookoptions*:]:).\n" +
"\\newblock (:[:publisher:]:)(:, [:address*:]:)" +
"(:, [:edition*:] edition:), (:[:month*:] :)(:[:year:]:).\n" +
"(:\\newblock [:note*:].\n:)"
$styles['booklet'] = "(:[:author_or_c_title:]:).\n" +
"(:\\newblock [:c_title_ifauthor*:].\n:)" +
"(:\\newblock [:bookletoptions*:].\n:)" +
"(:\\newblock [:note*:].\n:)"
$styles['inbook'] = "(:[:author_editor:]:).\n" +
"\\newblock (:\\emph{[:title:]}:)(:, [:vnseries_ifvn*:]:)" +
"(:, [:chapter_pp_pages:]:)(:. \\emph{[:series_ifnovn*:]}:).\n" +
"\\newblock (:[:publisher:]:)(:, [:address*:]:)(:, [:edition*:] edition:), " +
"(:[:month*:] :)(:[:year:]:).\n" +
"(:\\newblock [:note*:].\n:)"
$styles['incollection'] = "(:[:author:]:).\n" +
"\\newblock (:[:c_title:]:).\n" +
"\\newblock In (:[:editor*:], :)(:\\emph{[:booktitle:]}:)(:, [:volume_number_series*:]:)" +
"(:, [:chapter_pp_pages*:]:).\n" +
"\\newblock (:[:publisher:]:)(:, [:address*:]:)(:, [:edition*:] edition:), " +
"(:[:month*:] :)(:[:year:]:).\n" +
"(:\\newblock [:note*:].\n:)"
$styles['inproceedings'] = "(:[:author:]:).\n" +
"\\newblock (:[:c_title:]:).\n" +
"\\newblock In (:[:editor*:], :)(:\\emph{[:booktitle:]}:)(:, [:volume_number_series*:]:)" +
"(:, [:pp_pages*:]:)(:, [:address*:]:), (:[:month*:] :)(:[:year:]:).\n" +
"(:\\newblock [:organization_publisher*:].\n:)" +
"(:\\newblock [:note*:].\n:)"
$styles['manual'] = "(:[:author_or_title:]:).\n" +
"(:\\newblock \\emph{[:title_ifauthor*:]}.\n:)" +
"(:\\newblock [:manualoptions*:].\n:)" +
"(:\\newblock [:note*:].\n:)"
$styles['mastersthesis'] = "(:[:author:]:).\n" +
"\\newblock (:[:c_title:]:).\n" +
"\\newblock (:[:mastersthesistype:]:), (:[:school:]:)(:, [:address*:]:), " +
"(:[:month*:] :)(:[:year:]:)." +
"(:\\newblock [:note*:].\n:)"
$styles['misc'] = "(:[:author_or_title*:]:)(:[:period_ifat*:]\n:)" +
"(:\\newblock [:title_ifauthor*:].\n:)" +
"(:\\newblock [:miscoptions*:].\n:)" +
"(:\\newblock [:note*:].\n:)"
$styles['phdthesis'] = "(:[:author:]:).\n" +
"\\newblock (:\\emph{[:title:]}:).\n" +
"\\newblock (:[:phdthesistype:]:), (:[:school:]:)(:, [:address*:]:), " +
"(:[:month*:] :)(:[:year:]:).\n" +
"(:\\newblock [:note*:].:)"
$styles['proceedings'] = "(:[:editor_or_organization_or_title:]:).\n" +
"\\newblock (:\\emph{[:title_ifeoro*:]}, :)" +
"(:[:volume_number_series*:], :)(:[:address*:], :)(:[:month*:] :)(:[:year:]:).\n" +
"(:\\newblock [:proceedingsoptions*:].\n:)" +
"(:\\newblock [:note*:].\n:)"
$styles['techreport'] = "(:[:author:]:).\n" +
"\\newblock (:[:c_title:]:).\n" +
"\\newblock (:[:techreporttype:]:)(: [:number*:]:)(:, [:institution:]:)(:, [:address*:]:), " +
"(:[:month*:] :)(:[:year:]:).\n" +
"(:\\newblock [:note*:].\n:)"
$styles['unpublished'] = "(:[:author:]:).\n" +
"\\newblock (:[:c_title:]:).\n" +
"\\newblock (:[:note:]:)(:, [:month_year*:]:).\n"
# XXX: cross reference entries
$styles['inbook_xref'] = "(:[:author_xref:]:) (:([:year_xref:]):).\n" +
"\\newblock (:[:title:]:)(: ([:chapter_pages:]):).\n" +
"\\newblock In (:[:xrefcite:]:).\n"
=begin
--- namestyle, andspec
namestyle and andspec are parameters for NameFormatter#format_names.
namestyle specifies how the names shall be formatted, and
andspec specifies the style for using "and" before the last author name.
An element of a namestyle is of the form
"(:<Part A>[:<NameSpec>|<AbbrevLetter>|<Space>:]<Part C>:)".
<NameSpec> specifies what part of the name shall appear in what form,
and is one of the following. Please see the BibTeX document(*1) for terminology.
(*1) Oren Patashnik: Helpful Hints, section 4 of BibTeXing. February 1988.
*ff: The First part.
*f: Initial of the First part.
*vv: The von part.
*v: Initial of the von part.
*ll: The Last part.
*l: Initial of the Last part.
*jj: The Jr part.
*j: Initial of the Jr part.
<AbbrevLetter> is a letter to mean that the name is abbreviated.
This is usually a period (.) or nothing.
One element (:<Part A>[:<NameSpec>|<AbbrevLetter>|<Space>:]<Part C>:) is
replaced with a string according to the name to process as follows.
* If the name does not have the specified part, the element becomes "".
* If the name has the specified part, each name in that part replaces
<NameSpec> followed by <AbbrevLetter>, and they are concatenated
with the delimiter <Space>. Then the result (let it be <Result>) is
placed between <Part A> and <Part C> to form a string.
Examples: if the element is (:---[:f|.|~:]+++:) and the First part
of the name is "Foo Bar", the processing results "---F.~B.+++".
The process is applied to each names in the name list.
If the number of names is two, the first element of andspec is used;
if there are more, the second element is used. For example, if
andspec is [' and ', ', and'], results are like:
Aaa Bbb and Ccc Ddd
Aaa Bbb, Ccc Ddd, and Eee Fff
The order of replacement is not defined.
=end
=begin
--- $author_namestyle, $author_andspecs
Used to format author names.
--- $editor_namestyle, $editor_andspecs
Used to format editor names.
--- $sort_namestyle, $sort_andspecs
Used to sort the bibliography list.
=end
$author_namestyle = '(:[:ff|| :] :)(:[:vv||~:]~:)(:[:ll||~:]:)(:, [:jj||~:]:)'
$author_andspecs = [ ' and ', ', and ' ]
$editor_namestyle = '(:[:ff|| :] :)(:[:vv||~:]~:)(:[:ll||~:]:)(:, [:jj||~:]:)'
$editor_andspecs = [ ' and ', ', and ' ]
$sort_namestyle = '(:[:vv||~:]~:)(:[:ll||~:]:)(: [:ff||~:]:)'
$sort_andspecs = [ ' ', ' ' ]
# Samples
# $author_namestyle = '(:[:vv||~:]~:)(:[:ll||~:]:)(: [:jj||~:]:)(:, [:f|.| :]:)'
# $author_andspecs = [ ' \& ', ', \& ' ]
=begin
--- Formatter
This class should define the following methods.
:f_ functions
f_ functions that appear in the style lines above must be defined.
They should not have side effects, since the order of calling is
not defined.
:Formatter#widestlabel
This function should return a string that is to be specified as
the parameter of \begin{thebibliography}{<here>}.
:Formatter#sort
The function to sort the array $cite, whose order is the order
of the bibliography list.
=end
class Formatter
include NameFormatter
include MonthFormatter
include MiscFormatter
def f_author
a = $db[$cite]['author']
if a.nil?
return nil
else
names, numauthor = format_names(a, $author_namestyle, $author_andspecs)
return names
end
end
def f_author_xref
s = f_author
if s
return s
end
xrefcite = $db[$cite]['crossref']
if $db[xrefcite]['author']
names, num = format_names($db[xrefcite]['author'], $author_namestyle, $author_andspecs)
return names
else
$log.puts "Required field missing: no author for #{$cite} including the cited entry #{xrefcite}"
return nil
end
end
def f_editor
e = $db[$cite]['editor']
if e
names, numeditor = format_names(e, $editor_namestyle, $editor_andspecs)
if numeditor == 1
return names + ', editor'
else
return names + ', editors'
end
else
return nil
end
end
def f_author_editor
a = $db[$cite]['author']
e = $db[$cite]['editor']
if a and e
$log.puts "Redundant fields: author and editor for #{$cite}; taking author"
end
if a
names, num = format_names(a, $author_namestyle, $author_andspecs)
return names
elsif e
names, num = format_names(e, $editor_namestyle, $editor_andspecs)
if num == 1
return names + ', editor'
else
return names + ', editors'
end
else
return nil
end
end
def f_author_or_title
a = $db[$cite]['author']
t = $db[$cite]['title']
if a
names, num = format_names(a, $author_namestyle, $author_andspecs)
return names
elsif t
return "\\emph{#{t}}"
else
return nil
end
end
def f_author_or_c_title
a = $db[$cite]['author']
t = $db[$cite]['title']
if a
names, num = format_names(a, $author_namestyle, $author_andspecs)
return names
elsif t
return capitalize_toplevel(t)
else
return nil
end
end
def f_author_or_journal
a = $db[$cite]['author']
j = $db[$cite]['journal']
if a
names, num = format_names(a, $author_namestyle, $author_andspecs)
return names
elsif j
return "\\emph{#{j}}"
else
return nil
end
end
def f_editor_or_organization_or_title
e = $db[$cite]['editor']
o = $db[$cite]['organization']
t = $db[$cite]['title']
if e
names, num = format_names(e, $editor_namestyle, $editor_andspecs)
if num == 1
return names + ', editor'
else
return names + ', editors'
end
elsif o
return o
elsif t
return "\\emph{#{t}}"
else
return nil
end
end
def f_title
$db[$cite]['title']
end
def f_c_title
t = $db[$cite]['title']
if t
capitalize_toplevel(t)
else
nil
end
end
def f_booktitle
$db[$cite]['booktitle']
end
def f_year
$db[$cite]['year']
end
def f_month
m = $db[$cite]['month']
if m.nil?
ms = nil
else
ms = format_month(m)
end
ms
end
def f_month_year
m = $db[$cite]['month']
y = $db[$cite]['year']
s = nil
if y
if m
s = format_month(m) + ' ' + y
else
s = y
end
elsif m
$log.puts "Month without year is specified for #{$cite}"
s = format_month(m)
end
s
end
def f_year_xref
s = f_year
if s
return s
end
xrefcite = $db[$cite]['crossref']
return $db[xrefcite]['year']
end
def f_journal
$db[$cite]['journal']
end
def f_volume
$db[$cite]['volume']
end
def f_number
$db[$cite]['number']
end
def f_pages
$db[$cite]['pages']
end
def f_volume_number_pages
v = $db[$cite]['volume']
n = $db[$cite]['number']
p = $db[$cite]['pages']
s = ''
if v
s += v
end
if n
s += "(#{n})"
end
if p
if s == ''
s = p
else
s += ":#{p}"
end
end
if s == ''
nil
else
s
end
end
def f_pp_pages
pages = $db[$cite]['pages']
if pages.nil?
return nil
elsif /[-+]/ =~ pages
return 'pages~' + pages
else
return 'page~' + pages
end
end
def f_chapter_pp_pages
c = $db[$cite]['chapter']
p = $db[$cite]['pages']
t = $db[$cite]['type']
s = ''
if p
if /[-+]/ =~ p
pp = 'pages~' + p
else
pp = 'page~' + p
end
end
if c
if t
s = "#{lowercase_toplevel(t)} #{c}"
else
s = "chapter #{c}"
end
end
if p
if c
s += ", " + pp
else
s = pp
end
end
if s == ''
return nil
else
return s
end
end
def f_chapter_pages
c = $db[$cite]['chapter']
p = $db[$cite]['pages']
if p
if /[-+]/ =~ p
pp = 'pp.~' + p
else
pp = 'p.~' + p
end
end
if c and p
return 'chapter ' + c + ', ' + pp
elsif c
return 'chapter ' + c
elsif p
return pp
else
return nil
end
end
def f_edition
e = $db[$cite]['edition']
if e
lowercase_toplevel(e)
else
nil
end
end
def f_address
$db[$cite]['address']
end
def f_publisher
$db[$cite]['publisher']
end
def f_howpublished
$db[$cite]['howpublished']
end
def f_institution
$db[$cite]['institution']
end
def f_school
$db[$cite]['school']
end
def f_bookoptions
v = $db[$cite]['volume']
n = $db[$cite]['number']
s = $db[$cite]['series']
t = nil
if v and n
$log.puts "Warning: volume and number exist for #{$cite}; taking volume"
t = "volume #{v}"
elsif v
t = "volume #{v}"
elsif n
t = "number #{n}"
else
t = nil
end
if s
if t
if v
t += " of \\emph{#{s}}"
else
t += " in #{s}"
end
else
t = s
end
end
t
end
def f_volume_number_series
v = $db[$cite]['volume']
n = $db[$cite]['number']
s = $db[$cite]['series']
t = nil
if v and n
$log.puts "Warning: volume and number exist for #{$cite}; taking volume"
t = "volume #{v}"
elsif v
t = "volume #{v}"
elsif n
t = "number #{n}"
else
t = nil
end
if s
if t
if v
t += " of \\emph{#{s}}"
else
t += " in #{s}"
end
else
t = s
end
end
t
end
def f_articleoptions
a = $db[$cite]['author']
j = $db[$cite]['journal']
v = $db[$cite]['volume']
n = $db[$cite]['number']
p = $db[$cite]['pages']
vnp = f_volume_number_pages
s = ''
if a
s += "\\emph{#{j}}"
if vnp
s += ", " + vnp
end
else
# no author; the entire journal is specified.
# (XXX: author is required, but the BibTeX examples include this type of entry.)
# This case, the journal appears at the top;
# we do not need to place it here.
if vnp
s += vnp
end
end
if s == ''
nil
else
s
end
end
def f_miscoptions
h = $db[$cite]['howpublished']
m = $db[$cite]['month']
y = $db[$cite]['year']
s = ''
if h
s = h
end
if y
s += ', ' if s != ''
if m
s += format_month(m) + " " + y
else
s += y
end
else
if m
$log.puts "Month without year is specified for #{$cite}"
if s == ''
s = format_month(m)
else
s += ', ' + format_month(m)
end
end
end
if s == ''
nil
else
s
end
end
def f_period_ifat
if $db[$cite]['author'] or $db[$cite]['title']
'.'
else
nil
end
end
def f_vnseries_ifvn
if $db[$cite]['volume'] or $db[$cite]['number']
f_bookoptions
else
nil
end
end
def f_series_ifnovn
if $db[$cite]['volume'] or $db[$cite]['number']
nil
else
$db[$cite]['series']
end
end
def f_title_ifauthor
return $db[$cite]['title'] if $db[$cite]['author']
end
def f_c_title_ifauthor
if $db[$cite]['author']
t = $db[$cite]['title']
if t
capitalize_toplevel(t)
else
nil
end
else
nil
end
end
def f_journal_ifauthor
return $db[$cite]['journal'] if $db[$cite]['author']
end
def f_title_ifeoro
return $db[$cite]['title'] if $db[$cite]['editor'] or $db[$cite]['organization']
end
def f_bookletoptions
h = $db[$cite]['howpublished']
a = $db[$cite]['address']
m = $db[$cite]['month']
y = $db[$cite]['year']
s = ''
if h
s += "#{h}"
end
if a
if s == ''
s = a
else
s += ", #{a}"
end
end
if y
s += ', ' if s != ''
if m
s += format_month(m) + " " + y
else
s += y
end
else
if m
$log.puts "Month without year is specified for #{$cite}"
if s == ''
s = format_month(m)
else
s += ', ' + format_month(m)
end
end
end
if s != ''
return s
else
return nil
end
end
def f_manualoptions
o = $db[$cite]['organization']
a = $db[$cite]['address']
e = $db[$cite]['edition']
m = $db[$cite]['month']
y = $db[$cite]['year']
s = ''
if o
s += o
end
if a
if s == ''
s = a
else
s += ", " + a
end
end
if e
if s == ''
s = e + " edition"
else
s += ", " + lowercase_toplevel(e) + " edition"
end
end
if y
s += ', ' if s != ''
if m
s += format_month(m) + " " + y
else
s += y
end
else
if m
$log.puts "Month without year is specified for #{$cite}"
if s == ''
s = format_month(m)
else
s += ', ' + format_month(m)
end
end
end
if s == ''
nil
else
s
end
end
def f_organization_publisher
o = $db[$cite]['organization']
p = $db[$cite]['publisher']
s = ''
if o
s += o
end
if p
if o
s += ", " + p
else
s = p
end
end
if s == ''
return nil
else
return s
end
end
def f_proceedingsoptions
e = $db[$cite]['editor']
o = $db[$cite]['organization']
p = $db[$cite]['publisher']
s = ''
if o and e
s += o
else
# (if no editor, organization should have appeared at the top)
end
if p
if s == ''
s = p
else
s += ", " + p
end
end
if s == ''
return nil
else
return s
end
end
def f_organization_address_publisher
o = $db[$cite]['organization']
a = $db[$cite]['address']
p = $db[$cite]['publisher']
s = ''
if o
s += o
end
if a
if o
s += ", #{a}"
else
s = a
end
end
if p
if a
s += ": " + p
elsif o
s += ", " + p
else
s = p
end
end
if s == ''
return nil
else
return s
end
end
def f_phdthesistype
if $db[$cite]['type']
return capitalize_toplevel($db[$cite]['type'])
else
return 'PhD thesis'
end
end
def f_mastersthesistype
if $db[$cite]['type']
return $db[$cite]['type']
else
return 'Masters thesis'
end
end
def f_note
$db[$cite]['note']
end
def f_techreporttype
t = $db[$cite]['type']
if t
t
else
'Technical report'
end
end
def f_xrefcite
xref = $db[$cite]['crossref']
if xref
return "\\cite{#{xref}}"
else
$stderr.puts "Cross reference is missing: from #{$cite}"
return nil
end
end
#
# interface
#
def widestlabel
# $stderr.puts "debug: widestlabel: $cites.size is #{$cites.size}"
if $cites.size <= 0
$log.puts "Only #{$cites.size} citations found"
"9"
else
(10**(Math.log10($cites.size).to_i+1)-1).to_s # e.g., 21 -> 99
end
end
def sort
end
end
# EOF