diff --git a/inc/functions.php b/inc/functions.php
index effdbd05..efe98875 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -2377,6 +2377,16 @@ function unicodify($body) {
return $body;
}
+function end_on_newline($body) {
+ return strstr($body, "\n", true);
+}
+
+// If there is no punctuation before newline, add a full-stop.
+// Then replace all newlines/whitespace with a space.
+function remove_paragraphs($body) {
+ return preg_replace("/\s+/",' ', preg_replace("/\b(?=\n*$)/m",'.',$body));
+}
+
function extract_modifiers($body) {
$modifiers = array();
diff --git a/inc/lib/twig/extensions/Extension/Tinyboard.php b/inc/lib/twig/extensions/Extension/Tinyboard.php
index 3e36db73..c14d1523 100644
--- a/inc/lib/twig/extensions/Extension/Tinyboard.php
+++ b/inc/lib/twig/extensions/Extension/Tinyboard.php
@@ -19,6 +19,8 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
new Twig_SimpleFilter('capcode', 'capcode'),
new Twig_SimpleFilter('remove_modifiers', 'remove_modifiers'),
new Twig_SimpleFilter('remove_markup', 'remove_markup'),
+ new Twig_SimpleFilter('end_on_newline', 'end_on_newline'),
+ new Twig_SimpleFilter('remove_paragraphs', 'remove_paragraphs'),
new Twig_SimpleFilter('hasPermission', 'twig_hasPermission_filter'),
new Twig_SimpleFilter('date', 'twig_date_filter'),
new Twig_SimpleFilter('poster_id', 'poster_id'),
diff --git a/templates/thread.html b/templates/thread.html
index 042fb95b..112c3551 100644
--- a/templates/thread.html
+++ b/templates/thread.html
@@ -11,9 +11,10 @@
{% include 'header.html' %}
- {% set meta_subject %}{% if config.thread_subject_in_title and thread.subject %}{{ thread.subject|e }}{% else %}{{ thread.body_nomarkup|remove_modifiers|remove_markup[:256]|e }}{% endif %}{% endset %}
+ {% set meta_desc %}{{ thread.body_nomarkup|remove_modifiers|remove_markup|remove_paragraphs[:256]|e }}{% endset %}
+ {% set meta_subject %}{% if config.thread_subject_in_title and thread.subject %}{{ thread.subject|e }}{% else %}{{ thread.body_nomarkup|remove_modifiers|remove_markup|end_on_newline[:256]|e }}{% endif %}{% endset %}
-
+