[btOOL] escaping problems
Status: Beta
Brought to you by:
gward
|
From: Guillaume R. <Gui...@in...> - 2005-11-30 09:16:08
|
I'm using Text::BibTeX to convert bibtex database to XML. I faced small
escaping problems I was unable to solve properly.
First, all entries keep internal formating braces.
Such a bibtex entry:
title =3D "Automata-based Parsing in Dynamic Programming for
{L}inear {I}ndexed {G}rammars"
Result in following title value:
Automata-based Parsing in Dynamic Programming for
{L}inear {I}ndexed {G}rammars
Second, I was unable to convert accentued characters macros, such as \'E
to =C9, even when trying to use macro-related functions, such as
add_macro_text('\\\'E', '=C9') or add_macro_text("\\'E", '=C9')
The only solution I found is an ugly hack to add additional function in
original Text::BibTeX namespace, so as to convert values on the fly:
sub convert {
$_[0] =3D~ s/{//g;
$_[0] =3D~ s/}//g;
$_[0] =3D~ s/\\'E/=C9/g;
$_[0] =3D~ s/\\'o/=F3/g;
$_[0] =3D~ s/\\'a/=E1/g;
return $_[0];
}
package Text::BibTeX::Entry;
sub safe_get {
my ($self, $field) =3D @_;
return main::convert($self->get($field));
}
package Text::BibTeX::Name;
sub safe_part {
my ($self, $field) =3D @_;
return
map { main::convert($_) }
$self->part($field);
}
Is there any other solution ?
--=20
Everything always works in your HQ, everything always fails in the
Colonel's HQ
-- Murphy's Military Laws n=B030
|