+
+sub normalize_text_blocks {
+ my ($self) = @_;
+
+ # check if feature is enabled (select normalize_part_descriptions from defaults)
+ return unless ($::instance_conf->get_normalize_part_descriptions);
+
+ # text block
+ foreach (qw(description)) {
+ $self->part->{$_} =~ s/\s+$//s;
+ $self->part->{$_} =~ s/^\s+//s;
+ $self->part->{$_} =~ s/ {2,}/ /g;
+ }
+ # html block (caveat: can be circumvented by using bold or italics)
+ $self->part->{notes} =~ s/^<p>( )+\s+/<p>/s;
+ $self->part->{notes} =~ s/( )+<\/p>$/<\/p>/s;
+
+}
+