Subject: | anchors are are treated as links |
Hello, <a> tag may or may not have "href" attribute; it may have "name"
attribute instead to mark some point in the document. In the latter
case, such tags should not be treated as "links" and should not be
enumerated and listed in footnotes.
The following patch solves the problem for me:
--- lib/HTML/FormatText/WithLinks.pm- 2005-05-19 19:11:37 +0000
+++ lib/HTML/FormatText/WithLinks.pm 2005-08-23 04:54:54 +0000
@@ -58,7 +58,8 @@ sub a_start {
my $self = shift;
my $node = shift;
# local urls are no use so we have to make them absolute
- my $href = $node->attr('href') || '';
+ my $href = $node->attr('href');
+if (defined $href) {
if ($href =~ m#^http:|^mailto:#) {
push @{$self->{_links}}, $href;
} else {
@@ -66,6 +67,7 @@ sub a_start {
push @{$self->{_links}}, $u->abs();
}
$self->out( $self->text('before_link') );
+}
$self->SUPER::a_start();
}
@@ -74,6 +76,8 @@ sub a_end {
my $self = shift;
my $node = shift;
+ my $href = $node->attr('href');
+if (defined $href) {
my $text = $self->text('after_link');
# If we're just dealing with a fragment of HTML, with a link at the
# end, we get a space before the first footnote link if we do
@@ -81,6 +85,7 @@ sub a_end {
if ($text ne '') {
$self->out( $text );
}
+}
$self->SUPER::a_end();
}
End of patch
Thanks.
--
Alexey Tourbin
ALT Linux Team