mirror of
https://github.com/koel/koel
synced 2024-11-28 06:50:27 +00:00
feat: replace br with new lines in lyrics
This commit is contained in:
parent
7680c71d77
commit
117a3df1f5
1 changed files with 8 additions and 0 deletions
|
@ -105,6 +105,14 @@ class Song extends Model
|
|||
);
|
||||
}
|
||||
|
||||
protected function lyrics(): Attribute
|
||||
{
|
||||
// Since we're displaying the lyrics using <pre>, replace breaks with newlines and strip all tags.
|
||||
$normalizer = static fn (?string $value): string => strip_tags(preg_replace('#<br\s*/?>#i', PHP_EOL, $value));
|
||||
|
||||
return new Attribute(get: $normalizer, set: $normalizer);
|
||||
}
|
||||
|
||||
public static function withMeta(User $scopedUser, ?Builder $query = null): Builder
|
||||
{
|
||||
$query ??= static::query();
|
||||
|
|
Loading…
Reference in a new issue