]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/ChapterExportController.php
move zip export into exportservice
[bookstack] / app / Http / Controllers / ChapterExportController.php
index 0c86f854828b70dad5418a9b475c7262aef16612..c0fa9fad94fad64fb85df88416cc24750be2dafd 100644 (file)
@@ -55,4 +55,16 @@ class ChapterExportController extends Controller
         $chapterText = $this->exportService->chapterToPlainText($chapter);
         return $this->downloadResponse($chapterText, $chapterSlug . '.txt');
     }
+
+    /**
+     * Export a chapter to a simple markdown file.
+     * @throws NotFoundException
+     */
+    public function markdown(string $bookSlug, string $chapterSlug)
+    {
+        // TODO: This should probably export to a zip file.
+        $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
+        $chapterText = $this->exportService->chapterToMarkdown($chapter);
+        return $this->downloadResponse($chapterText, $chapterSlug . '.md');
+    }
 }