Skip to content

Commit f12946d

Browse files
committed
ExportFormatter: Add book description and check for empty book and chapter descriptions in markdown export
1 parent ac27e18 commit f12946d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/Entities/Tools/ExportFormatter.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,11 @@ public function pageToMarkdown(Page $page): string
315315
public function chapterToMarkdown(Chapter $chapter): string
316316
{
317317
$text = '# ' . $chapter->name . "\n\n";
318-
$text .= $chapter->description . "\n\n";
318+
319+
if (!empty($chapter->description)) {
320+
$text .= $chapter->description . "\n\n";
321+
}
322+
319323
foreach ($chapter->pages as $page) {
320324
$text .= $this->pageToMarkdown($page) . "\n\n";
321325
}
@@ -330,6 +334,11 @@ public function bookToMarkdown(Book $book): string
330334
{
331335
$bookTree = (new BookContents($book))->getTree(false, true);
332336
$text = '# ' . $book->name . "\n\n";
337+
338+
if (!empty($book->description)) {
339+
$text .= $book->description . "\n\n";
340+
}
341+
333342
foreach ($bookTree as $bookChild) {
334343
if ($bookChild instanceof Chapter) {
335344
$text .= $this->chapterToMarkdown($bookChild) . "\n\n";

0 commit comments

Comments
 (0)