mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-12 21:43:48 +08:00
ExportFormatter: Add book description and check for empty book and chapter descriptions in markdown export
This commit is contained in:
parent
ac27e18933
commit
f12946d581
|
@ -315,7 +315,11 @@ class ExportFormatter
|
|||
public function chapterToMarkdown(Chapter $chapter): string
|
||||
{
|
||||
$text = '# ' . $chapter->name . "\n\n";
|
||||
|
||||
if (!empty($chapter->description)) {
|
||||
$text .= $chapter->description . "\n\n";
|
||||
}
|
||||
|
||||
foreach ($chapter->pages as $page) {
|
||||
$text .= $this->pageToMarkdown($page) . "\n\n";
|
||||
}
|
||||
|
@ -330,6 +334,11 @@ class ExportFormatter
|
|||
{
|
||||
$bookTree = (new BookContents($book))->getTree(false, true);
|
||||
$text = '# ' . $book->name . "\n\n";
|
||||
|
||||
if (!empty($book->description)) {
|
||||
$text .= $book->description . "\n\n";
|
||||
}
|
||||
|
||||
foreach ($bookTree as $bookChild) {
|
||||
if ($bookChild instanceof Chapter) {
|
||||
$text .= $this->chapterToMarkdown($bookChild) . "\n\n";
|
||||
|
|
Loading…
Reference in New Issue
Block a user