+ /**
+ * Converts the page contents into simple plain text.
+ * This method filters any bad looking content to
+ * provide a nice final output.
+ * @param Page $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;
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+