LaTeX-BibTeX
view release on metacpan or search on metacpan
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
%EXPORT_TAGS = (nodetypes => [qw(BTAST_STRING BTAST_MACRO BTAST_NUMBER)],
metatypes => [qw(BTE_UNKNOWN BTE_REGULAR BTE_COMMENT
BTE_PREAMBLE BTE_MACRODEF)],
nameparts => [qw(BTN_FIRST BTN_VON BTN_LAST BTN_JR BTN_NONE)],
joinmethods => [qw(BTJ_MAYTIE BTJ_SPACE
BTJ_FORCETIE BTJ_NOTHING)],
subs => [qw(bibloop split_list
purify_string change_case)],
macrosubs => [qw(add_macro_text
delete_macro
delete_all_macros
macro_length
macro_text)]);
@EXPORT_OK = (@{$EXPORT_TAGS{'subs'}},
@{$EXPORT_TAGS{'macrosubs'}},
@{$EXPORT_TAGS{'nodetypes'}},
=item Name parts
C<BTN_FIRST>, C<BTN_VON>, C<BTN_LAST>, C<BTN_JR>, C<BTN_NONE>. Used to
specify the various parts of a name after it has been split up. These
are mainly useful when using the C<NameFormat> class. See also
L<bt_split_names> and L<bt_format_names>. Export tag: C<nameparts>.
=item Join methods
C<BTJ_MAYTIE>, C<BTJ_SPACE>, C<BTJ_FORCETIE>, C<BTJ_NOTHING>. Used to
tell the C<NameFormat> class how to join adjacent tokens together; see
L<LaTeX::BibTeX::NameFormat> and L<bt_format_names>. Export tag:
C<joinmethods>.
=back
=head1 UTILITY FUNCTIONS
C<LaTeX::BibTeX> provides several functions that operate outside of the
normal class hierarchy. Of these, only C<bibloop> is likely to be of
BibTeX/NameFormat.pm view on Meta::CPAN
=head1 CONSTANTS
Two enumerated types for dealing with names and name formatting have
been brought from C into Perl. In the B<btparse> documentation, you'll
see references to C<bt_namepart> and C<bt_joinmethod>. The former lists
the four "parts" of a BibTeX name: first, von, last, and jr; its values
(in both C and Perl) are C<BTN_FIRST>, C<BTN_VON>, C<BTN_LAST>, and
C<BTN_JR>. The latter lists the ways in which C<bt_format_name()> (the
C function that corresponds to C<LaTeX::BibTeX::NameFormat>'s C<apply>
method) can join adjacent tokens together: C<BTJ_MAYTIE>, C<BTJ_SPACE>,
C<BTJ_FORCETIE>, and C<BTJ_NOTHING>. Both sets of values may be
imported from the C<LaTeX::BibTeX> module, using the import tags
C<nameparts> and C<joinmethods>. For instance:
use LaTeX::BibTeX qw(:nameparts :joinmethods);
use LaTeX::BibTeX::Name;
use LaTeX::BibTeX::NameFormat;
The "name part" constants are used to specify surrounding text or
formatting options on a per-part basis: for instance, you can supply the
"pre-token" text, or the "abbreviate" flag, for a single part without
btxs_support.c view on Meta::CPAN
case 'N': /* name parts */
if (strEQ (name, "BTN_FIRST")) { *arg = BTN_FIRST; ok = TRUE; }
if (strEQ (name, "BTN_VON")) { *arg = BTN_VON; ok = TRUE; }
if (strEQ (name, "BTN_LAST")) { *arg = BTN_LAST; ok = TRUE; }
if (strEQ (name, "BTN_JR")) { *arg = BTN_JR; ok = TRUE; }
if (strEQ (name, "BTN_NONE")) { *arg = BTN_NONE; ok = TRUE; }
break;
case 'J': /* token join methods */
if (strEQ (name, "BTJ_MAYTIE")) { *arg = BTJ_MAYTIE; ok = TRUE; }
if (strEQ (name, "BTJ_SPACE")) { *arg = BTJ_SPACE; ok = TRUE; }
if (strEQ (name, "BTJ_FORCETIE")) { *arg = BTJ_FORCETIE; ok = TRUE; }
if (strEQ (name, "BTJ_NOTHING")) { *arg = BTJ_NOTHING; ok = TRUE; }
break;
default:
break;
}
return ok;
}
t/nameformat.t view on Meta::CPAN
slist_equal (\@von, [qw(de la)]) &&
slist_equal (\@last, ['Vall{\'e}e', 'Poussin']));
# Start with a basic "von last, jr, first" formatter
my $format = new LaTeX::BibTeX::NameFormat ('vljf', 1);
test ($format->apply ($name) eq "de~la Vall{\'e}e~Poussin, C.~L. X.~J." &&
$format->apply ($name) eq $name->format ($format));
# Tweak options: force ties between tokens of the first name
$format->set_options (BTN_FIRST, 1, BTJ_FORCETIE, BTJ_NOTHING);
test ($format->apply ($name) eq "de~la Vall{\'e}e~Poussin, C.~L.~X.~J.");
# And no ties in the "von" part
$format->set_options (BTN_VON, 0, BTJ_SPACE, BTJ_SPACE);
test ($format->apply ($name) eq "de la Vall{\'e}e~Poussin, C.~L.~X.~J.");
# No punctuation in the first name
$format->set_text (BTN_FIRST, undef, undef, undef, '');
test ($format->apply ($name) eq "de la Vall{\'e}e~Poussin, C~L~X~J");
( run in 1.194 second using v1.01-cache-2.11-cpan-49f99fa48dc )