--- modules\node\node.module.1.911 Tue Nov 27 20:21:42 2007 +++ modules\node\node.module Tue Nov 27 21:04:55 2007 @@ -238,14 +238,20 @@ function node_teaser_js(&$form, &$form_s /** * Automatically generate a teaser for a node body. * + * If the end of the teaser is not indicated using the special delimiter + * then we try to end the teaser at a sensible place - i.e. the end of a + * paragraph, or a line break, or the end of a sentence. + * * @param $body * The content for which a teaser will be generated. * @param $format * The format of the content. If the content contains PHP code, we do not - * split it up to prevent parse errors. + * split it up to prevent parse errors; if the line break filter is present + * then we treat newlines embedded in $body as line breaks. * @param $size * The desired character length of the teaser. If omitted, the default - * value will be used. + * value will be used. Ignored if the special delimiter is present + * in $body. * @return * The generated teaser. */ @@ -279,7 +285,7 @@ function node_teaser($body, $format = NU } // If we have a short body, the entire body is the teaser. - if (strlen($body) < $size) { + if (strlen($body) <= $size) { return $body; } @@ -308,8 +314,15 @@ function node_teaser($body, $format = NU // A paragraph near the end of sliced teaser is most preferable. $break_points[] = array('

' => 0); - // Other line breaks often indicate a paragraph. - $break_points[] = array('
' => 6, '
' => 4, "\n" => 1); + // If no complete paragraph then treat line breaks as paragraphs. + // Newline only indicates a line break if line break converter + // filter is present. + if (isset($filters['filter/1'])) { + $break_points[] = array('
' => 6, '
' => 4, "\n" => 1); + } + else { + $break_points[] = array('
' => 6, '
' => 4); + } // If the first paragraph is too long, split at the end of a sentence. $break_points[] = array('. ' => 1, '! ' => 1, '? ' => 1, '。' => 0, '؟ ' => 1);