File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -316,8 +316,9 @@ public function chapterToMarkdown(Chapter $chapter): string
316316 {
317317 $ text = '# ' . $ chapter ->name . "\n\n" ;
318318
319- if (!empty ($ chapter ->description )) {
320- $ text .= $ chapter ->description . "\n\n" ;
319+ $ description = (new HtmlToMarkdown ($ chapter ->descriptionHtml ()))->convert ();
320+ if ($ description ) {
321+ $ text .= $ description . "\n\n" ;
321322 }
322323
323324 foreach ($ chapter ->pages as $ page ) {
@@ -334,9 +335,10 @@ public function bookToMarkdown(Book $book): string
334335 {
335336 $ bookTree = (new BookContents ($ book ))->getTree (false , true );
336337 $ text = '# ' . $ book ->name . "\n\n" ;
337-
338- if (!empty ($ book ->description )) {
339- $ text .= $ book ->description . "\n\n" ;
338+
339+ $ description = (new HtmlToMarkdown ($ book ->descriptionHtml ()))->convert ();
340+ if ($ description ) {
341+ $ text .= $ description . "\n\n" ;
340342 }
341343
342344 foreach ($ bookTree as $ bookChild ) {
Original file line number Diff line number Diff line change @@ -417,23 +417,35 @@ public function test_page_markdown_export_converts_html_where_no_markdown()
417417 public function test_chapter_markdown_export ()
418418 {
419419 $ chapter = $ this ->entities ->chapter ();
420+ $ chapter ->description_html = '<p>My <strong>chapter</strong> description</p> ' ;
421+ $ chapter ->save ();
420422 $ page = $ chapter ->pages ()->first ();
423+
421424 $ resp = $ this ->asEditor ()->get ($ chapter ->getUrl ('/export/markdown ' ));
422425
423426 $ resp ->assertSee ('# ' . $ chapter ->name );
424427 $ resp ->assertSee ('# ' . $ page ->name );
428+ $ resp ->assertSee ('My **chapter** description ' );
425429 }
426430
427431 public function test_book_markdown_export ()
428432 {
429433 $ book = Book::query ()->whereHas ('pages ' )->whereHas ('chapters ' )->first ();
434+ $ book ->description_html = '<p>My <strong>book</strong> description</p> ' ;
435+ $ book ->save ();
436+
430437 $ chapter = $ book ->chapters ()->first ();
438+ $ chapter ->description_html = '<p>My <strong>chapter</strong> description</p> ' ;
439+ $ chapter ->save ();
440+
431441 $ page = $ chapter ->pages ()->first ();
432442 $ resp = $ this ->asEditor ()->get ($ book ->getUrl ('/export/markdown ' ));
433443
434444 $ resp ->assertSee ('# ' . $ book ->name );
435445 $ resp ->assertSee ('# ' . $ chapter ->name );
436446 $ resp ->assertSee ('# ' . $ page ->name );
447+ $ resp ->assertSee ('My **book** description ' );
448+ $ resp ->assertSee ('My **chapter** description ' );
437449 }
438450
439451 public function test_book_markdown_export_concats_immediate_pages_with_newlines ()
You can’t perform that action at this time.
0 commit comments