]> BookStack Code Mirror - bookstack/commitdiff
Input WYSIWYG: Updated exports to handle HTML descriptions
authorDan Brown <redacted>
Fri, 22 Dec 2023 14:57:20 +0000 (14:57 +0000)
committerDan Brown <redacted>
Fri, 22 Dec 2023 14:57:20 +0000 (14:57 +0000)
resources/views/exports/book.blade.php
resources/views/exports/chapter.blade.php
resources/views/exports/parts/chapter-item.blade.php
tests/Entity/ExportTest.php

index 42e03ea01bb581366916bfb3134eadc76c92d7e2..9de7b8eba6c1be4e9be19d1e2ba931343bdf5cb4 100644 (file)
@@ -5,7 +5,7 @@
 @section('content')
 
     <h1 style="font-size: 4.8em">{{$book->name}}</h1>
 @section('content')
 
     <h1 style="font-size: 4.8em">{{$book->name}}</h1>
-    <p>{{ $book->description }}</p>
+    <div>{!! $book->descriptionHtml() !!}</div>
 
     @include('exports.parts.book-contents-menu', ['children' => $bookChildren])
 
 
     @include('exports.parts.book-contents-menu', ['children' => $bookChildren])
 
index ae49fa918288d70e7649861fd643aee762e8f4a7..515366d60e33f9bebcb2e8abdf404f50c74aabb5 100644 (file)
@@ -5,7 +5,7 @@
 @section('content')
 
     <h1 style="font-size: 4.8em">{{$chapter->name}}</h1>
 @section('content')
 
     <h1 style="font-size: 4.8em">{{$chapter->name}}</h1>
-    <p>{{ $chapter->description }}</p>
+    <div>{!! $chapter->descriptionHtml() !!}</div>
 
     @include('exports.parts.chapter-contents-menu', ['pages' => $pages])
 
 
     @include('exports.parts.chapter-contents-menu', ['pages' => $pages])
 
index f58068b5e4cf3dcd89055f8a69df90d761d39bda..fa0b1f22884b6eeb7ecef0612899579f01bcf782 100644 (file)
@@ -1,7 +1,7 @@
 <div class="page-break"></div>
 <h1 id="chapter-{{$chapter->id}}">{{ $chapter->name }}</h1>
 
 <div class="page-break"></div>
 <h1 id="chapter-{{$chapter->id}}">{{ $chapter->name }}</h1>
 
-<p>{{ $chapter->description }}</p>
+<div>{!! $chapter->descriptionHtml() !!}</div>
 
 @if(count($chapter->visible_pages) > 0)
     @foreach($chapter->visible_pages as $page)
 
 @if(count($chapter->visible_pages) > 0)
     @foreach($chapter->visible_pages as $page)
index 08bf17d0ada22d799a3ee271a91e5cf2acf626c3..eedcb672c998da7b53a26f76e7e59ae7fe6885e0 100644 (file)
@@ -107,18 +107,18 @@ class ExportTest extends TestCase
         $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $book->slug . '.html"');
     }
 
         $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $book->slug . '.html"');
     }
 
-    public function test_book_html_export_shows_chapter_descriptions()
+    public function test_book_html_export_shows_html_descriptions()
     {
     {
-        $chapterDesc = 'My custom test chapter description ' . Str::random(12);
-        $chapter = $this->entities->chapter();
-        $chapter->description = $chapterDesc;
+        $book = $this->entities->bookHasChaptersAndPages();
+        $chapter = $book->chapters()->first();
+        $book->description_html = '<p>A description with <strong>HTML</strong> within!</p>';
+        $chapter->description_html = '<p>A chapter description with <strong>HTML</strong> within!</p>';
+        $book->save();
         $chapter->save();
 
         $chapter->save();
 
-        $book = $chapter->book;
-        $this->asEditor();
-
-        $resp = $this->get($book->getUrl('/export/html'));
-        $resp->assertSee($chapterDesc);
+        $resp = $this->asEditor()->get($book->getUrl('/export/html'));
+        $resp->assertSee($book->description_html, false);
+        $resp->assertSee($chapter->description_html, false);
     }
 
     public function test_chapter_text_export()
     }
 
     public function test_chapter_text_export()
@@ -174,6 +174,16 @@ class ExportTest extends TestCase
         $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $chapter->slug . '.html"');
     }
 
         $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $chapter->slug . '.html"');
     }
 
+    public function test_chapter_html_export_shows_html_descriptions()
+    {
+        $chapter = $this->entities->chapter();
+        $chapter->description_html = '<p>A description with <strong>HTML</strong> within!</p>';
+        $chapter->save();
+
+        $resp = $this->asEditor()->get($chapter->getUrl('/export/html'));
+        $resp->assertSee($chapter->description_html, false);
+    }
+
     public function test_page_html_export_contains_custom_head_if_set()
     {
         $page = $this->entities->page();
     public function test_page_html_export_contains_custom_head_if_set()
     {
         $page = $this->entities->page();