1 |
package Bibulus; |
package Bibulus; |
2 |
|
|
3 |
use 5.006; |
use 5.008; |
4 |
use strict; |
use strict; |
5 |
use warnings; |
use warnings; |
6 |
use Carp; |
use Carp; |
7 |
use XML::Twig; |
use XML::Twig; |
8 |
|
|
9 |
require Exporter; |
my $DEBUG = 0; |
10 |
|
sub setdebug { |
11 |
|
$DEBUG = 1; |
12 |
|
print STDERR 'This is Bibulus $Id$; ', "\n"; |
13 |
|
} |
14 |
|
|
15 |
|
# OO magic: |
16 |
|
require Exporter; |
17 |
our @ISA = qw(Exporter); |
our @ISA = qw(Exporter); |
18 |
|
|
19 |
# Internal block delimiter for use in list2text: |
# Internal block delimiter for use in list2text: |
20 |
my $newblock = '###'; |
my $newblock = '###'; |
21 |
|
|
22 |
|
|
23 |
sub new { |
sub new { |
24 |
my $class = shift; |
my $class = shift; |
25 |
my $self = {}; |
my $self = {}; |
26 |
bless($self, $class); |
bless($self, $class); |
27 |
|
|
28 |
|
# default: if a title is only xref'ed once, it will be inlined: |
29 |
$self->inlinecrossref(1); |
$self->inlinecrossref(1); |
30 |
|
|
31 |
return $self; |
return $self; |
32 |
} |
} |
33 |
|
|
|
# max. number of crossrefs to an entry that will be inlined. |
|
|
sub inlinecrossref { |
|
|
my $self = shift; |
|
|
$self->{INLINECROSSREF} = shift; |
|
|
} |
|
|
|
|
34 |
# add a text to the tree |
# add a text to the tree |
35 |
# (it's not used internally, but it's useful for users) |
# (it's not used internally, but it's useful for users |
36 |
|
# who can do stuff like \bibulusadd{label}{note}{Good book!}) |
37 |
sub add { |
sub add { |
38 |
my $self = shift; |
my $self = shift; |
39 |
my ($ref, $field, $text) = @_; |
my ($ref, $field, $text) = @_; |
45 |
} |
} |
46 |
} |
} |
47 |
|
|
48 |
|
# max. number of crossrefs to an entry that will be inlined |
49 |
|
sub inlinecrossref { |
50 |
|
my $self = shift; |
51 |
|
$self->{INLINECROSSREF} = shift; |
52 |
|
} |
53 |
|
|
54 |
|
# inline titles that are referenced rarely |
55 |
sub doinlinecrossref { |
sub doinlinecrossref { |
56 |
my $self = shift; |
my $self = shift; |
57 |
|
|
93 |
@{$self->{EL}} = grep {$_} @{$self->{EL}}; |
@{$self->{EL}} = grep {$_} @{$self->{EL}}; |
94 |
} |
} |
95 |
|
|
96 |
|
# main program logic |
97 |
sub getbib { |
sub getbib { |
98 |
my $self = shift; |
my $self = shift; |
99 |
$self->allfound; |
$self->allfound; |