Skip to content

Commit

Permalink
MBS-4091: Avoid breaking lists while trimming
Browse files Browse the repository at this point in the history
From annotation formatting:
Lists: tab or 4 spaces and:
* bullets or 1., a., A., i., I. numbered items (rendered with 1.)

We are trimming all whitespace at the start and end of the
annotation though (FormHandler's default), meaning if the
annotation starts with a list the formatting for the first
element will be broken. This overrides the default trim method with one
that only trims the ending, to avoid this situation.
  • Loading branch information
reosarevok committed Nov 20, 2019
1 parent 9258db0 commit f826ac6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/MusicBrainz/Server/Form/Annotation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ has '+name' => (default => 'edit-annotation');

has_field 'text' => (
type => 'Text',
trim => { transform => sub {
my $string = shift;
# Not trimming starting spaces to avoid breaking list formatting,
# consider trimming again once this uses Markdown
$string =~ s/\s+$//;
return $string;
} }
);

has_field 'changelog' => (
Expand Down

0 comments on commit f826ac6

Please sign in to comment.