Describe the Bug
For example, when a book's description is empty, editing and saving it will result in HTML tags being appended to the empty field. As a result, an empty <p> tag is rendered in the description.
Quick Fix
app/Entities/Models/HasHtmlDescription.php
/**
* Check if the entity has a meaningful description (not just empty HTML tags).
*/
public function hasDescription(): bool
{
$cleanedHtml = str_replace(['<p>', '</p>', '<br>', '<br/>', "\xC2", "\xA0", " "], '', $this->descriptionHtml());
return !empty(trim($cleanedHtml));
}
resources/views/books/show.blade.php
resources/views/chapters/show.blade.php
resources/views/shelves/show.blade.php
@if($book->hasDescription())
<div class="text-muted break-text">{!! $book->descriptionHtml() !!}</div>
@endif
Steps to Reproduce
- Go to https://demo.bookstackapp.com/books/bookstack-demo-site
- Click
Edit on the right side.
- Remove description content and save.
- Click
Edit again and save, it will add an empty line(<p>).
Expected Behaviour
- No empty line.
- Trim empty description.
Screenshots or Additional Context
No response
Browser Details
No response
Exact BookStack Version
v25.05.2
Describe the Bug
For example, when a book's description is empty, editing and saving it will result in HTML tags being appended to the empty field. As a result, an empty
<p>tag is rendered in the description.Quick Fix
app/Entities/Models/HasHtmlDescription.phpresources/views/books/show.blade.phpresources/views/chapters/show.blade.phpresources/views/shelves/show.blade.phpSteps to Reproduce
Editon the right side.Editagain and save, it will add an empty line(<p>).Expected Behaviour
Screenshots or Additional Context
No response
Browser Details
No response
Exact BookStack Version
v25.05.2