--- /usr/local/share/drupal/modules/node.module 2005-06-29 13:53:35.000000000 -0600 +++ node.module 2005-08-04 13:05:35.117414530 -0600 @@ -187,19 +187,23 @@ return $body; } + // Truncate the body. We will truncate further if there's a sensible + // place to do it within this initial truncation. + $teaser = truncate_utf8($body, $size); + // In some cases, no delimiter has been specified (e.g. when posting using // the Blogger API). In this case, we try to split at paragraph boundaries. // When even the first paragraph is too long, we try to split at the end of // the next sentence. $breakpoints = array('

' => 4, '
' => 0, '
' => 0, "\n" => 0, '. ' => 1, '! ' => 1, '? ' => 1, '。' => 1, '؟ ' => 1); foreach ($breakpoints as $point => $charnum) { - if ($length = strpos($body, $point, $size)) { - return substr($body, 0, $length + $charnum); + if ($length = strrpos($teaser, $point)) { + return substr($teaser, 0, $length + $charnum); } } - // If all else fails, we simply truncate the string. - return truncate_utf8($body, $size); + // If all else fails, we simply truncate. + return $teaser; }