Debian Codegraph @

texmf-dist/doc/latex/harvard/harvard.perl

raw
1 # harvard.perl
2 # Copyright 1994 - thorsten schnier ([email protected])
3 # key center of design computing, university of sydney
4 #
5 # This work may be distributed and/or modified under the
6 # conditions of the LaTeX Project Public License, either version 1.3
7 # of this license or (at your option) any later version.
8 # The latest version of this license is in
9 # http://www.latex-project.org/lppl.txt
10 # and version 1.3 or later is part of all distributions of LaTeX
11 # version 2005/12/01 or later.
12 #
13 # This work has the LPPL maintenance status `maintained'.
14 #
15 # The Current Maintainers of this work are Peter Williams and Thorsten Schnier.
16 #
17 # This work consists of all files listed in manifest.txt.
18 #
19 # Licence notice added on behalf of Peter Williams and Thorsten Schnier
20 # by Clea F. Rees 2009/01/30.
21 #
22 # Change Log:
23 # ===========
24 #
25 # 07-JUN-94 first attempt
26 # 16-JUN-94 changes for harvard 2.0
27 # (star and starstar commands)
28
29
30 package main;
31
32 $cite_mark = '<tex2html_cite_mark>';
33 $citefull_mark = '<tex2html_citefull_mark>';
34 $citeshort_mark = '<tex2html_citeshort_mark>';
35 $citename_mark = '<tex2html_citename_mark>';
36 $citenamefull_mark = '<tex2html_citenamefull_mark>';
37 $citenameshort_mark = '<tex2html_citenameshort_mark>';
38 $citekey_mark = '<tex2html_citekey_mark>';
39 $citeyear_mark = '<tex2html_citeyear_mark>';
40
41 $harvard_left = '(';
42 $harvard_right = ')';
43 $harvardyear_left = '(';
44 $harvardyear_right = ')';
45 $harvard_cite_separator = $harvard_agsm_cite_separator = ', ';
46 $harvard_year_separator = $harvard_agsm_year_separator = " ";
47 $harvard_agsm_and = '&amp;';
48 $harvard_dcu_cite_separator = "; ";
49 $harvard_dcu_year_separator = ", ";
50 $harvard_dcu_and = 'and';
51 $harvard_and = $harvard_agsm_and;
52 $harvard_default = 1;
53 $harvard_full = 0;
54
55 # the citation commands
56 # This just creates a link from a label (yet to be determined) to the
57 # cite_key in the citation file.
58 # use different markers, depending on the style of the citation used
59
60 #changes to latex2html-version:
61 #insert separating sign, use optional text argument, use brackets
62 #according to cite-mode, and reverse order of cites (to correct order)
63
64
65
66 sub do_cmd_cite {
67 local($_) = @_;
68 local($text, $dummy) = &get_next_optional_argument;
69 s/$next_pair_pr_rx//o;
70 local($cite_key) = $2;
71 local ($first) = 1 ;
72 local ($result);
73 if ($cite_key) {
74 foreach $cite_key (split(/,/,$cite_key)) {
75 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
76 $result = join ('', $result,
77 $first ? $harvard_left : $harvard_cite_separator,
78 "<A HREF=#$cite_key>$citekey_mark",
79 '##', $cite_key, $cite_mark,
80 $harvard_year_separator,
81 '##', $cite_key, $citeyear_mark,
82 "<\/A>");
83 $first = 0;
84 }
85 join ('',
86 $result,
87 $text ? ($harvard_agsm_cite_separator, $text):'',
88 $harvard_right,
89 $_);
90 }
91 else {warn "Cannot find citation argument\n";}
92 }
93
94
95 sub do_cmd_citestar {
96 local($_) = @_;
97 local($text, $dummy) = &get_next_optional_argument;
98 s/$next_pair_pr_rx//o;
99 local($cite_key) = $2;
100 local ($first) = 1 ;
101 local ($result);
102 if ($cite_key) {
103 foreach $cite_key (split(/,/,$cite_key)) {
104 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
105 $result = join ('', $result,
106 $first ? $harvard_left : $harvard_cite_separator,
107 "<A HREF=#$cite_key>$citekey_mark",
108 '##', $cite_key, $citefull_mark,
109 $harvard_year_separator,
110 '##', $cite_key, $citeyear_mark,
111 "<\/A>");
112 $first = 0;
113 }
114 join ('',
115 $result,
116 $text ? ($harvard_agsm_cite_separator, $text):'',
117 $harvard_right,
118 $_);
119 }
120 else {warn "Cannot find citation argument\n";}
121 }
122
123
124 sub do_cmd_citestarstar {
125 local($_) = @_;
126 local($text, $dummy) = &get_next_optional_argument;
127 s/$next_pair_pr_rx//o;
128 local($cite_key) = $2;
129 local ($first) = 1 ;
130 local ($result);
131 if ($cite_key) {
132 foreach $cite_key (split(/,/,$cite_key)) {
133 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
134 $result = join ('', $result,
135 $first ? $harvard_left : $harvard_cite_separator,
136 "<A HREF=#$cite_key>$citekey_mark",
137 '##', $cite_key, $citeshort_mark,
138 $harvard_year_separator,
139 '##', $cite_key, $citeyear_mark,
140 "<\/A>");
141 $first = 0;
142 }
143 join ('',
144 $result,
145 $text ? ($harvard_agsm_cite_separator, $text):'',
146 $harvard_right,
147 $_);
148 }
149 else {warn "Cannot find citation argument\n";}
150 }
151
152
153
154 sub do_cmd_citeaffixed {
155 local($_) = @_;
156 local($text, $dummy) = &get_next_optional_argument;
157 s/$next_pair_pr_rx//o;
158 local($cite_key) = $2;
159 s/$next_pair_pr_rx//o;
160 local($comment) = $2;
161 local ($first) = 1;
162 local ($result);
163 if ($cite_key) {
164 foreach $cite_key (split(/,/,$cite_key)) {
165 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
166 $result = join ('', $result,
167 $first? ($harvard_left, $comment, " ")
168 : $harvard_cite_separator,
169 "<A HREF=#$cite_key>$citekey_mark",
170 '##', $cite_key, $cite_mark,
171 $harvard_year_separator,
172 '##', $cite_key,$citeyear_mark,
173 "<\/A>");
174 $first = 0;
175 }
176 join('',
177 $result,
178 $text? ($harvard_agsm_cite_separator, $text):'',
179 $harvard_right,
180 $_);
181 }
182 else {warn "Cannot find citation argument\n";}
183 }
184
185
186 sub do_cmd_citeaffixedstar {
187 local($_) = @_;
188 local($text, $dummy) = &get_next_optional_argument;
189 s/$next_pair_pr_rx//o;
190 local($cite_key) = $2;
191 s/$next_pair_pr_rx//o;
192 local($comment) = $2;
193 local ($first) = 1;
194 local ($result);
195 if ($cite_key) {
196 foreach $cite_key (split(/,/,$cite_key)) {
197 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
198 $result = join ('', $result,
199 $first? ($harvard_left, $comment, " ")
200 : $harvard_cite_separator,
201 "<A HREF=#$cite_key>$citekey_mark",
202 '##', $cite_key, $citefull_mark,
203 $harvard_year_separator,
204 '##', $cite_key,$citeyear_mark,
205 "<\/A>");
206 $first = 0;
207 }
208 join('',
209 $result,
210 $text? ($harvard_agsm_cite_separator, $text):'',
211 $harvard_right,
212 $_);
213 }
214 else {warn "Cannot find citation argument\n";}
215 }
216
217 sub do_cmd_citeaffixedstarstar {
218 local($_) = @_;
219 local($text, $dummy) = &get_next_optional_argument;
220 s/$next_pair_pr_rx//o;
221 local($cite_key) = $2;
222 s/$next_pair_pr_rx//o;
223 local($comment) = $2;
224 local ($first) = 1;
225 local ($result);
226 if ($cite_key) {
227 foreach $cite_key (split(/,/,$cite_key)) {
228 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
229 $result = join ('', $result,
230 $first? ($harvard_left, $comment, " ")
231 : $harvard_cite_separator,
232 "<A HREF=#$cite_key>$citekey_mark",
233 '##', $cite_key, $citeshort_mark,
234 $harvard_year_separator,
235 '##', $cite_key,$citeyear_mark,
236 "<\/A>");
237 $first = 0;
238 }
239 join('',
240 $result,
241 $text? ($harvard_agsm_cite_separator, $text):'',
242 $harvard_right,
243 $_);
244 }
245 else {warn "Cannot find citation argument\n";}
246 }
247
248
249
250 #similar to cite
251 #no multiple cites allowed !
252
253 sub do_cmd_citeasnoun {
254 local($_) = @_;
255 local($text, $dummy) = &get_next_optional_argument;
256 s/$next_pair_pr_rx//o;
257 local($cite_key) = $2;
258 if ($cite_key) {
259 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
260 join ('',
261 "<A HREF=#$cite_key>$citekey_mark",
262 '##', $cite_key,$cite_mark,
263 ' ',
264 $harvard_left,
265 '##', $cite_key,$citeyear_mark,
266 $text ? ($harvard_agsm_cite_separator, $text):'',
267 $harvard_right,
268 "<\/A>",
269 $_);
270 }
271 else {warn "Cannot find citation argument\n";}
272 }
273
274
275 sub do_cmd_citeasnounstar {
276 local($_) = @_;
277 local($text, $dummy) = &get_next_optional_argument;
278 s/$next_pair_pr_rx//o;
279 local($cite_key) = $2;
280 if ($cite_key) {
281 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
282 join ('',
283 "<A HREF=#$cite_key>$citekey_mark",
284 '##', $cite_key,$citefull_mark,
285 ' ',
286 $harvard_left,
287 '##', $cite_key,$citeyear_mark,
288 $text ? ($harvard_agsm_cite_separator, $text):'',
289 $harvard_right,
290 "<\/A>",
291 $_);
292 }
293 else {warn "Cannot find citation argument\n";}
294 }
295
296
297 sub do_cmd_citeasnounstarstar {
298 local($_) = @_;
299 local($text, $dummy) = &get_next_optional_argument;
300 s/$next_pair_pr_rx//o;
301 local($cite_key) = $2;
302 if ($cite_key) {
303 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
304 join ('',
305 "<A HREF=#$cite_key>$citekey_mark",
306 '##', $cite_key,$citeshort_mark,
307 ' ',
308 $harvard_left,
309 '##', $cite_key,$citeyear_mark,
310 $text ? ($harvard_agsm_cite_separator, $text):'',
311 $harvard_right,
312 "<\/A>",
313 $_);
314 }
315 else {warn "Cannot find citation argument\n";}
316 }
317
318
319
320 #same as citeasnoun, but add the possessive 's
321 #no multiple cites allowed !
322
323 sub do_cmd_possessivecite {
324 local($_) = @_;
325 local($text, $dummy) = &get_next_optional_argument;
326 s/$next_pair_pr_rx//o;
327 local($cite_key) = $2;
328 if ($cite_key) {
329 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
330 # The proper link $citefile#$cite_key will be substituted later
331 join('', "<A HREF=#$cite_key>$citekey_mark",
332 '##', $cite_key,$cite_mark,
333 '\'s ',
334 $harvard_left,
335 '##', $cite_key,$citeyear_mark,
336 $text? ($harvard_agsm_cite_separator, $text):'',
337 $harvard_right,
338 "<\/A>",
339 $_);
340 }
341 else {warn "Cannot find citation argument\n";}
342 }
343
344 sub do_cmd_possessivecitestar {
345 local($_) = @_;
346 local($text, $dummy) = &get_next_optional_argument;
347 s/$next_pair_pr_rx//o;
348 local($cite_key) = $2;
349 if ($cite_key) {
350 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
351 # The proper link $citefile#$cite_key will be substituted later
352 join('', "<A HREF=#$cite_key>$citekey_mark",
353 '##', $cite_key,$citefull_mark,
354 '\'s ',
355 $harvard_left,
356 '##', $cite_key,$citeyear_mark,
357 $text? ($harvard_agsm_cite_separator, $text):'',
358 $harvard_right,
359 "<\/A>",
360 $_);
361 }
362 else {warn "Cannot find citation argument\n";}
363 }
364
365 sub do_cmd_possessivecitestarstar {
366 local($_) = @_;
367 local($text, $dummy) = &get_next_optional_argument;
368 s/$next_pair_pr_rx//o;
369 local($cite_key) = $2;
370 if ($cite_key) {
371 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
372 # The proper link $citefile#$cite_key will be substituted later
373 join('', "<A HREF=#$cite_key>$citekey_mark",
374 '##', $cite_key,$citeshort_mark,
375 '\'s ',
376 $harvard_left,
377 '##', $cite_key,$citeyear_mark,
378 $text? ($harvard_agsm_cite_separator, $text):'',
379 $harvard_right,
380 "<\/A>",
381 $_);
382 }
383 else {warn "Cannot find citation argument\n";}
384 }
385
386
387 #similar to citeasnoun, but only names
388 #multiple arguments allowed, no link produced
389 #no optional text argument
390
391 sub do_cmd_citename {
392 local($_) = @_;
393 s/$next_pair_pr_rx//o;
394 local($cite_key) = $2;
395 local ($first) = 1;
396 local ($result);
397 if ($cite_key) {
398 foreach $cite_key (split(/,/,$cite_key)) {
399 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
400 # The proper link $citefile#$cite_key will be substituted later
401 $result = join('', $result,
402 ($first? '': $harvard_cite_separator),
403 "<A HREF=#$cite_key>$citekey_mark",
404 '##', $cite_key, $citename_mark,
405 "</A>");
406 $first = 0;
407 }
408 join ('', $result, $_);
409 }
410 else {warn "Cannot find citation argument\n";}
411 }
412
413 sub do_cmd_citenamestar {
414 local($_) = @_;
415 s/$next_pair_pr_rx//o;
416 local($cite_key) = $2;
417 local ($first) = 1 ;
418 local ($result);
419 if ($cite_key) {
420 foreach $cite_key (split(/,/,$cite_key)) {
421 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
422 # The proper link $citefile#$cite_key will be substituted later
423 $result = join('', $result,
424 ($first? '' : $harvard_cite_separator),
425 "<A HREF=#$cite_key>$citekey_mark",
426 '##', $cite_key,$citenamefull_mark,
427 "</A>");
428 $first = 0;
429 }
430 join ('', $result, $_);
431 }
432 else {warn "Cannot find citation argument\n";}
433 }
434
435 sub do_cmd_citenamestarstar {
436 local($_) = @_;
437 s/$next_pair_pr_rx//o;
438 local($cite_key) = $2;
439 local ($first) = 1 ;
440 local ($result);
441 if ($cite_key) {
442 foreach $cite_key (split(/,/,$cite_key)) {
443 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
444 # The proper link $citefile#$cite_key will be substituted later
445 $result = join('', $result,
446 ($first? '' : $harvard_cite_separator),
447 "<A HREF=#$cite_key>$citekey_mark",
448 '##', $cite_key,$citenameshort_mark,
449 "</A>");
450 $first = 0;
451 }
452 join ('', $result, $_);
453 }
454 else {warn "Cannot find citation argument\n";}
455 }
456
457
458 #similar to cite, but only year
459 #multiple arguments allowed, no link produced
460 #no optional text argument
461
462 sub do_cmd_citeyear {
463 local($_) = @_;
464 s/$next_pair_pr_rx//o;
465 local($cite_key) = $2;
466 local ($first) = 1 ;
467 local ($result);
468 if ($cite_key) {
469 foreach $cite_key (split(/,/,$cite_key)) {
470 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
471 # The proper link $citefile#$cite_key will be substituted later
472 $result = join ('', $result,
473 ($first ? $harvard_left : $harvard_cite_separator),
474 "<A HREF=#$cite_key>$citekey_mark",
475 '##', $cite_key,$citeyear_mark,
476 "</A>");
477 $first = 0;
478 }
479 join('',$result, $harvard_right, $_); # closing bracket
480 }
481 else {warn "Cannot find citation argument\n";}
482 }
483
484
485 # citeyear without brackets
486
487 sub do_cmd_citeyearstar {
488 local($_) = @_;
489 s/$next_pair_pr_rx//o;
490 local($cite_key) = $2;
491 local ($first) = 1 ;
492 local ($result);
493 if ($cite_key) {
494 foreach $cite_key (split(/,/,$cite_key)) {
495 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
496 # The proper link $citefile#$cite_key will be substituted later
497 $result = join ('', $result,
498 ($first ? '' : $harvard_cite_separator),
499 "<A HREF=#$cite_key>$citekey_mark",
500 '##', $cite_key,$citeyear_mark,
501 "</A>");
502 $first = 0;
503 }
504 join('',$result, $_); # no brackets
505 }
506 else {warn "Cannot find citation argument\n";}
507 }
508
509
510
511
512 # the style commands
513
514 sub do_cmd_citationstyle{
515 local($_) = @_;
516 s/$next_pair_pr_rx//o;
517 $2;
518 switch: {
519 if ($2 =~ /dcu/){
520 $harvard_cite_separator = $harvard_dcu_cite_separator;
521 $harvard_year_separator = $harvard_dcu_year_separator;
522 $harvard_and = $harvard_dcu_and;
523 last switch; }
524 if ($2 =~ /agsm/) {
525 $harvard_cite_separator = $harvard_agsm_cite_separator;
526 $harvard_year_separator = $harvard_agsm_year_separator;
527 $harvard_and = $harvard_agsm_and;
528 last switch;}
529 warn 'unknown citation style $2';}
530 $_;
531 }
532
533
534
535 sub do_cmd_citationmode{
536 local($_) = @_;
537 s/$next_pair_pr_rx//o;
538 $2;
539 switch: {
540 if ($2 =~ /full/){
541 $harvard_full = 1;
542 $harvard_default = 0;
543 last switch; }
544 if ($2 =~ /abbr/) {
545 $harvard_full = 0;
546 $harvard_default = 0;
547 last switch;}
548 if ($2 =~ /default/) {
549 $harvard_full = 0;
550 $harvard_default = 1;
551 last switch;}
552 warn 'unknown citation mode $2';}
553 $_;
554 }
555
556
557 sub do_cmd_harvardparenthesis{
558 local($_) = @_;
559 s/$next_pair_pr_rx//o;
560 switch: {
561 if ($2 =~ /round/){
562 $harvard_left = '\(';
563 $harvard_right = '\)';
564 $harvardyear_left = '\(';
565 $harvardyear_right = '\)';
566 last switch; }
567 if ($2 =~ /curly/) {
568 $harvard_left = '\{';
569 $harvard_right = '\}';
570 $harvardyear_left = '\{';
571 $harvardyear_right = '\}';
572 last switch;}
573 if ($2 =~ /square/) {
574 $harvard_left = '\[';
575 $harvard_right = '\]';
576 $harvardyear_left = '\[';
577 $harvardyear_right = '\]';
578 last switch;}
579 if ($2 =~ /angle/) {
580 $harvard_left = '&lt;';
581 $harvard_right = '&gt;';
582 $harvardyear_left = '&lt;';
583 $harvardyear_right = '&gt;';
584 last switch;}
585 warn 'unknown paranthesis type $2';}
586 $_
587 }
588
589
590 sub do_cmd_harvardyearparenthesis{
591 local($_) = @_;
592 s/$next_pair_pr_rx//o;
593 switch: {
594 if ($2 =~ /round/){
595 $harvardyear_left = '\(';
596 $harvardyear_right = '\)';
597 last switch; }
598 if ($2 =~ /curly/) {
599 $harvardyear_left = '\{';
600 $harvardyear_right = '\}';
601 last switch;}
602 if ($2 =~ /square/) {
603 $harvardyear_left = '\[';
604 $harvardyear_right = '\]';
605 last switch;}
606 if ($2 =~ /angle/) {
607 $harvardyear_left = '&lt;';
608 $harvardyear_right = '&gt;';
609 last switch;}
610 warn 'unknown year paranthesis type $_';}
611 $_;
612 }
613
614
615 # harvard symbols
616
617 sub do_cmd_harvardleft {
618 join('',$harvard_left,@_[0]);
619 }
620
621 sub do_cmd_harvardright {
622 join('',$harvard_right,@_[0]);
623 }
624
625 sub do_cmd_harvardyearleft {
626 join('',$harvardyear_left,@_[0]);
627 }
628
629 sub do_cmd_harvardyearright {
630 join('',$harvardyear_right,@_[0]);
631 }
632
633 sub do_cmd_harvardand {
634 join('',$harvard_and,@_[0]);
635 }
636
637
638
639 # This command will only be encountered inside a thebibliography environment.
640 # this should not occur in a file using harvard style
641 # mainly unchanged, only a warning added
642
643 sub do_cmd_bibitem {
644 local($_) = @_;
645 # The square brackets may contain the label to be printed
646 warn "bibitem-command in harvard-style file\n Cannot extract all neccessary information for cites\n";
647 local($label, $dummy) = &get_next_optional_argument;
648 $label = ++$bibitem_counter unless $label; # Numerical labels
649 s/$next_pair_pr_rx//o;
650 $cite_key = $2;
651 if ($cite_key) {
652 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
653 # Associate the cite_key with the printed label.
654 # The printed label will be substituted back into the document later.
655 $cite_info{$cite_key} = $label;
656 # Create an anchor around the citation
657 join('',"<DT><A NAME=\"$cite_key\"><B>$label</B></A><DD>", $_);
658 }
659 else {
660 warn "Cannot find bibitem labels\n";}
661 }
662
663 # collect information from item and associate it with the
664 # cite-key. Contrary to bibitem, the cite-key argument is not optional,
665 # so no numeric cite-key has to be generated
666
667 sub do_cmd_harvarditem {
668 local($_) = @_;
669 # The square brackets may contain the short citation
670 local($abbr_cite, $dummy) = &get_next_optional_argument;
671 s/$next_pair_pr_rx//o;
672 local($full_cite)= $2;
673 $abbr_cite= $full_cite unless $abbr_cite;
674 s/$next_pair_pr_rx//o;
675 local($cite_year) = $2;
676 s/$next_pair_pr_rx//o;
677 local($cite_key) = $2;
678 if ($cite_key) {
679 $cite_key =~ s/\W//g; # Remove non alphanumeric characters
680 # Associate the citation-infos with the cite-key.
681 # The infos will be substituted back into the document later,
682 # depending on the citation used
683 $cite_info_abbr {$cite_key} = $abbr_cite;
684 $cite_info_full {$cite_key} = $full_cite;
685 $cite_info_year {$cite_key} = $cite_year;
686 $cite_info_first {$cite_key} = 1;
687 # Create an anchor around the citation
688 join('',"<DT><A NAME=\"$cite_key\">- </A><DD>", $_);
689 }
690 else {
691 warn "Cannot find bibitem labels\n";}
692 }
693
694
695 ##
696 ## to allow bibcard to produce URL links:
697 ## same as htmladdnormallink, but only one argument (both link and text)
698
699 sub do_cmd_harvardurl{
700 local($_) = @_;
701 local($url);
702 s/$next_pair_pr_rx/$url = $2; ''/eo;
703 join('',do {qq/<B>URL:<\/B><A HREF="$url">$url<\/A>/;},$_);
704 }
705
706
707
708 # this onle has to be extended to search for citename_mark and
709 # citeyear_mark as well
710 # the appropriate entries should have been produced by do_cmd_harvarditem
711
712 sub replace_cite_references {
713 s/##(\w+)$cite_mark/&help_replace_cites(\1)/ge;
714 s/##(\w+)$citefull_mark/&help_replace_fullcites(\1)/ge;
715 s/##(\w+)$citeshort_mark/&help_replace_shortcites(\1)/ge;
716 s/##(\w+)$citename_mark/&help_replace_name($1)/ge;
717 s/##(\w+)$citenamefull_mark/$cite_info_full{\1}/g;
718 s/##(\w+)$citenameshort_mark/$cite_info_short{\1}/g;
719 s/##(\w+)$citeyear_mark/$cite_info_year{\1}/g;
720 s/#(\w+)>$citekey_mark/$citefile#\1>/g;
721 $_
722 }
723
724
725 #return full or abbreviated cite text
726 sub help_replace_cites {
727 local ($key)= @_[0];
728 $cite_info_first{$key}= 0; # not the first time anymore
729 if ($harvard_full || ($cite_info_first{$key} && $harvard_default)) {
730 $cite_info_full{$key}; # full citation
731 }
732 else{
733 $cite_info_abbr{$key}; # abbreviated citation
734 }
735 }
736
737 sub help_replace_shortcites {
738 local ($key)= @_[0];
739 $cite_info_first{$key}= 0; # not the first time anymore
740 $cite_info_abbr{$key}; # abbreviated citation
741 }
742
743 sub help_replace_fullcites {
744 local ($key)= @_[0];
745 $cite_info_first{$key}= 0; # not the first time anymore
746 $cite_info_full{$key}; # full citation
747 }
748
749 sub help_replace_name {
750 local ($key)= @_[0];
751 if ($harvard_full || ($cite_info_first{$key} && $harvard_default)) {
752 $cite_info_full{$key}; # full citation
753 }
754 else{
755 $cite_info_abbr{$key}; # abbreviated citation
756 }
757 }
758
759
760 #this one has to be changes as well, so that it finds all citemarks
761
762 sub remove_general_markers {
763 s/$lof_mark/<UL>$figure_captions<\/UL>/o;
764 s/$lot_mark/<UL>$table_captions<\/UL>/o;
765 s/$bbl_mark/$citations/o;
766 &add_toc if (/$toc_mark/);
767 &add_idx if (/$idx_mark/);
768 &replace_cross_references if /$cross_ref_mark/;
769 &replace_external_references if /$external_ref_mark/;
770 &replace_cite_references; #just take the if out (not really neccessary)
771 }
772
773
774 1; # Not really necessary...
775
776
777
778 # T.S.: added the starstar option
779 # If a normalized command name exists, return it.
780 sub normalize {
781 local($cmd) = @_;
782 local($ncmd);
783 if ($ncmd = $normalize{$cmd}) {
784 $ncmd}
785 elsif ($cmd =~ s/[*]/star/g) {
786 $cmd }
787 elsif ($cmd =~ s/^@/tex/) {
788 $cmd}
789 else {$cmd}
790 }
791
792
793 # does not really belong to harvard.perl, but as a general improvement
794
795
796 sub do_cmd_and {
797 join('',"<p>", @_[0]); #make a paragraph brake of it
798 }
799
800 sub do_cmd_newline {
801 join('',"<br>", @_[0]);
802 }
803