1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Merge branch 'markdown-export' of https://github.com/nikhiljha/BookStack-1 into nikhiljha-markdown-export

This commit is contained in:
Dan Brown
2021-06-22 19:12:24 +01:00
9 changed files with 124 additions and 4 deletions

View File

@ -52,4 +52,24 @@ class BookExportController extends Controller
$textContent = $this->exportFormatter->bookToPlainText($book);
return $this->downloadResponse($textContent, $bookSlug . '.txt');
}
/**
* Export a book as a markdown file.
*/
public function markdown(string $bookSlug)
{
$book = $this->bookRepo->getBySlug($bookSlug);
$textContent = $this->exportService->bookToMarkdown($book);
return $this->downloadResponse($textContent, $bookSlug . '.md');
}
/**
* Export a book as a zip file, made of markdown files.
*/
public function zip(string $bookSlug)
{
$book = $this->bookRepo->getBySlug($bookSlug);
$filename = $this->exportService->bookToZip($book);
return response()->download($filename);
}
}

View File

@ -54,4 +54,16 @@ class ChapterExportController extends Controller
$chapterText = $this->exportFormatter->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

@ -60,4 +60,15 @@ class PageExportController extends Controller
$pageText = $this->exportFormatter->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');
}
}