File tree 2 files changed +19
-5
lines changed
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
316
316
{
317
317
$ text = '# ' . $ chapter ->name . "\n\n" ;
318
318
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" ;
321
322
}
322
323
323
324
foreach ($ chapter ->pages as $ page ) {
@@ -334,9 +335,10 @@ public function bookToMarkdown(Book $book): string
334
335
{
335
336
$ bookTree = (new BookContents ($ book ))->getTree (false , true );
336
337
$ 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" ;
340
342
}
341
343
342
344
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()
417
417
public function test_chapter_markdown_export ()
418
418
{
419
419
$ chapter = $ this ->entities ->chapter ();
420
+ $ chapter ->description_html = '<p>My <strong>chapter</strong> description</p> ' ;
421
+ $ chapter ->save ();
420
422
$ page = $ chapter ->pages ()->first ();
423
+
421
424
$ resp = $ this ->asEditor ()->get ($ chapter ->getUrl ('/export/markdown ' ));
422
425
423
426
$ resp ->assertSee ('# ' . $ chapter ->name );
424
427
$ resp ->assertSee ('# ' . $ page ->name );
428
+ $ resp ->assertSee ('My **chapter** description ' );
425
429
}
426
430
427
431
public function test_book_markdown_export ()
428
432
{
429
433
$ book = Book::query ()->whereHas ('pages ' )->whereHas ('chapters ' )->first ();
434
+ $ book ->description_html = '<p>My <strong>book</strong> description</p> ' ;
435
+ $ book ->save ();
436
+
430
437
$ chapter = $ book ->chapters ()->first ();
438
+ $ chapter ->description_html = '<p>My <strong>chapter</strong> description</p> ' ;
439
+ $ chapter ->save ();
440
+
431
441
$ page = $ chapter ->pages ()->first ();
432
442
$ resp = $ this ->asEditor ()->get ($ book ->getUrl ('/export/markdown ' ));
433
443
434
444
$ resp ->assertSee ('# ' . $ book ->name );
435
445
$ resp ->assertSee ('# ' . $ chapter ->name );
436
446
$ resp ->assertSee ('# ' . $ page ->name );
447
+ $ resp ->assertSee ('My **book** description ' );
448
+ $ resp ->assertSee ('My **chapter** description ' );
437
449
}
438
450
439
451
public function test_book_markdown_export_concats_immediate_pages_with_newlines ()
You can’t perform that action at this time.
0 commit comments