projects
/
kivitendo-erp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0d12df6
)
SL::HTML::Strip: immer Leerzeichen zwischen Textenteilen lassen
author
Moritz Bunkus
<m.bunkus@linet.de>
Wed, 10 Nov 2021 13:05:18 +0000
(14:05 +0100)
committer
Moritz Bunkus
<m.bunkus@linet.de>
Wed, 10 Nov 2021 15:07:50 +0000
(16:07 +0100)
SL/HTML/Util.pm
patch
|
blob
|
history
diff --git
a/SL/HTML/Util.pm
b/SL/HTML/Util.pm
index
f68fb0a
..
a54425d
100644
(file)
--- a/
SL/HTML/Util.pm
+++ b/
SL/HTML/Util.pm
@@
-27,7
+27,7
@@
sub strip {
if (!%stripper) {
%stripper = ( parser => HTML::Parser->new );
- $stripper{parser}->handler(text => sub { $stripper{text} .= $_[1]; });
+ $stripper{parser}->handler(text => sub { $stripper{text} .=
' ' .
$_[1]; });
}
$stripper{text} = '';
@@
-35,6
+35,8
@@
sub strip {
$stripper{parser}->eof;
$stripper{text} =~ s{\&([^;]+);}{ $entities{$1} || "\&$1;" }eg;
+ $stripper{text} =~ s{^ +| +$}{}g;
+ $stripper{text} =~ s{ {2,}}{ }g;
return delete $stripper{text};
}