1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

basic markdown export

This commit is contained in:
Nikhil Jha
2020-05-12 21:12:26 -07:00
parent 9666c8c0f7
commit a34a07c610
7 changed files with 84 additions and 0 deletions

View File

@ -53,4 +53,15 @@ class BookExportController extends Controller
$textContent = $this->exportService->bookToPlainText($book);
return $this->downloadResponse($textContent, $bookSlug . '.txt');
}
/**
* Export a book as a markdown file.
*/
public function markdown(string $bookSlug)
{
// TODO: This should probably export to a zip file.
$book = $this->bookRepo->getBySlug($bookSlug);
$textContent = $this->exportService->bookToMarkdown($book);
return $this->downloadResponse($textContent, $bookSlug . '.md');
}
}

View 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');
}
}

View File

@ -63,4 +63,15 @@ class PageExportController extends Controller
$pageText = $this->exportService->pageToPlainText($page);
return $this->downloadResponse($pageText, $pageSlug . '.txt');
}
/**
* Export a page to a simple markdown .md file.
* @throws NotFoundException
*/
public function markdown(string $bookSlug, string $pageSlug)
{
$page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
$pageText = $this->exportService->pageToMarkdown($page);
return $this->downloadResponse($pageText, $pageSlug . '.md');
}
}