BookStack\Services\ExportService::pageToPlainText PHP Method

pageToPlainText() public method

This method filters any bad looking content to provide a nice final output.
public pageToPlainText ( Page $page ) : mixed
$page BookStack\Page
return mixed
    public function pageToPlainText(Page $page)
    {
        $text = $page->text;
        // Replace multiple spaces with single spaces
        $text = preg_replace('/\\ {2,}/', ' ', $text);
        // Reduce multiple horrid whitespace characters.
        $text = preg_replace('/(\\x0A|\\xA0|\\x0A|\\r|\\n){2,}/su', "\n\n", $text);
        $text = html_entity_decode($text);
        // Add title
        $text = $page->name . "\n\n" . $text;
        return $text;
    }