On Fri, Nov 26, 2004 at 03:07:11PM +0100, Nicolas François wrote:
> @@ -97,14 +99,36 @@
> # $encoded = HTML::Entities::encode($a);
> # $decoded = HTML::Entities::decode($a);
> #print STDERR $token->[0];
> - $self->pushline( " ".$self->translate($text,
> + $self->pushline( $self->translate($text,
> "FIXME:0",
> (scalar @type ? $type[scalar @type-1]:
"NOTYPE")
> - )." " );
> + ),
> + 'wrap' => 1
> + );
I don't know why the string was surrounded by spaces. Do you think it may
be important? Is it related to the correction of the trim function?
(in the later case, just forget about the first question)
I think it was an attempt to do so, but either didn't work
well or was better done with the changes I did to the trim
function (I don't remember). However, your comment made me
noticed that the module joins lines without leaving a space,
which is wrong (in HTML a newline is equivalent to a space).
I'll make sure to introduce relevant cases to the test that
I'm about to write (as soon as I work out how).
> next NEXT;
> } elsif ($token->[0] eq 'S') {
> push @type,$token->[1];
> - $self->pushline( get_tag( $token ) );
> + my $text = get_tag( $token );
> + if ( $token->[1] eq 'img' ) {
> + my %foo = %{$token->[2]};
> + my $title = (exists
$foo{"title"}?$foo{"title"}:"")."\n";
> + my $alt = (exists
$foo{"alt"}?$foo{"alt"}:"")."\n";
> + for my $attr ($title, $alt) {
> + if (defined $attr) {
> + $attr = trim($attr),
> + my $translated = $self->translate(
> + $attr,
> + "FIXME:0",
> + (scalar @type?
> + $type[scalar @type-1]:
> + "NOTYPE")
> + );
The type could be set to either "title" or "alt".
Indeed, or rather $tag_title (e.g. "img_title", otherwise
it could be confused for the content of <title>). Thanks, I
now what the type is about :-)
> + $attr = quotemeta $attr;
> + $text =~ s/$attr/$translated/;
Is it possible to only change the attribute?
(change it in the %foo hash, and reconstruct $text afterwards)
I'm worried about something like:
<img
src="http://nekral.homelinux.net/foo" title="home"
alt="nekral">
Indeed. I went for the fastest way, which must be wrong :-)
I'll add that to the test as well.
(and %foo could be renamed %attributes, or something like that)
Yeah, we don't want to waste such an important symbol to
something as mundane as a temporary variable :-)
Y.