8 |
require Exporter; |
require Exporter; |
9 |
our @ISA = qw(Exporter Bibulus); |
our @ISA = qw(Exporter Bibulus); |
10 |
|
|
11 |
|
# debugging stuff: this is not done in an OO way |
12 |
|
# -- should this be changed? |
13 |
my $DEBUG = 0; |
my $DEBUG = 0; |
14 |
sub setdebug { |
sub setdebug { |
15 |
$DEBUG = 1; |
$DEBUG = 1; |
16 |
print STDERR 'This is Bibulus::LaTeX $Id$; ', "\n"; |
print STDERR 'This is Bibulus::LaTeX $Id$', "\n"; |
17 |
Bibulus->setdebug; |
Bibulus->setdebug; |
18 |
} |
} |
19 |
|
|
20 |
# The following translates an ISO language code into a babel language |
# The following translates an ISO language code into a babel language |
21 |
# name. Often there is more than one possible name, in which case |
# name. Often there is more than one possible name, in which case |
22 |
# I have more or less chosen one at random. There are many languages |
# I have chosen one more or less at random. |
23 |
# that can be typeset with LaTeX but that aren't handled by the babel |
# |
24 |
# system -- what should be done in these cases? |
# Problem: There are many languages that can be typeset with LaTeX but |
25 |
|
# that aren't handled by the babel system -- what should be done in |
26 |
|
# these cases? |
27 |
my %iso2babel = |
my %iso2babel = |
28 |
( |
( |
29 |
'af' => 'afrikaans', |
'af' => 'afrikaans', |
148 |
my $self = shift; |
my $self = shift; |
149 |
my ($filename) = @_; |
my ($filename) = @_; |
150 |
$filename =~ s/^(.*)(\.aux)$/$1/i; |
$filename =~ s/^(.*)(\.aux)$/$1/i; |
151 |
|
print "The top-level-auxiliary file: $filename.aux\n" if $self->{VERBOSE}; |
152 |
open AUX, "<$filename.aux" or croak "Cannot open $filename.aux"; |
open AUX, "<$filename.aux" or croak "Cannot open $filename.aux"; |
153 |
$self->{FILENAME} = $filename; |
$self->{FILENAME} = $filename; |
154 |
|
|
162 |
if (/^\\bibstyle\{(.*)\}$/) { |
if (/^\\bibstyle\{(.*)\}$/) { |
163 |
defined($self->{STYLE}) and carp "Duplicate \\bibstyle"; |
defined($self->{STYLE}) and carp "Duplicate \\bibstyle"; |
164 |
$self->{STYLE} = $1; |
$self->{STYLE} = $1; |
165 |
print STDERR "bibstyle: $self->{STYLE}\n" if $DEBUG; |
print "The style file: $1.bst\n" if $self->{VERBOSE}; |
|
|
|
166 |
# The various existing BibTeX styles should be defined here. |
# The various existing BibTeX styles should be defined here. |
167 |
# (At some point, it might more sense to put all of this into |
# (At some point, it might more sense to put all of this into |
168 |
# an external file, but at present it's OK just to do it here. |
# an external file, but at present it's OK just to do it here. |
170 |
$self->{STYLE} = { |
$self->{STYLE} = { |
171 |
cite => 'numerical', # undef might be better |
cite => 'numerical', # undef might be better |
172 |
titlefont => "emph", |
titlefont => "emph", |
173 |
|
givenbefore => 1, |
174 |
# More definitions are needed, of course! |
# More definitions are needed, of course! |
175 |
}; |
}; |
176 |
} else { |
} else { |
179 |
} |
} |
180 |
|
|
181 |
if (/^\\bibdata\{(.*)\}$/) { |
if (/^\\bibdata\{(.*)\}$/) { |
182 |
exists($self->{DATA}) and carp "Duplicate \\bibdata"; |
exists($self->{DATA}) and croak "Duplicate \\bibdata"; |
183 |
$self->{DATA} = $1; |
$self->{DATA} = [split(/\s*,\s*/, $1)]; |
184 |
print STDERR "bibdata: $self->{DATA}\n" if $DEBUG; |
print STDERR "bibdata: ", join('; ', @{$self->{DATA}}), "\n" if $DEBUG; |
185 |
} |
} |
186 |
|
|
187 |
if (/^\\b\@bulus\ ?\{(.*)\}$/) { |
if (/^\\b\@bulus\ ?\{(.*)\}$/) { |
215 |
croak "No style defined with either \bibulus or \bibliographystyle" |
croak "No style defined with either \bibulus or \bibliographystyle" |
216 |
unless $self->{STYLE}; |
unless $self->{STYLE}; |
217 |
|
|
218 |
my $f = $self->{DATA}; |
foreach my $f (@{$self->{DATA}}) { |
|
unless (-e $f) { |
|
|
$f .= '.xml'; |
|
219 |
unless (-e $f) { |
unless (-e $f) { |
220 |
croak "$f not found"; |
$f .= '.xml'; |
221 |
|
unless (-e $f) { |
222 |
|
croak "$f not found"; |
223 |
|
} |
224 |
} |
} |
225 |
|
$self->load($f); |
226 |
} |
} |
|
$self->load($f); |
|
227 |
} |
} |
228 |
|
|
229 |
# Now we override Bibulus built-ins to output LaTeX |
# Now we override Bibulus built-ins to output LaTeX |
268 |
|
|
269 |
sub newblock { |
sub newblock { |
270 |
my $self = shift; |
my $self = shift; |
271 |
return "\\newblock "; |
return "\n\\newblock "; |
272 |
} |
} |
273 |
|
|
274 |
# return text in given language |
# return text in given language |
350 |
|
|
351 |
None. |
None. |
352 |
|
|
353 |
|
=head1 BUGS |
354 |
|
|
355 |
|
BibTeX converts some spaces to nonbreakable ones, |
356 |
|
and because one can insert LaTeX commands into the |
357 |
|
bibliographic database, one can prevent hyphens |
358 |
|
from becoming linebreaks. Bibulus at the moment |
359 |
|
does nothing about this. |
360 |
|
|
361 |
=head1 SEE ALSO |
=head1 SEE ALSO |
362 |
|
|
363 |
The main Bibulus module. |
The main Bibulus module. |