Skip to content

Commit

Permalink
do not discard the interpunction
Browse files Browse the repository at this point in the history
  • Loading branch information
gflohr committed Dec 13, 2023
1 parent 3dd23c4 commit e634033
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/Qgoda/HTMLFilter/CleanUp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ sub start {

if ('a' eq lc $args{tagname}
&& defined $args{attr}->{href}
&& $args{attr}->{href} =~ s/[!,.:;?]$//) {
&& $args{attr}->{href} =~ s/([!,.:;?])$//) {
$self->{__interpunction} = $1;
$chunk = '<' . $args{tagname};

my $attrseq = $args{attrseq};
Expand All @@ -67,4 +68,15 @@ sub start {
return $chunk;
}

sub end {
my ($self, $chunk, %args) = @_;

my $interpunction = delete $self->{__interpunction} // '';
if ('a' eq $args{tagname}) {
return $chunk . $interpunction;
} else {
return $interpunction . $chunk;
}
}

1;

0 comments on commit e634033

Please sign in to comment.