mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-21 05:26:10 +03:00
Fixed conctenation of direct book pages within markdown export
- Updated to ensure seperation with newlines. - Added test to cover. For #3341
This commit is contained in:
parent
981807220c
commit
1c859e94e0
@ -326,7 +326,7 @@ class ExportFormatter
|
|||||||
$text .= $this->pageToMarkdown($page) . "\n\n";
|
$text .= $this->pageToMarkdown($page) . "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $text;
|
return trim($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -338,12 +338,12 @@ class ExportFormatter
|
|||||||
$text = '# ' . $book->name . "\n\n";
|
$text = '# ' . $book->name . "\n\n";
|
||||||
foreach ($bookTree as $bookChild) {
|
foreach ($bookTree as $bookChild) {
|
||||||
if ($bookChild instanceof Chapter) {
|
if ($bookChild instanceof Chapter) {
|
||||||
$text .= $this->chapterToMarkdown($bookChild);
|
$text .= $this->chapterToMarkdown($bookChild) . "\n\n";
|
||||||
} else {
|
} else {
|
||||||
$text .= $this->pageToMarkdown($bookChild);
|
$text .= $this->pageToMarkdown($bookChild) . "\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $text;
|
return trim($text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,6 +420,25 @@ class ExportTest extends TestCase
|
|||||||
$resp->assertSee('# ' . $page->name);
|
$resp->assertSee('# ' . $page->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_book_markdown_export_concats_immediate_pages_with_newlines()
|
||||||
|
{
|
||||||
|
/** @var Book $book */
|
||||||
|
$book = Book::query()->whereHas('pages')->first();
|
||||||
|
|
||||||
|
$this->asEditor()->get($book->getUrl('/create-page'));
|
||||||
|
$this->get($book->getUrl('/create-page'));
|
||||||
|
|
||||||
|
[$pageA, $pageB] = $book->pages()->where('chapter_id', '=', 0)->get();
|
||||||
|
$pageA->html = '<p>hello tester</p>';
|
||||||
|
$pageA->save();
|
||||||
|
$pageB->name = 'The second page in this test';
|
||||||
|
$pageB->save();
|
||||||
|
|
||||||
|
$resp = $this->get($book->getUrl('/export/markdown'));
|
||||||
|
$resp->assertDontSee("hello tester# The second page in this test");
|
||||||
|
$resp->assertSee("hello tester\n\n# The second page in this test");
|
||||||
|
}
|
||||||
|
|
||||||
public function test_export_option_only_visible_and_accessible_with_permission()
|
public function test_export_option_only_visible_and_accessible_with_permission()
|
||||||
{
|
{
|
||||||
$book = Book::query()->whereHas('pages')->whereHas('chapters')->first();
|
$book = Book::query()->whereHas('pages')->whereHas('chapters')->first();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user