summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm')
-rw-r--r--Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm75
1 files changed, 66 insertions, 9 deletions
diff --git a/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm b/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm
index af3d32f5e5a..6d3b0ec81a8 100644
--- a/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm
+++ b/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm
@@ -1,6 +1,6 @@
package BibTeX::Parser::Entry;
{
- $BibTeX::Parser::Entry::VERSION = '1.00';
+ $BibTeX::Parser::Entry::VERSION = '1.01';
}
use warnings;
@@ -216,17 +216,39 @@ sub raw_bibtex {
return $self->{_raw};
}
+sub pre {
+ my $self = shift;
+ if (@_) {
+ $self->{_pre} = shift;
+ }
+ return $self->{_pre};
+}
+
+
sub to_string {
my $self = shift;
my %options=@_;
if (!exists($options{canonize_names})) {
$options{canonize_names}=1;
}
- my @fields = grep {!/^_/} keys %$self;
+ my @fields = grep {!/^_/} keys %$self;
@fields = sort {
$self->{_fieldnums}->{$a} <=>
$self->{_fieldnums}->{$b}} @fields;
- my $result = '@'.$self->type."{".$self->key.",\n";
+ my $result = '';
+ if ($options{print_pre}) {
+ $result .= $self->pre()."\n";
+ }
+ my $type = $self->type;
+ if (exists($options{type_capitalization})) {
+ if ($options{type_capitalization} eq 'Lowercase') {
+ $type = lc $type;
+ }
+ if ($options{type_capitalization} eq 'Titlecase') {
+ $type = ucfirst lc $type;
+ }
+ }
+ $result .= '@'.$type."{".$self->key.",\n";
foreach my $field (@fields) {
my $value = $self->field($field);
if ($field eq 'author' && $options{canonize_names}) {
@@ -237,7 +259,15 @@ sub to_string {
my @names = ($self->editor);
$value = join(' and ', @names);
}
- $result .= " $field = {"."$value"."},\n";
+ if (exists($options{field_capitalization})) {
+ if ($options{field_capitalization} eq 'Uppercase') {
+ $field = uc $field;
+ }
+ if ($options{field_capitalization} eq 'Titlecase') {
+ $field = ucfirst $field;
+ }
+ }
+ $result .= " $field = {"."$value"."},\n";
}
$result .= "}";
return $result;
@@ -343,22 +373,49 @@ Returns a list of all the fields used in this entry.
Returns a true value if this entry has a value for $fieldname.
+=head2 pre ()
+
+Return the text in BibTeX file before the entry
+
=head2 raw_bibtex ()
Return raw BibTeX entry (if available).
=head2 to_string ([options])
-Returns a text of the BibTeX entry in BibTeX format. Options is
-a hash. Currently only the option C<canonize_names>
-is supported. If true (the default), authors' and editors'
+Returns a text of the BibTeX entry in BibTeX format. Options are
+a hash.
+
+=over 4
+
+=item C<canonize_names>
+
+If true (the default), authors' and editors'
names are translated into canonical bibtex form. The command
C<$entry-E<gt>to_string(canonize_names=E<gt>0)> overrides this behavior.
-=head1 VERSION
+=item C<field_capitalization>
+
+Capitalization of the field names.
+Can take values 'Uppercase', 'Lowercase' (the default) or 'Titlecase'
+
+=item C<print_pre>
-version 1.00
+False by default. If true, the text in the Bib file before the
+entry is printed. Note that at present we assume the text
+before the entry NEVER has the @ symbol inside
+
+=item C<type_capitalization>
+
+Capitalization of the type names.
+Can take values 'Uppercase' (the default), 'Lowercase' or 'Titlecase'
+
+
+=back
+
+=head1 VERSION
+version 1.01
=head1 AUTHOR